• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 pub type blkcnt_t = i32;
2 pub type blksize_t = i32;
3 pub type clock_t = i32;
4 pub type clockid_t = ::c_ulong;
5 pub type dev_t = u32;
6 pub type fsblkcnt_t = u64;
7 pub type fsfilcnt_t = u32;
8 pub type id_t = u32;
9 pub type ino_t = u32;
10 pub type key_t = ::c_int;
11 pub type loff_t = ::c_longlong;
12 pub type mode_t = ::c_uint;
13 pub type nfds_t = u32;
14 pub type nlink_t = ::c_ushort;
15 pub type off_t = i64;
16 pub type pthread_t = ::c_ulong;
17 pub type pthread_key_t = ::c_uint;
18 pub type rlim_t = u32;
19 pub type sa_family_t = u8;
20 pub type socklen_t = u32;
21 pub type speed_t = u32;
22 pub type suseconds_t = i32;
23 pub type tcflag_t = ::c_uint;
24 pub type time_t = i32;
25 pub type useconds_t = u32;
26 
27 s! {
28     pub struct addrinfo {
29         pub ai_flags: ::c_int,
30         pub ai_family: ::c_int,
31         pub ai_socktype: ::c_int,
32         pub ai_protocol: ::c_int,
33         pub ai_addrlen: socklen_t,
34         pub ai_canonname: *mut ::c_char,
35         pub ai_addr: *mut sockaddr,
36         pub ai_next: *mut addrinfo,
37     }
38 
39     pub struct ip_mreq {
40         pub imr_multiaddr: in_addr,
41         pub imr_interface: in_addr,
42     }
43 
44     pub struct linger {
45         pub l_onoff: ::c_int,
46         pub l_linger: ::c_int,
47     }
48 
49     pub struct in_addr {
50             pub s_addr: ::in_addr_t,
51     }
52 
53     pub struct hostent {
54             pub h_name: *mut ::c_char,
55             pub h_aliases: *mut *mut ::c_char,
56             pub h_addrtype: ::c_int,
57             pub h_length: ::c_int,
58             pub h_addr_list: *mut *mut ::c_char,
59             pub h_addr: *mut ::c_char,
60     }
61 
62     pub struct pollfd {
63         pub fd: ::c_int,
64         pub events: ::c_int,
65         pub revents: ::c_int,
66     }
67 
68     pub struct lconv {
69         pub decimal_point: *mut ::c_char,
70         pub thousands_sep: *mut ::c_char,
71         pub grouping: *mut ::c_char,
72         pub int_curr_symbol: *mut ::c_char,
73         pub currency_symbol: *mut ::c_char,
74         pub mon_decimal_point: *mut ::c_char,
75         pub mon_thousands_sep: *mut ::c_char,
76         pub mon_grouping: *mut ::c_char,
77         pub positive_sign: *mut ::c_char,
78         pub negative_sign: *mut ::c_char,
79         pub int_frac_digits: ::c_char,
80         pub frac_digits: ::c_char,
81         pub p_cs_precedes: ::c_char,
82         pub p_sep_by_space: ::c_char,
83         pub n_cs_precedes: ::c_char,
84         pub n_sep_by_space: ::c_char,
85         pub p_sign_posn: ::c_char,
86         pub n_sign_posn: ::c_char,
87         pub int_n_cs_precedes: ::c_char,
88         pub int_n_sep_by_space: ::c_char,
89         pub int_n_sign_posn: ::c_char,
90         pub int_p_cs_precedes: ::c_char,
91         pub int_p_sep_by_space: ::c_char,
92         pub int_p_sign_posn: ::c_char,
93     }
94 
95     pub struct tm {
96         pub tm_sec: ::c_int,
97         pub tm_min: ::c_int,
98         pub tm_hour: ::c_int,
99         pub tm_mday: ::c_int,
100         pub tm_mon: ::c_int,
101         pub tm_year: ::c_int,
102         pub tm_wday: ::c_int,
103         pub tm_yday: ::c_int,
104         pub tm_isdst: ::c_int,
105     }
106 
107     pub struct stat {
108         pub st_dev: ::dev_t,
109         pub st_ino: ::ino_t,
110         pub st_mode: ::mode_t,
111         pub st_nlink: ::nlink_t,
112         pub st_uid: ::uid_t,
113         pub st_gid: ::gid_t,
114         pub st_rdev: dev_t,
115         pub st_size: off_t,
116         pub st_atime: time_t,
117         pub st_spare1: ::c_long,
118         pub st_mtime: time_t,
119         pub st_spare2: ::c_long,
120         pub st_ctime: time_t,
121         pub st_spare3: ::c_long,
122         pub st_blksize: blksize_t,
123         pub st_blocks: blkcnt_t,
124         pub st_spare4: [::c_long; 2usize],
125     }
126 
127     pub struct statvfs {
128         pub f_bsize: ::c_ulong,
129         pub f_frsize: ::c_ulong,
130         pub f_blocks: fsblkcnt_t,
131         pub f_bfree: fsblkcnt_t,
132         pub f_bavail: fsblkcnt_t,
133         pub f_files: fsfilcnt_t,
134         pub f_ffree: fsfilcnt_t,
135         pub f_favail: fsfilcnt_t,
136         pub f_fsid: ::c_ulong,
137         pub f_flag: ::c_ulong,
138         pub f_namemax: ::c_ulong,
139     }
140 
141     pub struct sigset_t {
142         __val: [::c_ulong; 16],
143     }
144 
145     pub struct sigaction {
146         pub sa_handler: extern fn(arg1: ::c_int),
147         pub sa_mask: sigset_t,
148         pub sa_flags: ::c_int,
149     }
150 
151     pub struct dirent {
152         pub d_ino: ino_t,
153         pub d_type: ::c_uchar,
154         pub d_name: [::c_char; 256usize],
155     }
156 
157     pub struct stack_t {
158         pub ss_sp: *mut ::c_void,
159         pub ss_flags: ::c_int,
160         pub ss_size: usize,
161     }
162 
163     pub struct fd_set { // Unverified
164         fds_bits: [::c_ulong; FD_SETSIZE / ULONG_SIZE],
165     }
166 
167     pub struct passwd { // Unverified
168         pub pw_name: *mut ::c_char,
169         pub pw_passwd: *mut ::c_char,
170         pub pw_uid: ::uid_t,
171         pub pw_gid: ::gid_t,
172         pub pw_gecos: *mut ::c_char,
173         pub pw_dir: *mut ::c_char,
174         pub pw_shell: *mut ::c_char,
175     }
176 
177     pub struct termios { // Unverified
178         pub c_iflag: ::tcflag_t,
179         pub c_oflag: ::tcflag_t,
180         pub c_cflag: ::tcflag_t,
181         pub c_lflag: ::tcflag_t,
182         pub c_line: ::cc_t,
183         pub c_cc: [::cc_t; ::NCCS],
184     }
185 
186     pub struct sem_t { // Unverified
187         __size: [::c_char; 16],
188     }
189 
190     pub struct Dl_info { // Unverified
191         pub dli_fname: *const ::c_char,
192         pub dli_fbase: *mut ::c_void,
193         pub dli_sname: *const ::c_char,
194         pub dli_saddr: *mut ::c_void,
195     }
196 
197     pub struct utsname { // Unverified
198         pub sysname: [::c_char; 65],
199         pub nodename: [::c_char; 65],
200         pub release: [::c_char; 65],
201         pub version: [::c_char; 65],
202         pub machine: [::c_char; 65],
203         pub domainname: [::c_char; 65]
204     }
205 
206     pub struct cpu_set_t { // Unverified
207         bits: [u32; 32],
208     }
209 
210     pub struct pthread_attr_t { // Unverified
211         __size: [u64; 7]
212     }
213 
214     pub struct pthread_rwlockattr_t { // Unverified
215         __lockkind: ::c_int,
216         __pshared: ::c_int,
217     }
218 }
219 
220 // unverified constants
221 align_const! {
222     pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
223         size: [0; __SIZEOF_PTHREAD_MUTEX_T],
224     };
225     pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
226         size: [0; __SIZEOF_PTHREAD_COND_T],
227     };
228     pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
229         size: [0; __SIZEOF_PTHREAD_RWLOCK_T],
230     };
231 }
232 pub const NCCS: usize = 32;
233 pub const __SIZEOF_PTHREAD_ATTR_T: usize = 56;
234 pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40;
235 pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
236 pub const __SIZEOF_PTHREAD_COND_T: usize = 48;
237 pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
238 pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;
239 pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8;
240 pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32;
241 pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4;
242 pub const __PTHREAD_MUTEX_HAVE_PREV: usize = 1;
243 pub const __PTHREAD_RWLOCK_INT_FLAGS_SHARED: usize = 1;
244 pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0;
245 pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1;
246 pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2;
247 pub const FD_SETSIZE: usize = 1024;
248 // intentionally not public, only used for fd_set
249 const ULONG_SIZE: usize = 32;
250 
251 // Other constants
252 pub const EPERM: ::c_int = 1;
253 pub const ENOENT: ::c_int = 2;
254 pub const ESRCH: ::c_int = 3;
255 pub const EINTR: ::c_int = 4;
256 pub const EIO: ::c_int = 5;
257 pub const ENXIO: ::c_int = 6;
258 pub const E2BIG: ::c_int = 7;
259 pub const ENOEXEC: ::c_int = 8;
260 pub const EBADF: ::c_int = 9;
261 pub const ECHILD: ::c_int = 10;
262 pub const EAGAIN: ::c_int = 11;
263 pub const ENOMEM: ::c_int = 12;
264 pub const EACCES: ::c_int = 13;
265 pub const EFAULT: ::c_int = 14;
266 pub const EBUSY: ::c_int = 16;
267 pub const EEXIST: ::c_int = 17;
268 pub const EXDEV: ::c_int = 18;
269 pub const ENODEV: ::c_int = 19;
270 pub const ENOTDIR: ::c_int = 20;
271 pub const EISDIR: ::c_int = 21;
272 pub const EINVAL: ::c_int = 22;
273 pub const ENFILE: ::c_int = 23;
274 pub const EMFILE: ::c_int = 24;
275 pub const ENOTTY: ::c_int = 25;
276 pub const ETXTBSY: ::c_int = 26;
277 pub const EFBIG: ::c_int = 27;
278 pub const ENOSPC: ::c_int = 28;
279 pub const ESPIPE: ::c_int = 29;
280 pub const EROFS: ::c_int = 30;
281 pub const EMLINK: ::c_int = 31;
282 pub const EPIPE: ::c_int = 32;
283 pub const EDOM: ::c_int = 33;
284 pub const ERANGE: ::c_int = 34;
285 pub const ENOMSG: ::c_int = 35;
286 pub const EIDRM: ::c_int = 36;
287 pub const EDEADLK: ::c_int = 45;
288 pub const ENOLCK: ::c_int = 46;
289 pub const ENOSTR: ::c_int = 60;
290 pub const ENODATA: ::c_int = 61;
291 pub const ETIME: ::c_int = 62;
292 pub const ENOSR: ::c_int = 63;
293 pub const ENOLINK: ::c_int = 67;
294 pub const EPROTO: ::c_int = 71;
295 pub const EMULTIHOP: ::c_int = 74;
296 pub const EBADMSG: ::c_int = 77;
297 pub const EFTYPE: ::c_int = 79;
298 pub const ENOSYS: ::c_int = 88;
299 pub const ENOTEMPTY: ::c_int = 90;
300 pub const ENAMETOOLONG: ::c_int = 91;
301 pub const ELOOP: ::c_int = 92;
302 pub const EOPNOTSUPP: ::c_int = 95;
303 pub const EPFNOSUPPORT: ::c_int = 96;
304 pub const ECONNRESET: ::c_int = 104;
305 pub const ENOBUFS: ::c_int = 105;
306 pub const EAFNOSUPPORT: ::c_int = 106;
307 pub const EPROTOTYPE: ::c_int = 107;
308 pub const ENOTSOCK: ::c_int = 108;
309 pub const ENOPROTOOPT: ::c_int = 109;
310 pub const ECONNREFUSED: ::c_int = 111;
311 pub const EADDRINUSE: ::c_int = 112;
312 pub const ECONNABORTED: ::c_int = 113;
313 pub const ENETUNREACH: ::c_int = 114;
314 pub const ENETDOWN: ::c_int = 115;
315 pub const ETIMEDOUT: ::c_int = 116;
316 pub const EHOSTDOWN: ::c_int = 117;
317 pub const EHOSTUNREACH: ::c_int = 118;
318 pub const EINPROGRESS: ::c_int = 119;
319 pub const EALREADY: ::c_int = 120;
320 pub const EDESTADDRREQ: ::c_int = 121;
321 pub const EMSGSIZE: ::c_int = 122;
322 pub const EPROTONOSUPPORT: ::c_int = 123;
323 pub const EADDRNOTAVAIL: ::c_int = 125;
324 pub const ENETRESET: ::c_int = 126;
325 pub const EISCONN: ::c_int = 127;
326 pub const ENOTCONN: ::c_int = 128;
327 pub const ETOOMANYREFS: ::c_int = 129;
328 pub const EDQUOT: ::c_int = 132;
329 pub const ESTALE: ::c_int = 133;
330 pub const ENOTSUP: ::c_int = 134;
331 pub const EILSEQ: ::c_int = 138;
332 pub const EOVERFLOW: ::c_int = 139;
333 pub const ECANCELED: ::c_int = 140;
334 pub const ENOTRECOVERABLE: ::c_int = 141;
335 pub const EOWNERDEAD: ::c_int = 142;
336 pub const EWOULDBLOCK: ::c_int = 11;
337 
338 pub const F_DUPFD: ::c_int = 0;
339 pub const F_GETFD: ::c_int = 1;
340 pub const F_SETFD: ::c_int = 2;
341 pub const F_GETFL: ::c_int = 3;
342 pub const F_SETFL: ::c_int = 4;
343 pub const F_GETOWN: ::c_int = 5;
344 pub const F_SETOWN: ::c_int = 6;
345 pub const F_GETLK: ::c_int = 7;
346 pub const F_SETLK: ::c_int = 8;
347 pub const F_SETLKW: ::c_int = 9;
348 pub const F_RGETLK: ::c_int = 10;
349 pub const F_RSETLK: ::c_int = 11;
350 pub const F_CNVT: ::c_int = 12;
351 pub const F_RSETLKW: ::c_int = 13;
352 pub const F_DUPFD_CLOEXEC: ::c_int = 14;
353 
354 pub const O_RDONLY: ::c_int = 0;
355 pub const O_WRONLY: ::c_int = 1;
356 pub const O_RDWR: ::c_int = 2;
357 pub const O_APPEND: ::c_int = 8;
358 pub const O_CREAT: ::c_int = 512;
359 pub const O_TRUNC: ::c_int = 1024;
360 pub const O_EXCL: ::c_int = 2048;
361 pub const O_SYNC: ::c_int = 8192;
362 pub const O_NONBLOCK: ::c_int = 16384;
363 
364 pub const O_ACCMODE: ::c_int = 3;
365 pub const O_CLOEXEC: ::c_int = 0x80000;
366 
367 pub const POLLIN: ::c_short = 0x1;
368 pub const POLLPRI: ::c_short = 0x2;
369 pub const POLLERR: ::c_short = 0x8;
370 pub const POLLNVAL: ::c_short = 0x20;
371 
372 pub const RTLD_LAZY: ::c_int = 0x1;
373 
374 pub const STDIN_FILENO: ::c_int = 0;
375 pub const STDOUT_FILENO: ::c_int = 1;
376 pub const STDERR_FILENO: ::c_int = 2;
377 
378 pub const SEEK_SET: ::c_int = 0;
379 pub const SEEK_CUR: ::c_int = 1;
380 pub const SEEK_END: ::c_int = 2;
381 
382 pub const FIONBIO: ::c_ulong = 1;
383 pub const FIOCLEX: ::c_ulong = 0x20006601;
384 pub const FIONCLEX: ::c_ulong = 0x20006602;
385 
386 pub const S_BLKSIZE: ::mode_t = 1024;
387 pub const S_IREAD: ::mode_t = 256;
388 pub const S_IWRITE: ::mode_t = 128;
389 pub const S_IEXEC: ::mode_t = 64;
390 pub const S_ENFMT: ::mode_t = 1024;
391 pub const S_IFMT: ::mode_t = 61440;
392 pub const S_IFDIR: ::mode_t = 16384;
393 pub const S_IFCHR: ::mode_t = 8192;
394 pub const S_IFBLK: ::mode_t = 24576;
395 pub const S_IFREG: ::mode_t = 32768;
396 pub const S_IFLNK: ::mode_t = 40960;
397 pub const S_IFSOCK: ::mode_t = 49152;
398 pub const S_IFIFO: ::mode_t = 4096;
399 pub const S_IRUSR: ::mode_t = 256;
400 pub const S_IWUSR: ::mode_t = 128;
401 pub const S_IXUSR: ::mode_t = 64;
402 pub const S_IRGRP: ::mode_t = 32;
403 pub const S_IWGRP: ::mode_t = 16;
404 pub const S_IXGRP: ::mode_t = 8;
405 pub const S_IROTH: ::mode_t = 4;
406 pub const S_IWOTH: ::mode_t = 2;
407 pub const S_IXOTH: ::mode_t = 1;
408 
409 pub const SOL_SOCKET: ::c_int = 65535;
410 pub const SOL_TCP: ::c_int = 6;
411 
412 pub const PF_UNSPEC: ::c_int = 0;
413 pub const PF_INET: ::c_int = 2;
414 pub const PF_INET6: ::c_int = 23;
415 
416 pub const AF_UNSPEC: ::c_int = 0;
417 pub const AF_INET: ::c_int = 2;
418 pub const AF_INET6: ::c_int = 23;
419 
420 pub const SOCK_STREAM: ::c_int = 1;
421 pub const SOCK_DGRAM: ::c_int = 2;
422 
423 pub const MSG_OOB: ::c_int = 1;
424 pub const MSG_PEEK: ::c_int = 2;
425 pub const MSG_DONTWAIT: ::c_int = 4;
426 pub const MSG_DONTROUTE: ::c_int = 0;
427 pub const MSG_WAITALL: ::c_int = 0;
428 pub const MSG_MORE: ::c_int = 0;
429 pub const MSG_NOSIGNAL: ::c_int = 0;
430 
431 pub const SHUT_RD: ::c_int = 0;
432 pub const SHUT_WR: ::c_int = 1;
433 pub const SHUT_RDWR: ::c_int = 2;
434 
435 pub const SO_BINTIME: ::c_int = 0x2000;
436 pub const SO_NO_OFFLOAD: ::c_int = 0x4000;
437 pub const SO_NO_DDP: ::c_int = 0x8000;
438 pub const SO_REUSEPORT_LB: ::c_int = 0x10000;
439 pub const SO_LABEL: ::c_int = 0x1009;
440 pub const SO_PEERLABEL: ::c_int = 0x1010;
441 pub const SO_LISTENQLIMIT: ::c_int = 0x1011;
442 pub const SO_LISTENQLEN: ::c_int = 0x1012;
443 pub const SO_LISTENINCQLEN: ::c_int = 0x1013;
444 pub const SO_SETFIB: ::c_int = 0x1014;
445 pub const SO_USER_COOKIE: ::c_int = 0x1015;
446 pub const SO_PROTOCOL: ::c_int = 0x1016;
447 pub const SO_PROTOTYPE: ::c_int = SO_PROTOCOL;
448 pub const SO_VENDOR: ::c_int = 0x80000000;
449 pub const SO_DEBUG: ::c_int = 0x01;
450 pub const SO_ACCEPTCONN: ::c_int = 0x0002;
451 pub const SO_REUSEADDR: ::c_int = 0x0004;
452 pub const SO_KEEPALIVE: ::c_int = 0x0008;
453 pub const SO_DONTROUTE: ::c_int = 0x0010;
454 pub const SO_BROADCAST: ::c_int = 0x0020;
455 pub const SO_USELOOPBACK: ::c_int = 0x0040;
456 pub const SO_LINGER: ::c_int = 0x0080;
457 pub const SO_OOBINLINE: ::c_int = 0x0100;
458 pub const SO_REUSEPORT: ::c_int = 0x0200;
459 pub const SO_TIMESTAMP: ::c_int = 0x0400;
460 pub const SO_NOSIGPIPE: ::c_int = 0x0800;
461 pub const SO_ACCEPTFILTER: ::c_int = 0x1000;
462 pub const SO_SNDBUF: ::c_int = 0x1001;
463 pub const SO_RCVBUF: ::c_int = 0x1002;
464 pub const SO_SNDLOWAT: ::c_int = 0x1003;
465 pub const SO_RCVLOWAT: ::c_int = 0x1004;
466 pub const SO_SNDTIMEO: ::c_int = 0x1005;
467 pub const SO_RCVTIMEO: ::c_int = 0x1006;
468 pub const SO_ERROR: ::c_int = 0x1007;
469 pub const SO_TYPE: ::c_int = 0x1008;
470 
471 pub const SOCK_CLOEXEC: ::c_int = O_CLOEXEC;
472 
473 pub const INET_ADDRSTRLEN: ::c_int = 16;
474 
475 // https://github.
476 // com/bminor/newlib/blob/master/newlib/libc/sys/linux/include/net/if.h#L121
477 pub const IFF_UP: ::c_int = 0x1; // interface is up
478 pub const IFF_BROADCAST: ::c_int = 0x2; // broadcast address valid
479 pub const IFF_DEBUG: ::c_int = 0x4; // turn on debugging
480 pub const IFF_LOOPBACK: ::c_int = 0x8; // is a loopback net
481 pub const IFF_POINTOPOINT: ::c_int = 0x10; // interface is point-to-point link
482 pub const IFF_NOTRAILERS: ::c_int = 0x20; // avoid use of trailers
483 pub const IFF_RUNNING: ::c_int = 0x40; // resources allocated
484 pub const IFF_NOARP: ::c_int = 0x80; // no address resolution protocol
485 pub const IFF_PROMISC: ::c_int = 0x100; // receive all packets
486 pub const IFF_ALLMULTI: ::c_int = 0x200; // receive all multicast packets
487 pub const IFF_OACTIVE: ::c_int = 0x400; // transmission in progress
488 pub const IFF_SIMPLEX: ::c_int = 0x800; // can't hear own transmissions
489 pub const IFF_LINK0: ::c_int = 0x1000; // per link layer defined bit
490 pub const IFF_LINK1: ::c_int = 0x2000; // per link layer defined bit
491 pub const IFF_LINK2: ::c_int = 0x4000; // per link layer defined bit
492 pub const IFF_ALTPHYS: ::c_int = IFF_LINK2; // use alternate physical connection
493 pub const IFF_MULTICAST: ::c_int = 0x8000; // supports multicast
494 
495 pub const TCP_NODELAY: ::c_int = 8193;
496 pub const TCP_MAXSEG: ::c_int = 8194;
497 pub const TCP_NOPUSH: ::c_int = 4;
498 pub const TCP_NOOPT: ::c_int = 8;
499 pub const TCP_KEEPIDLE: ::c_int = 256;
500 pub const TCP_KEEPINTVL: ::c_int = 512;
501 pub const TCP_KEEPCNT: ::c_int = 1024;
502 
503 pub const IP_TOS: ::c_int = 3;
504 pub const IP_TTL: ::c_int = 8;
505 pub const IP_MULTICAST_IF: ::c_int = 9;
506 pub const IP_MULTICAST_TTL: ::c_int = 10;
507 pub const IP_MULTICAST_LOOP: ::c_int = 11;
508 pub const IP_ADD_MEMBERSHIP: ::c_int = 11;
509 pub const IP_DROP_MEMBERSHIP: ::c_int = 12;
510 
511 pub const IPV6_UNICAST_HOPS: ::c_int = 4;
512 pub const IPV6_MULTICAST_IF: ::c_int = 9;
513 pub const IPV6_MULTICAST_HOPS: ::c_int = 10;
514 pub const IPV6_MULTICAST_LOOP: ::c_int = 11;
515 pub const IPV6_V6ONLY: ::c_int = 27;
516 pub const IPV6_JOIN_GROUP: ::c_int = 12;
517 pub const IPV6_LEAVE_GROUP: ::c_int = 13;
518 pub const IPV6_ADD_MEMBERSHIP: ::c_int = 12;
519 pub const IPV6_DROP_MEMBERSHIP: ::c_int = 13;
520 
521 pub const HOST_NOT_FOUND: ::c_int = 1;
522 pub const NO_DATA: ::c_int = 2;
523 pub const NO_ADDRESS: ::c_int = 2;
524 pub const NO_RECOVERY: ::c_int = 3;
525 pub const TRY_AGAIN: ::c_int = 4;
526 
527 pub const AI_PASSIVE: ::c_int = 1;
528 pub const AI_CANONNAME: ::c_int = 2;
529 pub const AI_NUMERICHOST: ::c_int = 4;
530 pub const AI_NUMERICSERV: ::c_int = 0;
531 pub const AI_ADDRCONFIG: ::c_int = 0;
532 
533 pub const NI_MAXHOST: ::c_int = 1025;
534 pub const NI_MAXSERV: ::c_int = 32;
535 pub const NI_NOFQDN: ::c_int = 1;
536 pub const NI_NUMERICHOST: ::c_int = 2;
537 pub const NI_NAMEREQD: ::c_int = 4;
538 pub const NI_NUMERICSERV: ::c_int = 0;
539 pub const NI_DGRAM: ::c_int = 0;
540 
541 pub const EAI_FAMILY: ::c_int = -303;
542 pub const EAI_MEMORY: ::c_int = -304;
543 pub const EAI_NONAME: ::c_int = -305;
544 pub const EAI_SOCKTYPE: ::c_int = -307;
545 
546 f! {
547     pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () {
548         let bits = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
549         let fd = fd as usize;
550         (*set).fds_bits[fd / bits] &= !(1 << (fd % bits));
551         return
552     }
553 
554     pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool {
555         let bits = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
556         let fd = fd as usize;
557         return ((*set).fds_bits[fd / bits] & (1 << (fd % bits))) != 0
558     }
559 
560     pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () {
561         let bits = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
562         let fd = fd as usize;
563         (*set).fds_bits[fd / bits] |= 1 << (fd % bits);
564         return
565     }
566 
567     pub fn FD_ZERO(set: *mut fd_set) -> () {
568         for slot in (*set).fds_bits.iter_mut() {
569             *slot = 0;
570         }
571     }
572 }
573 
574 extern "C" {
getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int575     pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int;
setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int576     pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int;
577 
578     #[cfg_attr(target_os = "linux", link_name = "__xpg_strerror_r")]
strerror_r( errnum: ::c_int, buf: *mut c_char, buflen: ::size_t, ) -> ::c_int579     pub fn strerror_r(
580         errnum: ::c_int,
581         buf: *mut c_char,
582         buflen: ::size_t,
583     ) -> ::c_int;
584 
sem_destroy(sem: *mut sem_t) -> ::c_int585     pub fn sem_destroy(sem: *mut sem_t) -> ::c_int;
sem_init( sem: *mut sem_t, pshared: ::c_int, value: ::c_uint, ) -> ::c_int586     pub fn sem_init(
587         sem: *mut sem_t,
588         pshared: ::c_int,
589         value: ::c_uint,
590     ) -> ::c_int;
591 
abs(i: ::c_int) -> ::c_int592     pub fn abs(i: ::c_int) -> ::c_int;
atof(s: *const ::c_char) -> ::c_double593     pub fn atof(s: *const ::c_char) -> ::c_double;
labs(i: ::c_long) -> ::c_long594     pub fn labs(i: ::c_long) -> ::c_long;
rand() -> ::c_int595     pub fn rand() -> ::c_int;
srand(seed: ::c_uint)596     pub fn srand(seed: ::c_uint);
597 
bind(fd: ::c_int, addr: *const sockaddr, len: socklen_t) -> ::c_int598     pub fn bind(fd: ::c_int, addr: *const sockaddr, len: socklen_t)
599         -> ::c_int;
closesocket(sockfd: ::c_int) -> ::c_int600     pub fn closesocket(sockfd: ::c_int) -> ::c_int;
ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int601     pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
recvfrom( fd: ::c_int, buf: *mut ::c_void, n: usize, flags: ::c_int, addr: *mut sockaddr, addr_len: *mut socklen_t, ) -> isize602     pub fn recvfrom(
603         fd: ::c_int,
604         buf: *mut ::c_void,
605         n: usize,
606         flags: ::c_int,
607         addr: *mut sockaddr,
608         addr_len: *mut socklen_t,
609     ) -> isize;
getnameinfo( sa: *const sockaddr, salen: socklen_t, host: *mut ::c_char, hostlen: socklen_t, serv: *mut ::c_char, servlen: socklen_t, flags: ::c_int, ) -> ::c_int610     pub fn getnameinfo(
611         sa: *const sockaddr,
612         salen: socklen_t,
613         host: *mut ::c_char,
614         hostlen: socklen_t,
615         serv: *mut ::c_char,
616         servlen: socklen_t,
617         flags: ::c_int,
618     ) -> ::c_int;
memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void619     pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void;
fexecve( fd: ::c_int, argv: *const *const ::c_char, envp: *const *const ::c_char, ) -> ::c_int620     pub fn fexecve(
621         fd: ::c_int,
622         argv: *const *const ::c_char,
623         envp: *const *const ::c_char,
624     ) -> ::c_int;
gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int625     pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int;
626     #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrgid_r")]
getgrgid_r( gid: ::gid_t, grp: *mut ::group, buf: *mut ::c_char, buflen: ::size_t, result: *mut *mut ::group, ) -> ::c_int627     pub fn getgrgid_r(
628         gid: ::gid_t,
629         grp: *mut ::group,
630         buf: *mut ::c_char,
631         buflen: ::size_t,
632         result: *mut *mut ::group,
633     ) -> ::c_int;
634     #[cfg_attr(
635         all(target_os = "macos", target_arch = "x86"),
636         link_name = "sigaltstack$UNIX2003"
637     )]
638     #[cfg_attr(target_os = "netbsd", link_name = "__sigaltstack14")]
sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> ::c_int639     pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> ::c_int;
sem_close(sem: *mut sem_t) -> ::c_int640     pub fn sem_close(sem: *mut sem_t) -> ::c_int;
getdtablesize() -> ::c_int641     pub fn getdtablesize() -> ::c_int;
642     #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrnam_r")]
getgrnam_r( name: *const ::c_char, grp: *mut ::group, buf: *mut ::c_char, buflen: ::size_t, result: *mut *mut ::group, ) -> ::c_int643     pub fn getgrnam_r(
644         name: *const ::c_char,
645         grp: *mut ::group,
646         buf: *mut ::c_char,
647         buflen: ::size_t,
648         result: *mut *mut ::group,
649     ) -> ::c_int;
650     #[cfg_attr(
651         all(target_os = "macos", target_arch = "x86"),
652         link_name = "pthread_sigmask$UNIX2003"
653     )]
pthread_sigmask( how: ::c_int, set: *const sigset_t, oldset: *mut sigset_t, ) -> ::c_int654     pub fn pthread_sigmask(
655         how: ::c_int,
656         set: *const sigset_t,
657         oldset: *mut sigset_t,
658     ) -> ::c_int;
sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t659     pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t;
getgrnam(name: *const ::c_char) -> *mut ::group660     pub fn getgrnam(name: *const ::c_char) -> *mut ::group;
pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int661     pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int;
sem_unlink(name: *const ::c_char) -> ::c_int662     pub fn sem_unlink(name: *const ::c_char) -> ::c_int;
daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int663     pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int;
664     #[cfg_attr(target_os = "netbsd", link_name = "__getpwnam_r50")]
665     #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwnam_r")]
getpwnam_r( name: *const ::c_char, pwd: *mut passwd, buf: *mut ::c_char, buflen: ::size_t, result: *mut *mut passwd, ) -> ::c_int666     pub fn getpwnam_r(
667         name: *const ::c_char,
668         pwd: *mut passwd,
669         buf: *mut ::c_char,
670         buflen: ::size_t,
671         result: *mut *mut passwd,
672     ) -> ::c_int;
673     #[cfg_attr(target_os = "netbsd", link_name = "__getpwuid_r50")]
674     #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwuid_r")]
getpwuid_r( uid: ::uid_t, pwd: *mut passwd, buf: *mut ::c_char, buflen: ::size_t, result: *mut *mut passwd, ) -> ::c_int675     pub fn getpwuid_r(
676         uid: ::uid_t,
677         pwd: *mut passwd,
678         buf: *mut ::c_char,
679         buflen: ::size_t,
680         result: *mut *mut passwd,
681     ) -> ::c_int;
682     #[cfg_attr(
683         all(target_os = "macos", target_arch = "x86"),
684         link_name = "sigwait$UNIX2003"
685     )]
686     #[cfg_attr(target_os = "solaris", link_name = "__posix_sigwait")]
sigwait(set: *const sigset_t, sig: *mut ::c_int) -> ::c_int687     pub fn sigwait(set: *const sigset_t, sig: *mut ::c_int) -> ::c_int;
pthread_atfork( prepare: ::Option<unsafe extern "C" fn()>, parent: ::Option<unsafe extern "C" fn()>, child: ::Option<unsafe extern "C" fn()>, ) -> ::c_int688     pub fn pthread_atfork(
689         prepare: ::Option<unsafe extern "C" fn()>,
690         parent: ::Option<unsafe extern "C" fn()>,
691         child: ::Option<unsafe extern "C" fn()>,
692     ) -> ::c_int;
getgrgid(gid: ::gid_t) -> *mut ::group693     pub fn getgrgid(gid: ::gid_t) -> *mut ::group;
694     #[cfg_attr(
695         all(target_os = "macos", target_arch = "x86"),
696         link_name = "popen$UNIX2003"
697     )]
popen(command: *const c_char, mode: *const c_char) -> *mut ::FILE698     pub fn popen(command: *const c_char, mode: *const c_char) -> *mut ::FILE;
uname(buf: *mut ::utsname) -> ::c_int699     pub fn uname(buf: *mut ::utsname) -> ::c_int;
700 }
701 
702 cfg_if! {
703     if #[cfg(target_arch = "arm")] {
704         mod arm;
705         pub use self::arm::*;
706     } else if #[cfg(target_arch = "aarch64")] {
707         mod aarch64;
708         pub use self::aarch64::*;
709     } else {
710         // Only tested on ARM so far. Other platforms might have different
711         // definitions for types and constants.
712         pub use target_arch_not_implemented;
713     }
714 }
715 
716 cfg_if! {
717     if #[cfg(libc_align)] {
718         #[macro_use]
719         mod align;
720     } else {
721         #[macro_use]
722         mod no_align;
723     }
724 }
725 expand_align!();
726