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() {
96
96
cfg. header ( "termios.h" ) ;
97
97
cfg. header ( "poll.h" ) ;
98
98
cfg. header ( "syslog.h" ) ;
99
+ cfg. header ( "semaphore.h" ) ;
99
100
}
100
101
101
102
if android {
@@ -285,6 +286,8 @@ fn main() {
285
286
// uuid_t is a struct, not an integer.
286
287
"uuid_t" if dragonfly => true ,
287
288
n if n. starts_with ( "pthread" ) => true ,
289
+ // sem_t is a struct or pointer
290
+ "sem_t" if openbsd || freebsd || rumprun => true ,
288
291
289
292
// windows-isms
290
293
n if n. starts_with ( "P" ) => true ,
@@ -363,6 +366,10 @@ fn main() {
363
366
// we turn into an error) so just ignore it.
364
367
"daemon" if apple => true ,
365
368
369
+ // Deprecated on OSX
370
+ "sem_destroy" if apple => true ,
371
+ "sem_init" if apple => true ,
372
+
366
373
// These functions presumably exist on netbsd but don't look like
367
374
// they're implemented on rumprun yet, just let them slide for now.
368
375
// 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;
20
20
pub type tcflag_t = :: c_ulong ;
21
21
pub type nl_item = :: c_int ;
22
22
pub type id_t = :: c_uint ;
23
+ pub type sem_t = :: c_int ;
23
24
24
25
pub enum timezone { }
25
26
@@ -1248,6 +1249,8 @@ pub const PRIO_DARWIN_PROCESS: ::c_int = 4;
1248
1249
pub const PRIO_DARWIN_BG : :: c_int = 0x1000 ;
1249
1250
pub const PRIO_DARWIN_NONUI : :: c_int = 0x1001 ;
1250
1251
1252
+ pub const SEM_FAILED : * mut sem_t = -1isize as * mut :: sem_t ;
1253
+
1251
1254
f ! {
1252
1255
pub fn WSTOPSIG ( status: :: c_int) -> :: c_int {
1253
1256
status >> 8
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ pub type tcflag_t = ::c_uint;
11
11
pub type speed_t = :: c_uint ;
12
12
pub type nl_item = :: c_int ;
13
13
pub type id_t = i64 ;
14
+ pub type sem_t = _sem ;
14
15
15
16
pub enum timezone { }
16
17
@@ -149,6 +150,11 @@ s! {
149
150
pub int_p_sign_posn: :: c_char,
150
151
pub int_n_sign_posn: :: c_char,
151
152
}
153
+
154
+ // internal structure has changed over time
155
+ pub struct _sem {
156
+ data: [ u32 ; 4 ] ,
157
+ }
152
158
}
153
159
154
160
pub const LC_COLLATE_MASK : :: c_int = ( 1 << 0 ) ;
@@ -677,6 +683,8 @@ pub const LOG_NFACILITIES: ::c_int = 24;
677
683
pub const TIOCGWINSZ : :: c_ulong = 0x40087468 ;
678
684
pub const TIOCSWINSZ : :: c_ulong = 0x80087467 ;
679
685
686
+ pub const SEM_FAILED : * mut sem_t = 0 as * mut sem_t ;
687
+
680
688
#[ link( name = "util" ) ]
681
689
extern {
682
690
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;
11
11
pub type nl_item = c_long ;
12
12
pub type clockid_t = :: c_int ;
13
13
pub type id_t = :: uint32_t ;
14
+ pub type sem_t = * mut sem ;
14
15
15
16
pub enum timezone { }
17
+ pub enum sem { }
16
18
17
19
s ! {
18
20
pub struct sigaction {
@@ -445,6 +447,8 @@ pub const LOG_NFACILITIES: ::c_int = 24;
445
447
446
448
pub const HW_NCPU : :: c_int = 3 ;
447
449
450
+ pub const SEM_FAILED : * mut sem_t = 0 as * mut sem_t ;
451
+
448
452
#[ link( name = "util" ) ]
449
453
extern {
450
454
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 {
673
673
pub fn setlocale ( category : :: c_int ,
674
674
locale : * const :: c_char ) -> * mut :: c_char ;
675
675
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 ;
676
690
}
677
691
678
692
// TODO: get rid of this cfg(not(...))
Original file line number Diff line number Diff line change 95
95
#[ cfg( target_pointer_width = "32" ) ]
96
96
__bits: [ __CPU_BITTYPE; 1 ] ,
97
97
}
98
+
99
+ pub struct sem_t {
100
+ count: :: c_uint,
101
+ }
98
102
}
99
103
100
104
pub const BUFSIZ : :: c_uint = 1024 ;
@@ -472,6 +476,8 @@ pub const RTLD_NOLOAD: ::c_int = 0x4;
472
476
pub const RTLD_NOW : :: c_int = 0 ;
473
477
pub const RTLD_DEFAULT : * mut :: c_void = -1isize as * mut :: c_void ;
474
478
479
+ pub const SEM_FAILED : * mut sem_t = 0 as * mut sem_t ;
480
+
475
481
f ! {
476
482
pub fn sigemptyset( set: * mut sigset_t) -> :: c_int {
477
483
* set = 0 ;
Original file line number Diff line number Diff line change @@ -189,6 +189,15 @@ s! {
189
189
pub mem_unit: :: c_uint,
190
190
pub _f: [ :: c_char; 8 ] ,
191
191
}
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
+ }
192
201
}
193
202
194
203
pub 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;
452
452
453
453
pub const LOG_NFACILITIES : :: c_int = 24 ;
454
454
455
+ pub const SEM_FAILED : * mut :: sem_t = 0 as * mut sem_t ;
456
+
455
457
f ! {
456
458
pub fn CPU_ZERO ( cpuset: & mut cpu_set_t) -> ( ) {
457
459
for slot in cpuset. bits. iter_mut( ) {
Original file line number Diff line number Diff line change 20
20
pub msg_controllen: :: socklen_t,
21
21
pub msg_flags: :: c_int,
22
22
}
23
+
24
+ pub struct sem_t {
25
+ __val: [ :: c_int; 4 ] ,
26
+ }
23
27
}
24
28
25
29
pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32 ;
Original file line number Diff line number Diff line change @@ -100,6 +100,10 @@ s! {
100
100
__pad2: :: socklen_t,
101
101
pub msg_flags: :: c_int,
102
102
}
103
+
104
+ pub struct sem_t {
105
+ __val: [ :: c_int; 8 ] ,
106
+ }
103
107
}
104
108
105
109
pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56 ;
Original file line number Diff line number Diff line change @@ -121,6 +121,15 @@ s! {
121
121
__unused4: :: c_ulong,
122
122
__unused5: :: c_ulong
123
123
}
124
+
125
+ // FIXME this is actually a union
126
+ pub struct sem_t {
127
+ #[ cfg( target_pointer_width = "32" ) ]
128
+ __size: [ :: c_char; 16 ] ,
129
+ #[ cfg( target_pointer_width = "64" ) ]
130
+ __size: [ :: c_char; 32 ] ,
131
+ __align: [ :: c_long; 0 ] ,
132
+ }
124
133
}
125
134
126
135
pub const RLIMIT_RSS : :: c_int = 5 ;
You can’t perform that action at this time.
0 commit comments