1
1
pub type rlim_t = :: uintptr_t ;
2
2
pub type sa_family_t = u8 ;
3
3
pub type pthread_key_t = :: c_int ;
4
- pub type nfds_t = :: c_long ;
4
+ pub type nfds_t = :: c_ulong ;
5
5
pub type tcflag_t = :: c_uint ;
6
- pub type speed_t = :: c_uint ;
6
+ pub type speed_t = :: c_uchar ;
7
7
pub type c_char = i8 ;
8
8
pub type clock_t = i32 ;
9
9
pub type clockid_t = i32 ;
@@ -19,6 +19,7 @@ pub type nlink_t = i32;
19
19
pub type useconds_t = u32 ;
20
20
pub type socklen_t = u32 ;
21
21
pub type pthread_t = :: uintptr_t ;
22
+ pub type pthread_condattr_t = :: uintptr_t ;
22
23
pub type pthread_mutexattr_t = :: uintptr_t ;
23
24
pub type pthread_rwlockattr_t = :: uintptr_t ;
24
25
pub type sigset_t = u64 ;
@@ -28,6 +29,7 @@ pub type pthread_attr_t = *mut ::c_void;
28
29
pub type nl_item = :: c_int ;
29
30
pub type id_t = i32 ;
30
31
pub type idtype_t = :: c_uint ;
32
+ pub type fd_mask = u32 ;
31
33
32
34
#[ cfg_attr( feature = "extra_traits" , derive( Debug ) ) ]
33
35
pub enum timezone { }
69
71
pub struct sockaddr {
70
72
pub sa_len: u8 ,
71
73
pub sa_family: sa_family_t,
72
- pub sa_data: [ :: c_char ; 30 ] ,
74
+ pub sa_data: [ u8 ; 30 ] ,
73
75
}
74
76
75
77
pub struct sockaddr_in {
76
78
pub sin_len: u8 ,
77
79
pub sin_family: sa_family_t,
78
80
pub sin_port: :: in_port_t,
79
81
pub sin_addr: :: in_addr,
80
- pub sin_zero: [ u8 ; 24 ] ,
82
+ pub sin_zero: [ i8 ; 24 ] ,
81
83
}
82
84
83
85
pub struct sockaddr_in6 {
84
86
pub sin6_len: u8 ,
85
- pub sin6_family: sa_family_t ,
86
- pub sin6_port: :: in_port_t ,
87
+ pub sin6_family: u8 ,
88
+ pub sin6_port: u16 ,
87
89
pub sin6_flowinfo: u32 ,
88
90
pub sin6_addr: :: in6_addr,
89
91
pub sin6_scope_id: u32 ,
101
103
}
102
104
103
105
pub struct fd_set {
104
- fds_bits: [ c_ulong; FD_SETSIZE / ULONG_SIZE ] ,
106
+ // size for 1024 bits, and a fd_mask with size u32
107
+ fds_bits: [ fd_mask; 32 ] ,
105
108
}
106
109
107
110
pub struct tm {
114
117
pub tm_wday: :: c_int,
115
118
pub tm_yday: :: c_int,
116
119
pub tm_isdst: :: c_int,
117
- pub tm_gmtoff: :: c_long ,
118
- pub tm_zone: * const :: c_char,
120
+ pub tm_gmtoff: :: c_int ,
121
+ pub tm_zone: * mut :: c_char,
119
122
}
120
123
121
124
pub struct utsname {
@@ -155,16 +158,16 @@ s! {
155
158
156
159
pub struct msghdr {
157
160
pub msg_name: * mut :: c_void,
158
- pub msg_namelen: :: socklen_t,
161
+ pub msg_namelen: socklen_t,
159
162
pub msg_iov: * mut :: iovec,
160
163
pub msg_iovlen: :: c_int,
161
164
pub msg_control: * mut :: c_void,
162
- pub msg_controllen: :: socklen_t,
165
+ pub msg_controllen: socklen_t,
163
166
pub msg_flags: :: c_int,
164
167
}
165
168
166
169
pub struct cmsghdr {
167
- pub cmsg_len: :: size_t ,
170
+ pub cmsg_len: :: socklen_t ,
168
171
pub cmsg_level: :: c_int,
169
172
pub cmsg_type: :: c_int,
170
173
}
@@ -301,22 +304,16 @@ s! {
301
304
}
302
305
303
306
pub struct sigaction {
304
- pub sa_sigaction: :: sighandler_t,
307
+ pub sa_sigaction: :: sighandler_t, //actually a union with sa_handler
305
308
pub sa_mask: :: sigset_t,
306
309
pub sa_flags: :: c_int,
307
310
sa_userdata: * mut :: c_void,
308
311
}
309
312
310
313
pub struct sem_t {
311
- pub se_type: i32 ,
312
- pub se_named_id: i32 , // this is actually a union
313
- pub se_unnamed: i32 ,
314
- pub se_padding: [ i32 ; 4 ] ,
315
- }
316
-
317
- pub struct pthread_condattr_t {
318
- pub process_shared: bool ,
319
- pub clock_id: i32 ,
314
+ pub type_: i32 ,
315
+ pub named_sem_id: i32 , // actually a union with unnamed_sem (i32)
316
+ pub padding: [ i32 ; 2 ] ,
320
317
}
321
318
}
322
319
@@ -491,17 +488,6 @@ cfg_if! {
491
488
}
492
489
}
493
490
494
- // intentionally not public, only used for fd_set
495
- cfg_if ! {
496
- if #[ cfg( target_pointer_width = "32" ) ] {
497
- const ULONG_SIZE : usize = 32 ;
498
- } else if #[ cfg( target_pointer_width = "64" ) ] {
499
- const ULONG_SIZE : usize = 64 ;
500
- } else {
501
- // Unknown target_pointer_width
502
- }
503
- }
504
-
505
491
pub const EXIT_FAILURE : :: c_int = 1 ;
506
492
pub const EXIT_SUCCESS : :: c_int = 0 ;
507
493
pub const RAND_MAX : :: c_int = 2147483647 ;
@@ -559,7 +545,7 @@ pub const RLIMIT_STACK: ::c_int = 5;
559
545
pub const RLIMIT_AS : :: c_int = 6 ;
560
546
// Haiku specific
561
547
pub const RLIMIT_NOVMON : :: c_int = 7 ;
562
- pub const RLIMIT_NLIMITS : :: c_int = 8 ;
548
+ pub const RLIM_NLIMITS : :: c_int = 8 ;
563
549
564
550
pub const RUSAGE_SELF : :: c_int = 0 ;
565
551
@@ -596,18 +582,20 @@ pub const S_IFREG: ::mode_t = 32768;
596
582
pub const S_IFLNK : :: mode_t = 40960 ;
597
583
pub const S_IFSOCK : :: mode_t = 49152 ;
598
584
pub const S_IFMT : :: mode_t = 61440 ;
599
- pub const S_IRWXU : :: mode_t = 448 ;
600
- pub const S_IXUSR : :: mode_t = 64 ;
601
- pub const S_IWUSR : :: mode_t = 128 ;
602
- pub const S_IRUSR : :: mode_t = 256 ;
603
- pub const S_IRWXG : :: mode_t = 70 ;
604
- pub const S_IXGRP : :: mode_t = 10 ;
605
- pub const S_IWGRP : :: mode_t = 20 ;
606
- pub const S_IRGRP : :: mode_t = 40 ;
607
- pub const S_IRWXO : :: mode_t = 7 ;
608
- pub const S_IXOTH : :: mode_t = 1 ;
609
- pub const S_IWOTH : :: mode_t = 2 ;
610
- pub const S_IROTH : :: mode_t = 4 ;
585
+
586
+ pub const S_IRWXU : :: mode_t = 0o00700 ;
587
+ pub const S_IRUSR : :: mode_t = 0o00400 ;
588
+ pub const S_IWUSR : :: mode_t = 0o00200 ;
589
+ pub const S_IXUSR : :: mode_t = 0o00100 ;
590
+ pub const S_IRWXG : :: mode_t = 0o00070 ;
591
+ pub const S_IRGRP : :: mode_t = 0o00040 ;
592
+ pub const S_IWGRP : :: mode_t = 0o00020 ;
593
+ pub const S_IXGRP : :: mode_t = 0o00010 ;
594
+ pub const S_IRWXO : :: mode_t = 0o00007 ;
595
+ pub const S_IROTH : :: mode_t = 0o00004 ;
596
+ pub const S_IWOTH : :: mode_t = 0o00002 ;
597
+ pub const S_IXOTH : :: mode_t = 0o00001 ;
598
+
611
599
pub const F_OK : :: c_int = 0 ;
612
600
pub const R_OK : :: c_int = 4 ;
613
601
pub const W_OK : :: c_int = 2 ;
@@ -707,8 +695,8 @@ pub const ENOTTY: ::c_int = -2147454966;
707
695
pub const ENXIO : :: c_int = -2147454965 ;
708
696
pub const ESPIPE : :: c_int = -2147454964 ;
709
697
pub const ESRCH : :: c_int = -2147454963 ;
710
- pub const EFPOS : :: c_int = -2147457962 ;
711
- pub const ESIGPARM : :: c_int = -2147457961 ;
698
+ pub const EFPOS : :: c_int = -2147454962 ;
699
+ pub const ESIGPARM : :: c_int = -2147454961 ;
712
700
pub const EDOM : :: c_int = -2147454960 ;
713
701
pub const ERANGE : :: c_int = -2147454959 ;
714
702
pub const EPROTOTYPE : :: c_int = -2147454958 ;
@@ -756,7 +744,7 @@ pub const ETXTBSY: ::c_int = -2147454917;
756
744
pub const ENOATTR : :: c_int = -2147454916 ;
757
745
758
746
// INT_MIN
759
- pub const ENOMEM : :: c_int = -2147454976 ;
747
+ pub const ENOMEM : :: c_int = -2147483648 ;
760
748
761
749
// POSIX errors that can be mapped to BeOS error codes
762
750
pub const EACCES : :: c_int = -2147483646 ;
@@ -844,6 +832,9 @@ pub const TCP_MAXSEG: ::c_int = 0x02;
844
832
pub const TCP_NOPUSH : :: c_int = 0x04 ;
845
833
pub const TCP_NOOPT : :: c_int = 0x08 ;
846
834
835
+ pub const IF_NAMESIZE : :: size_t = 32 ;
836
+ pub const IFNAMSIZ : :: size_t = IF_NAMESIZE ;
837
+
847
838
pub const IPV6_MULTICAST_IF : :: c_int = 24 ;
848
839
pub const IPV6_MULTICAST_HOPS : :: c_int = 25 ;
849
840
pub const IPV6_MULTICAST_LOOP : :: c_int = 26 ;
@@ -854,7 +845,7 @@ pub const IPV6_V6ONLY: ::c_int = 30;
854
845
pub const IPV6_PKTINFO : :: c_int = 31 ;
855
846
pub const IPV6_RECVPKTINFO : :: c_int = 32 ;
856
847
pub const IPV6_HOPLIMIT : :: c_int = 33 ;
857
- pub const IPV6_REVCHOPLIMIT : :: c_int = 34 ;
848
+ pub const IPV6_RECVHOPLIMIT : :: c_int = 34 ;
858
849
pub const IPV6_HOPOPTS : :: c_int = 35 ;
859
850
pub const IPV6_DSTOPTS : :: c_int = 36 ;
860
851
pub const IPV6_RTHDR : :: c_int = 37 ;
@@ -1239,7 +1230,60 @@ pub const PRIO_PROCESS: ::c_int = 0;
1239
1230
pub const PRIO_PGRP : :: c_int = 1 ;
1240
1231
pub const PRIO_USER : :: c_int = 2 ;
1241
1232
1233
+ pub const LOG_PID : :: c_int = 1 << 12 ;
1234
+ pub const LOG_CONS : :: c_int = 2 << 12 ;
1235
+ pub const LOG_ODELAY : :: c_int = 4 << 12 ;
1236
+ pub const LOG_NDELAY : :: c_int = 8 << 12 ;
1237
+ pub const LOG_SERIAL : :: c_int = 16 << 12 ;
1238
+ pub const LOG_PERROR : :: c_int = 32 << 12 ;
1239
+ pub const LOG_NOWAIT : :: c_int = 64 << 12 ;
1240
+
1241
+ const_fn ! {
1242
+ { const } fn CMSG_ALIGN ( len: usize ) -> usize {
1243
+ len + :: mem:: size_of:: <usize >( ) - 1 & !( :: mem:: size_of:: <usize >( ) - 1 )
1244
+ }
1245
+ }
1246
+
1242
1247
f ! {
1248
+ pub fn CMSG_FIRSTHDR ( mhdr: * const msghdr) -> * mut cmsghdr {
1249
+ if ( * mhdr) . msg_controllen as usize >= :: mem:: size_of:: <cmsghdr>( ) {
1250
+ ( * mhdr) . msg_control as * mut cmsghdr
1251
+ } else {
1252
+ 0 as * mut cmsghdr
1253
+ }
1254
+ }
1255
+
1256
+ pub fn CMSG_DATA ( cmsg: * const :: cmsghdr) -> * mut :: c_uchar {
1257
+ ( cmsg as * mut :: c_uchar)
1258
+ . offset( CMSG_ALIGN ( :: mem:: size_of:: <:: cmsghdr>( ) ) as isize )
1259
+ }
1260
+
1261
+ pub { const } fn CMSG_SPACE ( length: :: c_uint) -> :: c_uint {
1262
+ ( CMSG_ALIGN ( length as usize ) + CMSG_ALIGN ( :: mem:: size_of:: <cmsghdr>( ) ) )
1263
+ as :: c_uint
1264
+ }
1265
+
1266
+ pub fn CMSG_LEN ( length: :: c_uint) -> :: c_uint {
1267
+ CMSG_ALIGN ( :: mem:: size_of:: <cmsghdr>( ) ) as :: c_uint + length
1268
+ }
1269
+
1270
+ pub fn CMSG_NXTHDR ( mhdr: * const msghdr,
1271
+ cmsg: * const cmsghdr) -> * mut cmsghdr {
1272
+ if cmsg. is_null( ) {
1273
+ return :: CMSG_FIRSTHDR ( mhdr) ;
1274
+ } ;
1275
+ let next = cmsg as usize + CMSG_ALIGN ( ( * cmsg) . cmsg_len as usize )
1276
+ + CMSG_ALIGN ( :: mem:: size_of:: <:: cmsghdr>( ) ) ;
1277
+ let max = ( * mhdr) . msg_control as usize
1278
+ + ( * mhdr) . msg_controllen as usize ;
1279
+ if next > max {
1280
+ 0 as * mut :: cmsghdr
1281
+ } else {
1282
+ ( cmsg as usize + CMSG_ALIGN ( ( * cmsg) . cmsg_len as usize ) )
1283
+ as * mut :: cmsghdr
1284
+ }
1285
+ }
1286
+
1243
1287
pub fn FD_CLR ( fd: :: c_int, set: * mut fd_set) -> ( ) {
1244
1288
let fd = fd as usize ;
1245
1289
let size = :: mem:: size_of_val( & ( * set) . fds_bits[ 0 ] ) * 8 ;
@@ -1368,10 +1412,10 @@ extern "C" {
1368
1412
clock_id : :: clockid_t ,
1369
1413
) -> :: c_int ;
1370
1414
pub fn memalign ( align : :: size_t , size : :: size_t ) -> * mut :: c_void ;
1371
- pub fn setgroups ( ngroups : :: size_t , ptr : * const :: gid_t ) -> :: c_int ;
1372
- pub fn ioctl ( fd : :: c_int , request : :: c_int , ...) -> :: c_int ;
1415
+ pub fn setgroups ( ngroups : :: c_int , ptr : * const :: gid_t ) -> :: c_int ;
1416
+ pub fn ioctl ( fd : :: c_int , request : :: c_ulong , ...) -> :: c_int ;
1373
1417
pub fn mprotect (
1374
- addr : * const :: c_void ,
1418
+ addr : * mut :: c_void ,
1375
1419
len : :: size_t ,
1376
1420
prot : :: c_int ,
1377
1421
) -> :: c_int ;
@@ -1380,9 +1424,9 @@ extern "C" {
1380
1424
sa : * const :: sockaddr ,
1381
1425
salen : :: socklen_t ,
1382
1426
host : * mut :: c_char ,
1383
- hostlen : :: size_t ,
1427
+ hostlen : :: socklen_t ,
1384
1428
serv : * mut :: c_char ,
1385
- sevlen : :: size_t ,
1429
+ sevlen : :: socklen_t ,
1386
1430
flags : :: c_int ,
1387
1431
) -> :: c_int ;
1388
1432
pub fn pthread_mutex_timedlock (
@@ -1455,12 +1499,12 @@ extern "C" {
1455
1499
pub fn writev (
1456
1500
fd : :: c_int ,
1457
1501
iov : * const :: iovec ,
1458
- iovcnt : :: c_int ,
1502
+ count : :: size_t ,
1459
1503
) -> :: ssize_t ;
1460
1504
pub fn readv (
1461
1505
fd : :: c_int ,
1462
1506
iov : * const :: iovec ,
1463
- iovcnt : :: c_int ,
1507
+ count : :: size_t ,
1464
1508
) -> :: ssize_t ;
1465
1509
1466
1510
pub fn sendmsg (
0 commit comments