From 6e6c0a5123fc90d564f88faef5ea1d15e4164f94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20F=C3=A4rnstrand?= Date: Sat, 21 Jul 2018 00:47:01 +0200 Subject: [PATCH] Testing out alignment in emscripten --- src/unix/notbsd/emscripten.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/unix/notbsd/emscripten.rs b/src/unix/notbsd/emscripten.rs index 6216947ee5152..cb1311d2eff0c 100644 --- a/src/unix/notbsd/emscripten.rs +++ b/src/unix/notbsd/emscripten.rs @@ -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], } @@ -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], };