Skip to content

Commit 6e6c0a5

Browse files
committed
Testing out alignment in emscripten
1 parent 555bf67 commit 6e6c0a5

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/unix/notbsd/emscripten.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,32 +72,45 @@ s! {
7272
__unused5: *mut ::c_void,
7373
}
7474

75+
#[cfg_attr(feature = "align", repr(align(8)))]
7576
pub struct pthread_mutex_t {
77+
#[cfg(not(feature = "align"))]
7678
__align: [::c_long; 0],
7779
size: [u8; __SIZEOF_PTHREAD_MUTEX_T],
7880
}
7981

82+
#[cfg_attr(feature = "align", repr(align(8)))]
8083
pub struct pthread_rwlock_t {
84+
#[cfg(not(feature = "align"))]
8185
__align: [::c_long; 0],
8286
size: [u8; __SIZEOF_PTHREAD_RWLOCK_T],
8387
}
8488

89+
#[cfg_attr(feature = "align", repr(align(4)))]
8590
pub struct pthread_mutexattr_t {
91+
#[cfg(not(feature = "align"))]
8692
__align: [::c_int; 0],
8793
size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T],
8894
}
8995

96+
#[cfg_attr(feature = "align", repr(align(4)))]
9097
pub struct pthread_rwlockattr_t {
98+
#[cfg(not(feature = "align"))]
9199
__align: [::c_int; 0],
92100
size: [u8; __SIZEOF_PTHREAD_RWLOCKATTR_T],
93101
}
94102

103+
#[cfg_attr(all(feature = "align", target_pointer_width = "32"), repr(align(4)))]
104+
#[cfg_attr(all(feature = "align", target_pointer_width = "64"), repr(align(8)))]
95105
pub struct pthread_cond_t {
106+
#[cfg(not(feature = "align"))]
96107
__align: [*const ::c_void; 0],
97108
size: [u8; __SIZEOF_PTHREAD_COND_T],
98109
}
99110

111+
#[cfg_attr(feature = "align", repr(align(4)))]
100112
pub struct pthread_condattr_t {
113+
#[cfg(not(feature = "align"))]
101114
__align: [::c_int; 0],
102115
size: [u8; __SIZEOF_PTHREAD_CONDATTR_T],
103116
}
@@ -748,14 +761,17 @@ pub const RTLD_NOW: ::c_int = 0x2;
748761
pub const TCP_MD5SIG: ::c_int = 14;
749762

750763
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
764+
#[cfg(not(feature = "align"))]
751765
__align: [],
752766
size: [0; __SIZEOF_PTHREAD_MUTEX_T],
753767
};
754768
pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
769+
#[cfg(not(feature = "align"))]
755770
__align: [],
756771
size: [0; __SIZEOF_PTHREAD_COND_T],
757772
};
758773
pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
774+
#[cfg(not(feature = "align"))]
759775
__align: [],
760776
size: [0; __SIZEOF_PTHREAD_RWLOCK_T],
761777
};

0 commit comments

Comments
 (0)