blob: 046fbe3839a7c838ebb54aae362507c8b5bb9d1a [file] [log] [blame]
Alex Crichton07d3a0d2015-10-30 10:21:32 -07001use dox::mem;
2
Alex Crichton5d6cf052015-09-11 14:52:34 -07003pub type rlim_t = c_ulong;
4pub type sa_family_t = u16;
Alex Crichton239f9cd2015-09-18 16:31:34 -07005pub type pthread_key_t = ::c_uint;
Alex Crichton8dce9ad2015-12-03 11:44:14 -08006pub type mqd_t = ::c_int;
7pub type speed_t = ::c_uint;
8pub type tcflag_t = ::c_uint;
Alex Crichton5d6cf052015-09-11 14:52:34 -07009
10pub enum timezone {}
11
12s! {
Alex Crichton5d6cf052015-09-11 14:52:34 -070013 pub struct sockaddr {
14 pub sa_family: sa_family_t,
Alex Crichtonf3b97482015-09-16 14:13:20 -070015 pub sa_data: [::c_char; 14],
Alex Crichton5d6cf052015-09-11 14:52:34 -070016 }
17
Alex Crichton50a42e22015-09-15 14:27:15 -070018 pub struct sockaddr_in {
19 pub sin_family: sa_family_t,
20 pub sin_port: ::in_port_t,
21 pub sin_addr: ::in_addr,
22 pub sin_zero: [u8; 8],
23 }
24
25 pub struct sockaddr_in6 {
26 pub sin6_family: sa_family_t,
27 pub sin6_port: ::in_port_t,
28 pub sin6_flowinfo: u32,
29 pub sin6_addr: ::in6_addr,
30 pub sin6_scope_id: u32,
31 }
32
33 pub struct sockaddr_un {
34 pub sun_family: sa_family_t,
35 pub sun_path: [::c_char; 108]
36 }
37
Alex Crichton5d6cf052015-09-11 14:52:34 -070038 pub struct sockaddr_storage {
39 pub ss_family: sa_family_t,
Alex Crichtonf3b97482015-09-16 14:13:20 -070040 __ss_align: ::size_t,
Alex Crichton5d6cf052015-09-11 14:52:34 -070041 #[cfg(target_pointer_width = "32")]
42 __ss_pad2: [u8; 128 - 2 * 4],
43 #[cfg(target_pointer_width = "64")]
44 __ss_pad2: [u8; 128 - 2 * 8],
45 }
46
Alex Crichton5d6cf052015-09-11 14:52:34 -070047 pub struct addrinfo {
Alex Crichton239f9cd2015-09-18 16:31:34 -070048 pub ai_flags: ::c_int,
49 pub ai_family: ::c_int,
50 pub ai_socktype: ::c_int,
51 pub ai_protocol: ::c_int,
Alex Crichton5d6cf052015-09-11 14:52:34 -070052 pub ai_addrlen: socklen_t,
53
54 #[cfg(target_os = "linux")]
Alex Crichton50a42e22015-09-15 14:27:15 -070055 pub ai_addr: *mut ::sockaddr,
Alex Crichton5d6cf052015-09-11 14:52:34 -070056
57 pub ai_canonname: *mut c_char,
58
Alex Crichtoncd9b33e2015-09-17 14:47:40 -070059 #[cfg(target_os = "android")]
Alex Crichton50a42e22015-09-15 14:27:15 -070060 pub ai_addr: *mut ::sockaddr,
Alex Crichton5d6cf052015-09-11 14:52:34 -070061
62 pub ai_next: *mut addrinfo,
63 }
64
Alex Crichton5d6cf052015-09-11 14:52:34 -070065 pub struct sockaddr_ll {
Alex Crichton239f9cd2015-09-18 16:31:34 -070066 pub sll_family: ::c_ushort,
67 pub sll_protocol: ::c_ushort,
68 pub sll_ifindex: ::c_int,
69 pub sll_hatype: ::c_ushort,
70 pub sll_pkttype: ::c_uchar,
71 pub sll_halen: ::c_uchar,
72 pub sll_addr: [::c_uchar; 8]
Alex Crichton5d6cf052015-09-11 14:52:34 -070073 }
Alex Crichton07d3a0d2015-10-30 10:21:32 -070074
75 pub struct fd_set {
76 fds_bits: [::c_ulong; FD_SETSIZE / ULONG_SIZE],
77 }
Alex Crichton568705e2015-11-03 14:18:52 -080078
79 pub struct tm {
80 pub tm_sec: ::c_int,
81 pub tm_min: ::c_int,
82 pub tm_hour: ::c_int,
83 pub tm_mday: ::c_int,
84 pub tm_mon: ::c_int,
85 pub tm_year: ::c_int,
86 pub tm_wday: ::c_int,
87 pub tm_yday: ::c_int,
88 pub tm_isdst: ::c_int,
89 pub tm_gmtoff: ::c_long,
90 pub tm_zone: *const ::c_char,
91 }
Alexander Polakove09951c2015-11-26 14:00:03 +030092
93 pub struct sched_param {
94 pub sched_priority: ::c_int,
95 #[cfg(target_env = "musl")]
96 pub sched_ss_low_priority: ::c_int,
97 #[cfg(target_env = "musl")]
98 pub sched_ss_repl_period: ::timespec,
99 #[cfg(target_env = "musl")]
100 pub sched_ss_init_budget: ::timespec,
101 #[cfg(target_env = "musl")]
102 pub sched_ss_max_repl: ::c_int,
103 }
Alex Crichton49d7bca2015-11-27 09:40:37 -0800104
105 pub struct Dl_info {
106 pub dli_fname: *const ::c_char,
107 pub dli_fbase: *mut ::c_void,
108 pub dli_sname: *const ::c_char,
109 pub dli_saddr: *mut ::c_void,
110 }
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800111
112 #[cfg_attr(any(target_arch = "x86", target_arch = "x86_64"),
113 repr(packed))]
114 pub struct epoll_event {
115 pub events: ::uint32_t,
116 pub u64: ::uint64_t,
117 }
118
119 pub struct utsname {
120 pub sysname: [::c_char; 65],
121 pub nodename: [::c_char; 65],
122 pub release: [::c_char; 65],
123 pub version: [::c_char; 65],
124 pub machine: [::c_char; 65],
125 pub domainname: [::c_char; 65]
126 }
Alex Crichton5d6cf052015-09-11 14:52:34 -0700127}
128
Alex Crichton07d3a0d2015-10-30 10:21:32 -0700129// intentionally not public, only used for fd_set
130#[cfg(target_pointer_width = "32")]
131const ULONG_SIZE: usize = 32;
132#[cfg(target_pointer_width = "64")]
133const ULONG_SIZE: usize = 64;
134
Alex Crichton239f9cd2015-09-18 16:31:34 -0700135pub const EXIT_FAILURE: ::c_int = 1;
136pub const EXIT_SUCCESS: ::c_int = 0;
137pub const RAND_MAX: ::c_int = 2147483647;
138pub const EOF: ::c_int = -1;
139pub const SEEK_SET: ::c_int = 0;
140pub const SEEK_CUR: ::c_int = 1;
141pub const SEEK_END: ::c_int = 2;
142pub const _IOFBF: ::c_int = 0;
143pub const _IONBF: ::c_int = 2;
144pub const _IOLBF: ::c_int = 1;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700145
Alex Crichton239f9cd2015-09-18 16:31:34 -0700146pub const F_DUPFD: ::c_int = 0;
147pub const F_GETFD: ::c_int = 1;
148pub const F_SETFD: ::c_int = 2;
149pub const F_GETFL: ::c_int = 3;
150pub const F_SETFL: ::c_int = 4;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700151
Alex Crichton239f9cd2015-09-18 16:31:34 -0700152pub const SIGTRAP: ::c_int = 5;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700153
Alex Crichton239f9cd2015-09-18 16:31:34 -0700154pub const PTHREAD_CREATE_JOINABLE: ::c_int = 0;
155pub const PTHREAD_CREATE_DETACHED: ::c_int = 1;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700156
Alex Crichton239f9cd2015-09-18 16:31:34 -0700157pub const CLOCK_REALTIME: ::c_int = 0;
158pub const CLOCK_MONOTONIC: ::c_int = 1;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700159
Alex Crichton239f9cd2015-09-18 16:31:34 -0700160pub const RLIMIT_CPU: ::c_int = 0;
161pub const RLIMIT_FSIZE: ::c_int = 1;
162pub const RLIMIT_DATA: ::c_int = 2;
163pub const RLIMIT_STACK: ::c_int = 3;
164pub const RLIMIT_CORE: ::c_int = 4;
165pub const RLIMIT_LOCKS: ::c_int = 10;
166pub const RLIMIT_SIGPENDING: ::c_int = 11;
167pub const RLIMIT_MSGQUEUE: ::c_int = 12;
168pub const RLIMIT_NICE: ::c_int = 13;
169pub const RLIMIT_RTPRIO: ::c_int = 14;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700170
Alex Crichton239f9cd2015-09-18 16:31:34 -0700171pub const RUSAGE_SELF: ::c_int = 0;
Alex Crichtond3d77922015-09-11 17:03:39 -0700172
173pub const O_RDONLY: ::c_int = 0;
174pub const O_WRONLY: ::c_int = 1;
175pub const O_RDWR: ::c_int = 2;
Alex Crichtond3d77922015-09-11 17:03:39 -0700176pub const O_TRUNC: ::c_int = 512;
Alex Crichton14f7e022015-11-02 14:21:30 -0800177pub const O_CLOEXEC: ::c_int = 0x80000;
Alex Crichtond3d77922015-09-11 17:03:39 -0700178pub const S_IFIFO: ::mode_t = 4096;
179pub const S_IFCHR: ::mode_t = 8192;
180pub const S_IFBLK: ::mode_t = 24576;
181pub const S_IFDIR: ::mode_t = 16384;
182pub const S_IFREG: ::mode_t = 32768;
183pub const S_IFLNK: ::mode_t = 40960;
184pub const S_IFSOCK: ::mode_t = 49152;
185pub const S_IFMT: ::mode_t = 61440;
186pub const S_IRWXU: ::mode_t = 448;
187pub const S_IXUSR: ::mode_t = 64;
188pub const S_IWUSR: ::mode_t = 128;
189pub const S_IRUSR: ::mode_t = 256;
190pub const S_IRWXG: ::mode_t = 56;
191pub const S_IXGRP: ::mode_t = 8;
192pub const S_IWGRP: ::mode_t = 16;
193pub const S_IRGRP: ::mode_t = 32;
194pub const S_IRWXO: ::mode_t = 7;
195pub const S_IXOTH: ::mode_t = 1;
196pub const S_IWOTH: ::mode_t = 2;
197pub const S_IROTH: ::mode_t = 4;
198pub const F_OK: ::c_int = 0;
199pub const R_OK: ::c_int = 4;
200pub const W_OK: ::c_int = 2;
201pub const X_OK: ::c_int = 1;
202pub const STDIN_FILENO: ::c_int = 0;
203pub const STDOUT_FILENO: ::c_int = 1;
204pub const STDERR_FILENO: ::c_int = 2;
205pub const SIGHUP: ::c_int = 1;
206pub const SIGINT: ::c_int = 2;
207pub const SIGQUIT: ::c_int = 3;
208pub const SIGILL: ::c_int = 4;
209pub const SIGABRT: ::c_int = 6;
210pub const SIGFPE: ::c_int = 8;
211pub const SIGKILL: ::c_int = 9;
212pub const SIGSEGV: ::c_int = 11;
213pub const SIGPIPE: ::c_int = 13;
214pub const SIGALRM: ::c_int = 14;
215pub const SIGTERM: ::c_int = 15;
216
217pub const PROT_NONE: ::c_int = 0;
218pub const PROT_READ: ::c_int = 1;
219pub const PROT_WRITE: ::c_int = 2;
220pub const PROT_EXEC: ::c_int = 4;
221
222pub const MAP_FILE: ::c_int = 0x0000;
223pub const MAP_SHARED: ::c_int = 0x0001;
224pub const MAP_PRIVATE: ::c_int = 0x0002;
225pub const MAP_FIXED: ::c_int = 0x0010;
Alex Crichtond3d77922015-09-11 17:03:39 -0700226
227pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void;
228
229pub const MCL_CURRENT: ::c_int = 0x0001;
230pub const MCL_FUTURE: ::c_int = 0x0002;
231
232pub const MS_ASYNC: ::c_int = 0x0001;
233pub const MS_INVALIDATE: ::c_int = 0x0002;
234pub const MS_SYNC: ::c_int = 0x0004;
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800235pub const MS_RDONLY: ::c_ulong = 0x01;
236pub const MS_NOSUID: ::c_ulong = 0x02;
237pub const MS_NODEV: ::c_ulong = 0x04;
238pub const MS_NOEXEC: ::c_ulong = 0x08;
239pub const MS_SYNCHRONOUS: ::c_ulong = 0x10;
240pub const MS_REMOUNT: ::c_ulong = 0x20;
241pub const MS_MANDLOCK: ::c_ulong = 0x40;
242pub const MS_DIRSYNC: ::c_ulong = 0x80;
243pub const MS_NOATIME: ::c_ulong = 0x0400;
244pub const MS_NODIRATIME: ::c_ulong = 0x0800;
245pub const MS_BIND: ::c_ulong = 0x1000;
246pub const MS_MOVE: ::c_ulong = 0x2000;
247pub const MS_REC: ::c_ulong = 0x4000;
248pub const MS_SILENT: ::c_ulong = 0x8000;
249pub const MS_POSIXACL: ::c_ulong = 0x010000;
250pub const MS_UNBINDABLE: ::c_ulong = 0x020000;
251pub const MS_PRIVATE: ::c_ulong = 0x040000;
252pub const MS_SLAVE: ::c_ulong = 0x080000;
253pub const MS_SHARED: ::c_ulong = 0x100000;
254pub const MS_ACTIVE: ::c_ulong = 0x40000000;
255pub const MS_NOUSER: ::c_ulong = 0x80000000;
256pub const MS_MGC_VAL: ::c_ulong = 0xc0ed0000;
257pub const MS_MGC_MSK: ::c_ulong = 0xffff0000;
Alex Crichtond3d77922015-09-11 17:03:39 -0700258
259pub const EPERM: ::c_int = 1;
260pub const ENOENT: ::c_int = 2;
261pub const ESRCH: ::c_int = 3;
262pub const EINTR: ::c_int = 4;
263pub const EIO: ::c_int = 5;
264pub const ENXIO: ::c_int = 6;
265pub const E2BIG: ::c_int = 7;
266pub const ENOEXEC: ::c_int = 8;
267pub const EBADF: ::c_int = 9;
268pub const ECHILD: ::c_int = 10;
269pub const EAGAIN: ::c_int = 11;
270pub const ENOMEM: ::c_int = 12;
271pub const EACCES: ::c_int = 13;
272pub const EFAULT: ::c_int = 14;
273pub const ENOTBLK: ::c_int = 15;
274pub const EBUSY: ::c_int = 16;
275pub const EEXIST: ::c_int = 17;
276pub const EXDEV: ::c_int = 18;
277pub const ENODEV: ::c_int = 19;
278pub const ENOTDIR: ::c_int = 20;
279pub const EISDIR: ::c_int = 21;
280pub const EINVAL: ::c_int = 22;
281pub const ENFILE: ::c_int = 23;
282pub const EMFILE: ::c_int = 24;
283pub const ENOTTY: ::c_int = 25;
284pub const ETXTBSY: ::c_int = 26;
285pub const EFBIG: ::c_int = 27;
286pub const ENOSPC: ::c_int = 28;
287pub const ESPIPE: ::c_int = 29;
288pub const EROFS: ::c_int = 30;
289pub const EMLINK: ::c_int = 31;
290pub const EPIPE: ::c_int = 32;
291pub const EDOM: ::c_int = 33;
292pub const ERANGE: ::c_int = 34;
Alex Crichtond3d77922015-09-11 17:03:39 -0700293pub const EWOULDBLOCK: ::c_int = EAGAIN;
Alex Crichtond3d77922015-09-11 17:03:39 -0700294
295pub const EBFONT: ::c_int = 59;
296pub const ENOSTR: ::c_int = 60;
297pub const ENODATA: ::c_int = 61;
298pub const ETIME: ::c_int = 62;
299pub const ENOSR: ::c_int = 63;
300pub const ENONET: ::c_int = 64;
301pub const ENOPKG: ::c_int = 65;
302pub const EREMOTE: ::c_int = 66;
303pub const ENOLINK: ::c_int = 67;
304pub const EADV: ::c_int = 68;
305pub const ESRMNT: ::c_int = 69;
306pub const ECOMM: ::c_int = 70;
307pub const EPROTO: ::c_int = 71;
Alex Crichtond3d77922015-09-11 17:03:39 -0700308pub const EDOTDOT: ::c_int = 73;
Alex Crichtond3d77922015-09-11 17:03:39 -0700309
310pub const AF_PACKET: ::c_int = 17;
311pub const IPPROTO_RAW: ::c_int = 255;
312
Alex Crichtond3d77922015-09-11 17:03:39 -0700313pub const PROT_GROWSDOWN: ::c_int = 0x1000000;
314pub const PROT_GROWSUP: ::c_int = 0x2000000;
315
316pub const MAP_TYPE: ::c_int = 0x000f;
Alex Crichtond3d77922015-09-11 17:03:39 -0700317
318pub const MADV_NORMAL: ::c_int = 0;
319pub const MADV_RANDOM: ::c_int = 1;
320pub const MADV_SEQUENTIAL: ::c_int = 2;
321pub const MADV_WILLNEED: ::c_int = 3;
322pub const MADV_DONTNEED: ::c_int = 4;
323pub const MADV_REMOVE: ::c_int = 9;
324pub const MADV_DONTFORK: ::c_int = 10;
325pub const MADV_DOFORK: ::c_int = 11;
326pub const MADV_MERGEABLE: ::c_int = 12;
327pub const MADV_UNMERGEABLE: ::c_int = 13;
328pub const MADV_HWPOISON: ::c_int = 100;
329
330pub const IFF_LOOPBACK: ::c_int = 0x8;
331
332pub const AF_UNIX: ::c_int = 1;
333pub const AF_INET: ::c_int = 2;
334pub const AF_INET6: ::c_int = 10;
Alex Crichtond3d77922015-09-11 17:03:39 -0700335pub const SOCK_RAW: ::c_int = 3;
336pub const IPPROTO_TCP: ::c_int = 6;
337pub const IPPROTO_IP: ::c_int = 0;
338pub const IPPROTO_IPV6: ::c_int = 41;
339pub const IP_MULTICAST_TTL: ::c_int = 33;
340pub const IP_MULTICAST_LOOP: ::c_int = 34;
341pub const IP_TTL: ::c_int = 2;
342pub const IP_HDRINCL: ::c_int = 3;
343pub const IP_ADD_MEMBERSHIP: ::c_int = 35;
344pub const IP_DROP_MEMBERSHIP: ::c_int = 36;
345pub const IPV6_ADD_MEMBERSHIP: ::c_int = 20;
346pub const IPV6_DROP_MEMBERSHIP: ::c_int = 21;
347
348pub const TCP_NODELAY: ::c_int = 1;
349pub const TCP_MAXSEG: ::c_int = 2;
350pub const TCP_CORK: ::c_int = 3;
351pub const TCP_KEEPIDLE: ::c_int = 4;
352pub const TCP_KEEPINTVL: ::c_int = 5;
353pub const TCP_KEEPCNT: ::c_int = 6;
354pub const TCP_SYNCNT: ::c_int = 7;
355pub const TCP_LINGER2: ::c_int = 8;
356pub const TCP_DEFER_ACCEPT: ::c_int = 9;
357pub const TCP_WINDOW_CLAMP: ::c_int = 10;
358pub const TCP_INFO: ::c_int = 11;
359pub const TCP_QUICKACK: ::c_int = 12;
360pub const TCP_CONGESTION: ::c_int = 13;
361
Alex Crichtonbabf3902015-09-18 17:16:51 -0700362pub const IPV6_MULTICAST_LOOP: ::c_int = 19;
363pub const IPV6_V6ONLY: ::c_int = 26;
364
Alex Crichtond3d77922015-09-11 17:03:39 -0700365pub const SO_DEBUG: ::c_int = 1;
Alex Crichtond3d77922015-09-11 17:03:39 -0700366
367pub const SHUT_RD: ::c_int = 0;
368pub const SHUT_WR: ::c_int = 1;
369pub const SHUT_RDWR: ::c_int = 2;
370
371pub const LOCK_SH: ::c_int = 1;
372pub const LOCK_EX: ::c_int = 2;
373pub const LOCK_NB: ::c_int = 4;
374pub const LOCK_UN: ::c_int = 8;
375
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700376pub const SIGSTKSZ: ::size_t = 8192;
377
Alex Crichton07d3a0d2015-10-30 10:21:32 -0700378pub const SA_NODEFER: ::c_int = 0x40000000;
379pub const SA_RESETHAND: ::c_int = 0x80000000;
380pub const SA_RESTART: ::c_int = 0x10000000;
381pub const SA_NOCLDSTOP: ::c_int = 0x00000001;
382
David Hotham8b296bd2015-12-12 11:52:54 +0000383pub const PATH_MAX: ::c_int = 4096;
384
Alex Crichton07d3a0d2015-10-30 10:21:32 -0700385pub const FD_SETSIZE: usize = 1024;
386
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800387pub const EPOLLIN: ::c_int = 0x1;
388pub const EPOLLPRI: ::c_int = 0x2;
389pub const EPOLLOUT: ::c_int = 0x4;
390pub const EPOLLRDNORM: ::c_int = 0x40;
391pub const EPOLLRDBAND: ::c_int = 0x80;
392pub const EPOLLWRNORM: ::c_int = 0x100;
393pub const EPOLLWRBAND: ::c_int = 0x200;
394pub const EPOLLMSG: ::c_int = 0x400;
395pub const EPOLLERR: ::c_int = 0x8;
396pub const EPOLLHUP: ::c_int = 0x10;
397pub const EPOLLET: ::c_int = 0x80000000;
398
399pub const EPOLL_CTL_ADD: ::c_int = 1;
400pub const EPOLL_CTL_MOD: ::c_int = 3;
401pub const EPOLL_CTL_DEL: ::c_int = 2;
402
403pub const MNT_DETACH: ::c_int = 0x2;
404pub const MNT_EXPIRE: ::c_int = 0x4;
405
406pub const Q_GETFMT: ::c_int = 0x800004;
407pub const Q_GETINFO: ::c_int = 0x800005;
408pub const Q_SETINFO: ::c_int = 0x800006;
409pub const QIF_BLIMITS: ::uint32_t = 1;
410pub const QIF_SPACE: ::uint32_t = 2;
411pub const QIF_ILIMITS: ::uint32_t = 4;
412pub const QIF_INODES: ::uint32_t = 8;
413pub const QIF_BTIME: ::uint32_t = 16;
414pub const QIF_ITIME: ::uint32_t = 32;
415pub const QIF_LIMITS: ::uint32_t = 5;
416pub const QIF_USAGE: ::uint32_t = 10;
417pub const QIF_TIMES: ::uint32_t = 48;
418pub const QIF_ALL: ::uint32_t = 63;
419
420pub const CBAUD: ::tcflag_t = 0o0010017;
421
422pub const EFD_CLOEXEC: ::c_int = 0x80000;
423
424pub const F_SETLK: ::c_int = 6;
425pub const F_SETLKW: ::c_int = 7;
426
427pub const MNT_FORCE: ::c_int = 0x1;
428
429pub const Q_SYNC: ::c_int = 0x800001;
430pub const Q_QUOTAON: ::c_int = 0x800002;
431pub const Q_QUOTAOFF: ::c_int = 0x800003;
432pub const Q_GETQUOTA: ::c_int = 0x800007;
433pub const Q_SETQUOTA: ::c_int = 0x800008;
434
435pub const TCIOFF: ::c_int = 2;
436pub const TCION: ::c_int = 3;
437pub const TCOOFF: ::c_int = 0;
438pub const TCOON: ::c_int = 1;
439pub const TCIFLUSH: ::c_int = 0;
440pub const TCOFLUSH: ::c_int = 1;
441pub const TCIOFLUSH: ::c_int = 2;
442pub const NL0: ::c_int = 0x00000000;
443pub const NL1: ::c_int = 0x00000100;
444pub const TAB0: ::c_int = 0x00000000;
445pub const TAB1: ::c_int = 0x00000800;
446pub const TAB2: ::c_int = 0x00001000;
447pub const TAB3: ::c_int = 0x00001800;
448pub const CR0: ::c_int = 0x00000000;
449pub const CR1: ::c_int = 0x00000200;
450pub const CR2: ::c_int = 0x00000400;
451pub const CR3: ::c_int = 0x00000600;
452pub const FF0: ::c_int = 0x00000000;
453pub const FF1: ::c_int = 0x00008000;
454pub const BS0: ::c_int = 0x00000000;
455pub const BS1: ::c_int = 0x00002000;
456pub const VT0: ::c_int = 0x00000000;
457pub const VT1: ::c_int = 0x00004000;
458pub const VERASE: usize = 2;
459pub const VWERASE: usize = 14;
460pub const VKILL: usize = 3;
461pub const VREPRINT: usize = 12;
462pub const VINTR: usize = 0;
463pub const VQUIT: usize = 1;
464pub const VSUSP: usize = 10;
465pub const VSTART: usize = 8;
466pub const VSTOP: usize = 9;
467pub const VLNEXT: usize = 15;
468pub const VDISCARD: usize = 13;
469pub const VTIME: usize = 5;
470pub const IGNBRK: ::tcflag_t = 0x00000001;
471pub const BRKINT: ::tcflag_t = 0x00000002;
472pub const IGNPAR: ::tcflag_t = 0x00000004;
473pub const PARMRK: ::tcflag_t = 0x00000008;
474pub const INPCK: ::tcflag_t = 0x00000010;
475pub const ISTRIP: ::tcflag_t = 0x00000020;
476pub const INLCR: ::tcflag_t = 0x00000040;
477pub const IGNCR: ::tcflag_t = 0x00000080;
478pub const ICRNL: ::tcflag_t = 0x00000100;
479pub const IXON: ::tcflag_t = 0x00000400;
480pub const IXOFF: ::tcflag_t = 0x00001000;
481pub const IXANY: ::tcflag_t = 0x00000800;
482pub const IMAXBEL: ::tcflag_t = 0x00002000;
483pub const OPOST: ::tcflag_t = 0x1;
484pub const ONLCR: ::tcflag_t = 0x4;
485pub const CSIZE: ::tcflag_t = 0x00000030;
486pub const CS5: ::tcflag_t = 0x00000000;
487pub const CS6: ::tcflag_t = 0x00000010;
488pub const CS7: ::tcflag_t = 0x00000020;
489pub const CS8: ::tcflag_t = 0x00000030;
490pub const CSTOPB: ::tcflag_t = 0x00000040;
491pub const CREAD: ::tcflag_t = 0x00000080;
492pub const PARENB: ::tcflag_t = 0x00000100;
493pub const PARODD: ::tcflag_t = 0x00000200;
494pub const HUPCL: ::tcflag_t = 0x00000400;
495pub const CLOCAL: ::tcflag_t = 0x00000800;
496pub const CRTSCTS: ::tcflag_t = 0x80000000;
497pub const ECHOKE: ::tcflag_t = 0x00000800;
498pub const ECHOE: ::tcflag_t = 0x00000010;
499pub const ECHOK: ::tcflag_t = 0x00000020;
500pub const ECHO: ::tcflag_t = 0x00000008;
501pub const ECHONL: ::tcflag_t = 0x00000040;
502pub const ECHOPRT: ::tcflag_t = 0x00000400;
503pub const ECHOCTL: ::tcflag_t = 0x00000200;
504pub const ISIG: ::tcflag_t = 0x00000001;
505pub const ICANON: ::tcflag_t = 0x00000002;
506pub const PENDIN: ::tcflag_t = 0x00004000;
507pub const NOFLSH: ::tcflag_t = 0x00000080;
508
509pub const CLONE_VM: ::c_int = 0x100;
510pub const CLONE_FS: ::c_int = 0x200;
511pub const CLONE_FILES: ::c_int = 0x400;
512pub const CLONE_SIGHAND: ::c_int = 0x800;
513pub const CLONE_PTRACE: ::c_int = 0x2000;
514pub const CLONE_VFORK: ::c_int = 0x4000;
515pub const CLONE_PARENT: ::c_int = 0x8000;
516pub const CLONE_THREAD: ::c_int = 0x10000;
517pub const CLONE_NEWNS: ::c_int = 0x20000;
518pub const CLONE_SYSVSEM: ::c_int = 0x40000;
519pub const CLONE_SETTLS: ::c_int = 0x80000;
520pub const CLONE_PARENT_SETTID: ::c_int = 0x100000;
521pub const CLONE_CHILD_CLEARTID: ::c_int = 0x200000;
522pub const CLONE_DETACHED: ::c_int = 0x400000;
523pub const CLONE_UNTRACED: ::c_int = 0x800000;
524pub const CLONE_CHILD_SETTID: ::c_int = 0x01000000;
525
Alex Crichton07d3a0d2015-10-30 10:21:32 -0700526f! {
527 pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () {
528 let fd = fd as usize;
Alex Crichtonef66d122015-11-09 23:53:57 -0800529 let size = mem::size_of_val(&(*set).fds_bits[0]) * 8;
Alex Crichton07d3a0d2015-10-30 10:21:32 -0700530 (*set).fds_bits[fd / size] &= !(1 << (fd % size));
531 return
532 }
533
534 pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool {
535 let fd = fd as usize;
Alex Crichtonef66d122015-11-09 23:53:57 -0800536 let size = mem::size_of_val(&(*set).fds_bits[0]) * 8;
Alex Crichton07d3a0d2015-10-30 10:21:32 -0700537 return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0
538 }
539
540 pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () {
541 let fd = fd as usize;
Alex Crichtonef66d122015-11-09 23:53:57 -0800542 let size = mem::size_of_val(&(*set).fds_bits[0]) * 8;
Alex Crichton07d3a0d2015-10-30 10:21:32 -0700543 (*set).fds_bits[fd / size] |= 1 << (fd % size);
544 return
545 }
546
547 pub fn FD_ZERO(set: *mut fd_set) -> () {
548 for slot in (*set).fds_bits.iter_mut() {
549 *slot = 0;
550 }
551 }
552
553 pub fn WIFEXITED(status: ::c_int) -> bool {
554 (status & 0xff) == 0
555 }
556
557 pub fn WEXITSTATUS(status: ::c_int) -> ::c_int {
558 (status >> 8) & 0xff
559 }
560
561 pub fn WTERMSIG(status: ::c_int) -> ::c_int {
562 status & 0x7f
563 }
564}
565
Alex Crichtond3d77922015-09-11 17:03:39 -0700566extern {
567 pub fn fdatasync(fd: ::c_int) -> ::c_int;
Alex Crichton8293ced2015-09-15 17:05:19 -0700568 pub fn mincore(addr: *mut ::c_void, len: ::size_t,
569 vec: *mut ::c_uchar) -> ::c_int;
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700570 pub fn clock_gettime(clk_id: ::c_int, tp: *mut ::timespec) -> ::c_int;
571 pub fn prctl(option: ::c_int, ...) -> ::c_int;
572 pub fn pthread_getattr_np(native: ::pthread_t,
573 attr: *mut ::pthread_attr_t) -> ::c_int;
574 pub fn pthread_attr_getguardsize(attr: *const ::pthread_attr_t,
575 guardsize: *mut ::size_t) -> ::c_int;
576 pub fn pthread_attr_getstack(attr: *const ::pthread_attr_t,
577 stackaddr: *mut *mut ::c_void,
578 stacksize: *mut ::size_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700579 pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void;
580 pub fn setgroups(ngroups: ::size_t,
581 ptr: *const ::gid_t) -> ::c_int;
Alexander Polakove09951c2015-11-26 14:00:03 +0300582 pub fn sched_setscheduler(pid: ::pid_t, policy: ::c_int, param: *const sched_param) -> ::c_int;
583 pub fn sched_getscheduler(pid: ::pid_t) -> ::c_int;
Alexander Polakov557c6702015-11-30 16:55:51 +0300584 pub fn sched_get_priority_max(policy: ::c_int) -> ::c_int;
585 pub fn sched_get_priority_min(policy: ::c_int) -> ::c_int;
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800586 pub fn epoll_create(size: ::c_int) -> ::c_int;
587 pub fn epoll_ctl(epfd: ::c_int,
588 op: ::c_int,
589 fd: ::c_int,
590 event: *mut epoll_event) -> ::c_int;
591 pub fn epoll_wait(epfd: ::c_int,
592 events: *mut epoll_event,
593 maxevents: ::c_int,
594 timeout: ::c_int) -> ::c_int;
595 pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int;
596 pub fn mount(src: *const ::c_char,
597 target: *const ::c_char,
598 fstype: *const ::c_char,
599 flags: ::c_ulong,
600 data: *const ::c_void) -> ::c_int;
601 pub fn umount(target: *const ::c_char) -> ::c_int;
602 pub fn umount2(target: *const ::c_char, flags: ::c_int) -> ::c_int;
603 pub fn clone(cb: extern fn(*mut ::c_void) -> ::c_int,
604 child_stack: *mut ::c_void,
605 flags: ::c_int,
606 arg: *mut ::c_void, ...) -> ::c_int;
607 pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int;
608 pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int;
Florian Hahn6bb23a12015-12-16 12:28:51 +0100609 pub fn memrchr(cx: *const ::c_void, c: ::c_int, n: ::size_t) -> *mut ::c_void;
Alex Crichton5d6cf052015-09-11 14:52:34 -0700610}
611
612cfg_if! {
Alex Crichton5d6cf052015-09-11 14:52:34 -0700613 if #[cfg(target_os = "linux")] {
614 mod linux;
615 pub use self::linux::*;
616 } else if #[cfg(target_os = "android")] {
617 mod android;
618 pub use self::android::*;
619 } else {
620 // ...
621 }
622}