File tree Expand file tree Collapse file tree 11 files changed +70
-0
lines changed
Expand file tree Collapse file tree 11 files changed +70
-0
lines changed Original file line number Diff line number Diff line change @@ -96,6 +96,7 @@ fn main() {
9696 cfg. header ( "termios.h" ) ;
9797 cfg. header ( "poll.h" ) ;
9898 cfg. header ( "syslog.h" ) ;
99+ cfg. header ( "semaphore.h" ) ;
99100 }
100101
101102 if android {
@@ -285,6 +286,8 @@ fn main() {
285286 // uuid_t is a struct, not an integer.
286287 "uuid_t" if dragonfly => true ,
287288 n if n. starts_with ( "pthread" ) => true ,
289+ // sem_t is a struct or pointer
290+ "sem_t" if openbsd || freebsd || rumprun => true ,
288291
289292 // windows-isms
290293 n if n. starts_with ( "P" ) => true ,
@@ -363,6 +366,10 @@ fn main() {
363366 // we turn into an error) so just ignore it.
364367 "daemon" if apple => true ,
365368
369+ // Deprecated on OSX
370+ "sem_destroy" if apple => true ,
371+ "sem_init" if apple => true ,
372+
366373 // These functions presumably exist on netbsd but don't look like
367374 // they're implemented on rumprun yet, just let them slide for now.
368375 // Some of them look like they have headers but then don't have
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ pub type speed_t = ::c_ulong;
2020pub type tcflag_t = :: c_ulong ;
2121pub type nl_item = :: c_int ;
2222pub type id_t = :: c_uint ;
23+ pub type sem_t = :: c_int ;
2324
2425pub enum timezone { }
2526
@@ -1248,6 +1249,8 @@ pub const PRIO_DARWIN_PROCESS: ::c_int = 4;
12481249pub const PRIO_DARWIN_BG : :: c_int = 0x1000 ;
12491250pub const PRIO_DARWIN_NONUI : :: c_int = 0x1001 ;
12501251
1252+ pub const SEM_FAILED : * mut sem_t = -1isize as * mut :: sem_t ;
1253+
12511254f ! {
12521255 pub fn WSTOPSIG ( status: :: c_int) -> :: c_int {
12531256 status >> 8
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ pub type tcflag_t = ::c_uint;
1111pub type speed_t = :: c_uint ;
1212pub type nl_item = :: c_int ;
1313pub type id_t = i64 ;
14+ pub type sem_t = _sem ;
1415
1516pub enum timezone { }
1617
@@ -149,6 +150,11 @@ s! {
149150 pub int_p_sign_posn: :: c_char,
150151 pub int_n_sign_posn: :: c_char,
151152 }
153+
154+ // internal structure has changed over time
155+ pub struct _sem {
156+ data: [ u32 ; 4 ] ,
157+ }
152158}
153159
154160pub const LC_COLLATE_MASK : :: c_int = ( 1 << 0 ) ;
@@ -677,6 +683,8 @@ pub const LOG_NFACILITIES: ::c_int = 24;
677683pub const TIOCGWINSZ : :: c_ulong = 0x40087468 ;
678684pub const TIOCSWINSZ : :: c_ulong = 0x80087467 ;
679685
686+ pub const SEM_FAILED : * mut sem_t = 0 as * mut sem_t ;
687+
680688#[ link( name = "util" ) ]
681689extern {
682690 pub fn getnameinfo ( sa : * const :: sockaddr ,
Original file line number Diff line number Diff line change @@ -11,8 +11,10 @@ pub type tcflag_t = ::c_uint;
1111pub type nl_item = c_long ;
1212pub type clockid_t = :: c_int ;
1313pub type id_t = :: uint32_t ;
14+ pub type sem_t = * mut sem ;
1415
1516pub enum timezone { }
17+ pub enum sem { }
1618
1719s ! {
1820 pub struct sigaction {
@@ -445,6 +447,8 @@ pub const LOG_NFACILITIES: ::c_int = 24;
445447
446448pub const HW_NCPU : :: c_int = 3 ;
447449
450+ pub const SEM_FAILED : * mut sem_t = 0 as * mut sem_t ;
451+
448452#[ link( name = "util" ) ]
449453extern {
450454 pub fn mincore ( addr : * mut :: c_void , len : :: size_t ,
Original file line number Diff line number Diff line change @@ -673,6 +673,20 @@ extern {
673673 pub fn setlocale ( category : :: c_int ,
674674 locale : * const :: c_char ) -> * mut :: c_char ;
675675 pub fn localeconv ( ) -> * mut lconv ;
676+
677+ pub fn sem_destroy ( sem : * mut sem_t ) -> :: c_int ;
678+ pub fn sem_open ( name : * const :: c_char , oflag : :: c_int , ...) -> * mut sem_t ;
679+ pub fn sem_close ( sem : * mut sem_t ) -> :: c_int ;
680+ pub fn sem_unlink ( name : * const :: c_char ) -> :: c_int ;
681+ #[ cfg_attr( all( target_os = "macos" , target_arch = "x86" ) ,
682+ link_name = "sem_wait$UNIX2003" ) ]
683+ pub fn sem_wait ( sem : * mut sem_t ) -> :: c_int ;
684+ pub fn sem_trywait ( sem : * mut sem_t ) -> :: c_int ;
685+ pub fn sem_post ( sem : * mut sem_t ) -> :: c_int ;
686+ pub fn sem_init ( sem : * mut sem_t ,
687+ pshared : :: c_int ,
688+ value : :: c_uint )
689+ -> :: c_int ;
676690}
677691
678692// TODO: get rid of this cfg(not(...))
Original file line number Diff line number Diff line change 9595 #[ cfg( target_pointer_width = "32" ) ]
9696 __bits: [ __CPU_BITTYPE; 1 ] ,
9797 }
98+
99+ pub struct sem_t {
100+ count: :: c_uint,
101+ }
98102}
99103
100104pub const BUFSIZ : :: c_uint = 1024 ;
@@ -472,6 +476,8 @@ pub const RTLD_NOLOAD: ::c_int = 0x4;
472476pub const RTLD_NOW : :: c_int = 0 ;
473477pub const RTLD_DEFAULT : * mut :: c_void = -1isize as * mut :: c_void ;
474478
479+ pub const SEM_FAILED : * mut sem_t = 0 as * mut sem_t ;
480+
475481f ! {
476482 pub fn sigemptyset( set: * mut sigset_t) -> :: c_int {
477483 * set = 0 ;
Original file line number Diff line number Diff line change @@ -189,6 +189,15 @@ s! {
189189 pub mem_unit: :: c_uint,
190190 pub _f: [ :: c_char; 8 ] ,
191191 }
192+
193+ // FIXME this is actually a union
194+ pub struct sem_t {
195+ #[ cfg( target_pointer_width = "32" ) ]
196+ __size: [ :: c_char; 16 ] ,
197+ #[ cfg( target_pointer_width = "64" ) ]
198+ __size: [ :: c_char; 32 ] ,
199+ __align: [ :: c_long; 0 ] ,
200+ }
192201}
193202
194203pub const BUFSIZ : :: c_uint = 8192 ;
Original file line number Diff line number Diff line change @@ -452,6 +452,8 @@ pub const AF_NETLINK: ::c_int = 16;
452452
453453pub const LOG_NFACILITIES : :: c_int = 24 ;
454454
455+ pub const SEM_FAILED : * mut :: sem_t = 0 as * mut sem_t ;
456+
455457f ! {
456458 pub fn CPU_ZERO ( cpuset: & mut cpu_set_t) -> ( ) {
457459 for slot in cpuset. bits. iter_mut( ) {
Original file line number Diff line number Diff line change 2020 pub msg_controllen: :: socklen_t,
2121 pub msg_flags: :: c_int,
2222 }
23+
24+ pub struct sem_t {
25+ __val: [ :: c_int; 4 ] ,
26+ }
2327}
2428
2529pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32 ;
Original file line number Diff line number Diff line change @@ -100,6 +100,10 @@ s! {
100100 __pad2: :: socklen_t,
101101 pub msg_flags: :: c_int,
102102 }
103+
104+ pub struct sem_t {
105+ __val: [ :: c_int; 8 ] ,
106+ }
103107}
104108
105109pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56 ;
You can’t perform that action at this time.
0 commit comments