Skip to content

Commit

Permalink
Testing out alignment in emscripten
Browse files Browse the repository at this point in the history
  • Loading branch information
faern committed Jul 20, 2018
1 parent 555bf67 commit 6e6c0a5
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/unix/notbsd/emscripten.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,32 +72,45 @@ s! {
__unused5: *mut ::c_void,
}

#[cfg_attr(feature = "align", repr(align(8)))]
pub struct pthread_mutex_t {
#[cfg(not(feature = "align"))]
__align: [::c_long; 0],
size: [u8; __SIZEOF_PTHREAD_MUTEX_T],
}

#[cfg_attr(feature = "align", repr(align(8)))]
pub struct pthread_rwlock_t {
#[cfg(not(feature = "align"))]
__align: [::c_long; 0],
size: [u8; __SIZEOF_PTHREAD_RWLOCK_T],
}

#[cfg_attr(feature = "align", repr(align(4)))]
pub struct pthread_mutexattr_t {
#[cfg(not(feature = "align"))]
__align: [::c_int; 0],
size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T],
}

#[cfg_attr(feature = "align", repr(align(4)))]
pub struct pthread_rwlockattr_t {
#[cfg(not(feature = "align"))]
__align: [::c_int; 0],
size: [u8; __SIZEOF_PTHREAD_RWLOCKATTR_T],
}

#[cfg_attr(all(feature = "align", target_pointer_width = "32"), repr(align(4)))]
#[cfg_attr(all(feature = "align", target_pointer_width = "64"), repr(align(8)))]
pub struct pthread_cond_t {
#[cfg(not(feature = "align"))]
__align: [*const ::c_void; 0],
size: [u8; __SIZEOF_PTHREAD_COND_T],
}

#[cfg_attr(feature = "align", repr(align(4)))]
pub struct pthread_condattr_t {
#[cfg(not(feature = "align"))]
__align: [::c_int; 0],
size: [u8; __SIZEOF_PTHREAD_CONDATTR_T],
}
Expand Down Expand Up @@ -748,14 +761,17 @@ pub const RTLD_NOW: ::c_int = 0x2;
pub const TCP_MD5SIG: ::c_int = 14;

pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
#[cfg(not(feature = "align"))]
__align: [],
size: [0; __SIZEOF_PTHREAD_MUTEX_T],
};
pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
#[cfg(not(feature = "align"))]
__align: [],
size: [0; __SIZEOF_PTHREAD_COND_T],
};
pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
#[cfg(not(feature = "align"))]
__align: [],
size: [0; __SIZEOF_PTHREAD_RWLOCK_T],
};
Expand Down

0 comments on commit 6e6c0a5

Please sign in to comment.