Merge pull request #335 from tmiasko/condattr
Add support for pthread_condattr_t on Unix platforms.
This commit is contained in:
commit
b065b3c659
@ -22,9 +22,11 @@ fn main() {
|
||||
let bsdlike = freebsd || apple || netbsd || openbsd || dragonfly;
|
||||
let mut cfg = ctest::TestGenerator::new();
|
||||
|
||||
// Pull in extra goodies on linux/mingw
|
||||
// Pull in extra goodies
|
||||
if linux || android {
|
||||
cfg.define("_GNU_SOURCE", None);
|
||||
} else if netbsd {
|
||||
cfg.define("_NETBSD_SOURCE", Some("1"));
|
||||
} else if windows {
|
||||
cfg.define("_WIN32_WINNT", Some("0x8000"));
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ s! {
|
||||
|
||||
pub const __PTHREAD_MUTEX_SIZE__: usize = 40;
|
||||
pub const __PTHREAD_COND_SIZE__: usize = 24;
|
||||
pub const __PTHREAD_CONDATTR_SIZE__: usize = 4;
|
||||
pub const __PTHREAD_RWLOCK_SIZE__: usize = 124;
|
||||
|
||||
pub const TIOCTIMESTAMP: ::c_ulong = 0x40087459;
|
||||
|
@ -12,6 +12,7 @@ s! {
|
||||
|
||||
pub const __PTHREAD_MUTEX_SIZE__: usize = 56;
|
||||
pub const __PTHREAD_COND_SIZE__: usize = 40;
|
||||
pub const __PTHREAD_CONDATTR_SIZE__: usize = 8;
|
||||
pub const __PTHREAD_RWLOCK_SIZE__: usize = 192;
|
||||
|
||||
pub const TIOCTIMESTAMP: ::c_ulong = 0x40107459;
|
||||
|
@ -114,6 +114,11 @@ s! {
|
||||
__opaque: [u8; __PTHREAD_COND_SIZE__],
|
||||
}
|
||||
|
||||
pub struct pthread_condattr_t {
|
||||
__sig: ::c_long,
|
||||
__opaque: [u8; __PTHREAD_CONDATTR_SIZE__],
|
||||
}
|
||||
|
||||
pub struct pthread_rwlock_t {
|
||||
__sig: ::c_long,
|
||||
__opaque: [u8; __PTHREAD_RWLOCK_SIZE__],
|
||||
|
@ -5,6 +5,7 @@ pub type rlim_t = i64;
|
||||
pub type pthread_mutex_t = *mut ::c_void;
|
||||
pub type pthread_mutexattr_t = *mut ::c_void;
|
||||
pub type pthread_cond_t = *mut ::c_void;
|
||||
pub type pthread_condattr_t = *mut ::c_void;
|
||||
pub type pthread_rwlock_t = *mut ::c_void;
|
||||
pub type pthread_key_t = ::c_int;
|
||||
pub type tcflag_t = ::c_uint;
|
||||
@ -806,6 +807,10 @@ extern {
|
||||
flags: ::c_int) -> ::c_int;
|
||||
pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char,
|
||||
mode: ::mode_t) -> ::c_int;
|
||||
pub fn pthread_condattr_getclock(attr: *const pthread_condattr_t,
|
||||
clock_id: *mut clockid_t) -> ::c_int;
|
||||
pub fn pthread_condattr_setclock(attr: *mut pthread_condattr_t,
|
||||
clock_id: clockid_t) -> ::c_int;
|
||||
}
|
||||
|
||||
cfg_if! {
|
||||
|
@ -9,6 +9,7 @@ pub type pthread_attr_t = *mut ::c_void;
|
||||
pub type pthread_mutex_t = *mut ::c_void;
|
||||
pub type pthread_mutexattr_t = *mut ::c_void;
|
||||
pub type pthread_cond_t = *mut ::c_void;
|
||||
pub type pthread_condattr_t = *mut ::c_void;
|
||||
pub type pthread_rwlock_t = *mut ::c_void;
|
||||
|
||||
s! {
|
||||
|
@ -525,6 +525,8 @@ extern {
|
||||
flags: ::c_int) -> ::c_int;
|
||||
pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char,
|
||||
mode: ::mode_t) -> ::c_int;
|
||||
pub fn pthread_condattr_setclock(attr: *mut pthread_condattr_t,
|
||||
clock_id: clockid_t) -> ::c_int;
|
||||
}
|
||||
|
||||
cfg_if! {
|
||||
|
@ -152,6 +152,11 @@ s! {
|
||||
ptc_private: *mut ::c_void,
|
||||
}
|
||||
|
||||
pub struct pthread_condattr_t {
|
||||
ptca_magic: ::c_uint,
|
||||
ptca_private: *mut ::c_void,
|
||||
}
|
||||
|
||||
pub struct pthread_rwlock_t {
|
||||
ptr_magic: ::c_uint,
|
||||
ptr_interlock: ::c_uchar,
|
||||
|
@ -9,6 +9,7 @@ pub type pthread_attr_t = *mut ::c_void;
|
||||
pub type pthread_mutex_t = *mut ::c_void;
|
||||
pub type pthread_mutexattr_t = *mut ::c_void;
|
||||
pub type pthread_cond_t = *mut ::c_void;
|
||||
pub type pthread_condattr_t = *mut ::c_void;
|
||||
pub type pthread_rwlock_t = *mut ::c_void;
|
||||
|
||||
s! {
|
||||
|
@ -538,6 +538,10 @@ extern {
|
||||
pub fn pthread_mutexattr_settype(attr: *mut pthread_mutexattr_t,
|
||||
_type: ::c_int) -> ::c_int;
|
||||
|
||||
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
|
||||
link_name = "pthread_cond_init$UNIX2003")]
|
||||
pub fn pthread_cond_init(cond: *mut pthread_cond_t,
|
||||
attr: *const pthread_condattr_t) -> ::c_int;
|
||||
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
|
||||
link_name = "pthread_cond_wait$UNIX2003")]
|
||||
pub fn pthread_cond_wait(cond: *mut pthread_cond_t,
|
||||
@ -550,6 +554,8 @@ extern {
|
||||
pub fn pthread_cond_signal(cond: *mut pthread_cond_t) -> ::c_int;
|
||||
pub fn pthread_cond_broadcast(cond: *mut pthread_cond_t) -> ::c_int;
|
||||
pub fn pthread_cond_destroy(cond: *mut pthread_cond_t) -> ::c_int;
|
||||
pub fn pthread_condattr_init(attr: *mut pthread_condattr_t) -> ::c_int;
|
||||
pub fn pthread_condattr_destroy(attr: *mut pthread_condattr_t) -> ::c_int;
|
||||
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
|
||||
link_name = "pthread_rwlock_destroy$UNIX2003")]
|
||||
pub fn pthread_rwlock_destroy(lock: *mut pthread_rwlock_t) -> ::c_int;
|
||||
|
@ -13,6 +13,7 @@ pub type useconds_t = u32;
|
||||
pub type socklen_t = i32;
|
||||
pub type pthread_t = ::c_long;
|
||||
pub type pthread_mutexattr_t = ::c_long;
|
||||
pub type pthread_condattr_t = ::c_long;
|
||||
pub type sigset_t = ::c_ulong;
|
||||
pub type time64_t = i64; // N/A on android
|
||||
pub type fsfilcnt_t = ::c_ulong;
|
||||
|
@ -378,6 +378,7 @@ pub const SO_RCVTIMEO: ::c_int = 4102;
|
||||
pub const SO_SNDTIMEO: ::c_int = 4101;
|
||||
pub const SO_ACCEPTCONN: ::c_int = 4105;
|
||||
|
||||
pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
|
||||
pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24;
|
||||
pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32;
|
||||
pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
|
||||
|
@ -104,6 +104,11 @@ s! {
|
||||
size: [u8; __SIZEOF_PTHREAD_COND_T],
|
||||
}
|
||||
|
||||
pub struct pthread_condattr_t {
|
||||
__align: [::c_int; 0],
|
||||
size: [u8; __SIZEOF_PTHREAD_CONDATTR_T],
|
||||
}
|
||||
|
||||
pub struct passwd {
|
||||
pub pw_name: *mut ::c_char,
|
||||
pub pw_passwd: *mut ::c_char,
|
||||
|
@ -107,6 +107,7 @@ pub const SIGUNUSED: ::c_int = ::SIGSYS;
|
||||
pub const FALLOC_FL_KEEP_SIZE: ::c_int = 0x01;
|
||||
pub const FALLOC_FL_PUNCH_HOLE: ::c_int = 0x02;
|
||||
|
||||
pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
|
||||
pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
|
||||
|
||||
pub const CPU_SETSIZE: ::c_int = 128;
|
||||
|
@ -85,6 +85,7 @@ s! {
|
||||
}
|
||||
}
|
||||
|
||||
pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
|
||||
pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24;
|
||||
pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32;
|
||||
pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
|
||||
|
@ -55,6 +55,7 @@ s! {
|
||||
}
|
||||
}
|
||||
|
||||
pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 8;
|
||||
pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 48;
|
||||
pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 8;
|
||||
|
||||
|
@ -53,6 +53,7 @@ s! {
|
||||
}
|
||||
}
|
||||
|
||||
pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
|
||||
pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40;
|
||||
pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
|
||||
|
||||
|
@ -93,6 +93,7 @@ s! {
|
||||
}
|
||||
}
|
||||
|
||||
pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
|
||||
pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40;
|
||||
pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
|
||||
|
||||
|
@ -860,6 +860,10 @@ extern {
|
||||
linkpath: *const ::c_char) -> ::c_int;
|
||||
pub fn unlinkat(dirfd: ::c_int, pathname: *const ::c_char,
|
||||
flags: ::c_int) -> ::c_int;
|
||||
pub fn pthread_condattr_getclock(attr: *const pthread_condattr_t,
|
||||
clock_id: *mut clockid_t) -> ::c_int;
|
||||
pub fn pthread_condattr_setclock(attr: *mut pthread_condattr_t,
|
||||
clock_id: clockid_t) -> ::c_int;
|
||||
}
|
||||
|
||||
cfg_if! {
|
||||
|
@ -143,6 +143,10 @@ s! {
|
||||
__pthread_cond_data: u64
|
||||
}
|
||||
|
||||
pub struct pthread_condattr_t {
|
||||
__pthread_condattrp: *mut ::c_void,
|
||||
}
|
||||
|
||||
pub struct pthread_rwlock_t {
|
||||
__pthread_rwlock_readers: i32,
|
||||
__pthread_rwlock_type: u16,
|
||||
@ -1013,5 +1017,9 @@ extern {
|
||||
pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int;
|
||||
pub fn if_nameindex() -> *mut if_nameindex;
|
||||
pub fn if_freenameindex(ptr: *mut if_nameindex);
|
||||
pub fn pthread_condattr_getclock(attr: *const pthread_condattr_t,
|
||||
clock_id: *mut clockid_t) -> ::c_int;
|
||||
pub fn pthread_condattr_setclock(attr: *mut pthread_condattr_t,
|
||||
clock_id: clockid_t) -> ::c_int;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user