Skip to content

Commit 3665c88

Browse files
committed
pthread_cond_t
1 parent 61d758b commit 3665c88

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

src/unix/notbsd/linux/mod.rs

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,27 @@ s! {
127127
size: [u8; __SIZEOF_PTHREAD_RWLOCKATTR_T],
128128
}
129129

130+
#[cfg_attr(all(feature = "align",
131+
target_env = "musl",
132+
target_pointer_width = "32"),
133+
repr(align(4)))]
134+
#[cfg_attr(all(feature = "align",
135+
target_env = "musl",
136+
target_pointer_width = "64"),
137+
repr(align(8)))]
138+
#[cfg_attr(all(feature = "align", not(target_env = "musl")),
139+
repr(align(8)))]
130140
pub struct pthread_cond_t {
131-
#[cfg(any(target_env = "musl"))]
141+
#[cfg(all(not(feature = "align"), target_env = "musl"))]
132142
__align: [*const ::c_void; 0],
133-
#[cfg(not(any(target_env = "musl")))]
143+
#[cfg(not(any(feature = "align", target_env = "musl")))]
134144
__align: [::c_longlong; 0],
135145
size: [u8; __SIZEOF_PTHREAD_COND_T],
136146
}
137147

148+
#[cfg_attr(feature = "align", repr(align(4)))]
138149
pub struct pthread_condattr_t {
150+
#[cfg(not(feature = "align"))]
139151
__align: [::c_int; 0],
140152
size: [u8; __SIZEOF_PTHREAD_CONDATTR_T],
141153
}
@@ -796,10 +808,18 @@ pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
796808
__align: [],
797809
size: [0; __SIZEOF_PTHREAD_MUTEX_T],
798810
};
799-
pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
800-
__align: [],
801-
size: [0; __SIZEOF_PTHREAD_COND_T],
802-
};
811+
cfg_if! {
812+
if #[cfg(feature = "align")] {
813+
pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
814+
size: [0; __SIZEOF_PTHREAD_COND_T],
815+
};
816+
} else {
817+
pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
818+
__align: [],
819+
size: [0; __SIZEOF_PTHREAD_COND_T],
820+
};
821+
}
822+
}
803823
pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
804824
__align: [],
805825
size: [0; __SIZEOF_PTHREAD_RWLOCK_T],

0 commit comments

Comments
 (0)