blob: f213a52a7441138a32fb62fa0a94584db35cbdfc [file] [log] [blame]
Alex Crichton07d3a0d2015-10-30 10:21:32 -07001use dox::mem;
2
Alex Crichton5d6cf052015-09-11 14:52:34 -07003pub type sa_family_t = u16;
Alex Crichton239f9cd2015-09-18 16:31:34 -07004pub type pthread_key_t = ::c_uint;
Alex Crichton8dce9ad2015-12-03 11:44:14 -08005pub type speed_t = ::c_uint;
6pub type tcflag_t = ::c_uint;
Kamal Marhubi0cfc25f2016-02-04 15:57:10 -05007pub type loff_t = ::c_longlong;
Alex Crichton5d6cf052015-09-11 14:52:34 -07008
9pub enum timezone {}
10
11s! {
Alex Crichton5d6cf052015-09-11 14:52:34 -070012 pub struct sockaddr {
13 pub sa_family: sa_family_t,
Alex Crichtonf3b97482015-09-16 14:13:20 -070014 pub sa_data: [::c_char; 14],
Alex Crichton5d6cf052015-09-11 14:52:34 -070015 }
16
Alex Crichton50a42e22015-09-15 14:27:15 -070017 pub struct sockaddr_in {
18 pub sin_family: sa_family_t,
19 pub sin_port: ::in_port_t,
20 pub sin_addr: ::in_addr,
21 pub sin_zero: [u8; 8],
22 }
23
24 pub struct sockaddr_in6 {
25 pub sin6_family: sa_family_t,
26 pub sin6_port: ::in_port_t,
27 pub sin6_flowinfo: u32,
28 pub sin6_addr: ::in6_addr,
29 pub sin6_scope_id: u32,
30 }
31
32 pub struct sockaddr_un {
33 pub sun_family: sa_family_t,
34 pub sun_path: [::c_char; 108]
35 }
36
Alex Crichton5d6cf052015-09-11 14:52:34 -070037 pub struct sockaddr_storage {
38 pub ss_family: sa_family_t,
Alex Crichtonf3b97482015-09-16 14:13:20 -070039 __ss_align: ::size_t,
Alex Crichton5d6cf052015-09-11 14:52:34 -070040 #[cfg(target_pointer_width = "32")]
41 __ss_pad2: [u8; 128 - 2 * 4],
42 #[cfg(target_pointer_width = "64")]
43 __ss_pad2: [u8; 128 - 2 * 8],
44 }
45
Alex Crichton5d6cf052015-09-11 14:52:34 -070046 pub struct addrinfo {
Alex Crichton239f9cd2015-09-18 16:31:34 -070047 pub ai_flags: ::c_int,
48 pub ai_family: ::c_int,
49 pub ai_socktype: ::c_int,
50 pub ai_protocol: ::c_int,
Alex Crichton5d6cf052015-09-11 14:52:34 -070051 pub ai_addrlen: socklen_t,
52
Brian Anderson7d1d5752015-11-26 23:27:45 +000053 #[cfg(any(target_os = "linux", target_os = "emscripten"))]
Alex Crichton50a42e22015-09-15 14:27:15 -070054 pub ai_addr: *mut ::sockaddr,
Alex Crichton5d6cf052015-09-11 14:52:34 -070055
56 pub ai_canonname: *mut c_char,
57
Alex Crichtoncd9b33e2015-09-17 14:47:40 -070058 #[cfg(target_os = "android")]
Alex Crichton50a42e22015-09-15 14:27:15 -070059 pub ai_addr: *mut ::sockaddr,
Alex Crichton5d6cf052015-09-11 14:52:34 -070060
61 pub ai_next: *mut addrinfo,
62 }
63
Alex Crichton5d6cf052015-09-11 14:52:34 -070064 pub struct sockaddr_ll {
Alex Crichton239f9cd2015-09-18 16:31:34 -070065 pub sll_family: ::c_ushort,
66 pub sll_protocol: ::c_ushort,
67 pub sll_ifindex: ::c_int,
68 pub sll_hatype: ::c_ushort,
69 pub sll_pkttype: ::c_uchar,
70 pub sll_halen: ::c_uchar,
71 pub sll_addr: [::c_uchar; 8]
Alex Crichton5d6cf052015-09-11 14:52:34 -070072 }
Alex Crichton07d3a0d2015-10-30 10:21:32 -070073
74 pub struct fd_set {
75 fds_bits: [::c_ulong; FD_SETSIZE / ULONG_SIZE],
76 }
Alex Crichton568705e2015-11-03 14:18:52 -080077
78 pub struct tm {
79 pub tm_sec: ::c_int,
80 pub tm_min: ::c_int,
81 pub tm_hour: ::c_int,
82 pub tm_mday: ::c_int,
83 pub tm_mon: ::c_int,
84 pub tm_year: ::c_int,
85 pub tm_wday: ::c_int,
86 pub tm_yday: ::c_int,
87 pub tm_isdst: ::c_int,
88 pub tm_gmtoff: ::c_long,
89 pub tm_zone: *const ::c_char,
90 }
Alexander Polakove09951c2015-11-26 14:00:03 +030091
92 pub struct sched_param {
93 pub sched_priority: ::c_int,
94 #[cfg(target_env = "musl")]
95 pub sched_ss_low_priority: ::c_int,
96 #[cfg(target_env = "musl")]
97 pub sched_ss_repl_period: ::timespec,
98 #[cfg(target_env = "musl")]
99 pub sched_ss_init_budget: ::timespec,
100 #[cfg(target_env = "musl")]
101 pub sched_ss_max_repl: ::c_int,
102 }
Alex Crichton49d7bca2015-11-27 09:40:37 -0800103
104 pub struct Dl_info {
105 pub dli_fname: *const ::c_char,
106 pub dli_fbase: *mut ::c_void,
107 pub dli_sname: *const ::c_char,
108 pub dli_saddr: *mut ::c_void,
109 }
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800110
Brian Anderson773aab82015-12-29 20:00:29 +0000111 #[cfg_attr(any(all(target_arch = "x86", not(target_env = "musl")),
112 target_arch = "x86_64"),
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800113 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;
James Perryb979fe02016-01-23 21:28:42 +0000178
Brian Campbellcb12fdf2016-01-31 21:27:59 -0500179pub const SOCK_CLOEXEC: ::c_int = O_CLOEXEC;
James Perryb979fe02016-01-23 21:28:42 +0000180
Alex Crichtond3d77922015-09-11 17:03:39 -0700181pub const S_IFIFO: ::mode_t = 4096;
182pub const S_IFCHR: ::mode_t = 8192;
183pub const S_IFBLK: ::mode_t = 24576;
184pub const S_IFDIR: ::mode_t = 16384;
185pub const S_IFREG: ::mode_t = 32768;
186pub const S_IFLNK: ::mode_t = 40960;
187pub const S_IFSOCK: ::mode_t = 49152;
188pub const S_IFMT: ::mode_t = 61440;
189pub const S_IRWXU: ::mode_t = 448;
190pub const S_IXUSR: ::mode_t = 64;
191pub const S_IWUSR: ::mode_t = 128;
192pub const S_IRUSR: ::mode_t = 256;
193pub const S_IRWXG: ::mode_t = 56;
194pub const S_IXGRP: ::mode_t = 8;
195pub const S_IWGRP: ::mode_t = 16;
196pub const S_IRGRP: ::mode_t = 32;
197pub const S_IRWXO: ::mode_t = 7;
198pub const S_IXOTH: ::mode_t = 1;
199pub const S_IWOTH: ::mode_t = 2;
200pub const S_IROTH: ::mode_t = 4;
201pub const F_OK: ::c_int = 0;
202pub const R_OK: ::c_int = 4;
203pub const W_OK: ::c_int = 2;
204pub const X_OK: ::c_int = 1;
205pub const STDIN_FILENO: ::c_int = 0;
206pub const STDOUT_FILENO: ::c_int = 1;
207pub const STDERR_FILENO: ::c_int = 2;
208pub const SIGHUP: ::c_int = 1;
209pub const SIGINT: ::c_int = 2;
210pub const SIGQUIT: ::c_int = 3;
211pub const SIGILL: ::c_int = 4;
212pub const SIGABRT: ::c_int = 6;
213pub const SIGFPE: ::c_int = 8;
214pub const SIGKILL: ::c_int = 9;
215pub const SIGSEGV: ::c_int = 11;
216pub const SIGPIPE: ::c_int = 13;
217pub const SIGALRM: ::c_int = 14;
218pub const SIGTERM: ::c_int = 15;
219
220pub const PROT_NONE: ::c_int = 0;
221pub const PROT_READ: ::c_int = 1;
222pub const PROT_WRITE: ::c_int = 2;
223pub const PROT_EXEC: ::c_int = 4;
224
225pub const MAP_FILE: ::c_int = 0x0000;
226pub const MAP_SHARED: ::c_int = 0x0001;
227pub const MAP_PRIVATE: ::c_int = 0x0002;
228pub const MAP_FIXED: ::c_int = 0x0010;
Alex Crichtond3d77922015-09-11 17:03:39 -0700229
230pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void;
231
232pub const MCL_CURRENT: ::c_int = 0x0001;
233pub const MCL_FUTURE: ::c_int = 0x0002;
234
235pub const MS_ASYNC: ::c_int = 0x0001;
236pub const MS_INVALIDATE: ::c_int = 0x0002;
237pub const MS_SYNC: ::c_int = 0x0004;
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800238pub const MS_RDONLY: ::c_ulong = 0x01;
239pub const MS_NOSUID: ::c_ulong = 0x02;
240pub const MS_NODEV: ::c_ulong = 0x04;
241pub const MS_NOEXEC: ::c_ulong = 0x08;
242pub const MS_SYNCHRONOUS: ::c_ulong = 0x10;
243pub const MS_REMOUNT: ::c_ulong = 0x20;
244pub const MS_MANDLOCK: ::c_ulong = 0x40;
245pub const MS_DIRSYNC: ::c_ulong = 0x80;
246pub const MS_NOATIME: ::c_ulong = 0x0400;
247pub const MS_NODIRATIME: ::c_ulong = 0x0800;
248pub const MS_BIND: ::c_ulong = 0x1000;
249pub const MS_MOVE: ::c_ulong = 0x2000;
250pub const MS_REC: ::c_ulong = 0x4000;
251pub const MS_SILENT: ::c_ulong = 0x8000;
252pub const MS_POSIXACL: ::c_ulong = 0x010000;
253pub const MS_UNBINDABLE: ::c_ulong = 0x020000;
254pub const MS_PRIVATE: ::c_ulong = 0x040000;
255pub const MS_SLAVE: ::c_ulong = 0x080000;
256pub const MS_SHARED: ::c_ulong = 0x100000;
257pub const MS_ACTIVE: ::c_ulong = 0x40000000;
258pub const MS_NOUSER: ::c_ulong = 0x80000000;
259pub const MS_MGC_VAL: ::c_ulong = 0xc0ed0000;
260pub const MS_MGC_MSK: ::c_ulong = 0xffff0000;
Jim Blandye91606d2016-01-11 20:47:08 -0800261pub const MS_RMT_MASK: ::c_ulong = 0x800051;
Alex Crichtond3d77922015-09-11 17:03:39 -0700262
263pub const EPERM: ::c_int = 1;
264pub const ENOENT: ::c_int = 2;
265pub const ESRCH: ::c_int = 3;
266pub const EINTR: ::c_int = 4;
267pub const EIO: ::c_int = 5;
268pub const ENXIO: ::c_int = 6;
269pub const E2BIG: ::c_int = 7;
270pub const ENOEXEC: ::c_int = 8;
271pub const EBADF: ::c_int = 9;
272pub const ECHILD: ::c_int = 10;
273pub const EAGAIN: ::c_int = 11;
274pub const ENOMEM: ::c_int = 12;
275pub const EACCES: ::c_int = 13;
276pub const EFAULT: ::c_int = 14;
277pub const ENOTBLK: ::c_int = 15;
278pub const EBUSY: ::c_int = 16;
279pub const EEXIST: ::c_int = 17;
280pub const EXDEV: ::c_int = 18;
281pub const ENODEV: ::c_int = 19;
282pub const ENOTDIR: ::c_int = 20;
283pub const EISDIR: ::c_int = 21;
284pub const EINVAL: ::c_int = 22;
285pub const ENFILE: ::c_int = 23;
286pub const EMFILE: ::c_int = 24;
287pub const ENOTTY: ::c_int = 25;
288pub const ETXTBSY: ::c_int = 26;
289pub const EFBIG: ::c_int = 27;
290pub const ENOSPC: ::c_int = 28;
291pub const ESPIPE: ::c_int = 29;
292pub const EROFS: ::c_int = 30;
293pub const EMLINK: ::c_int = 31;
294pub const EPIPE: ::c_int = 32;
295pub const EDOM: ::c_int = 33;
296pub const ERANGE: ::c_int = 34;
Alex Crichtond3d77922015-09-11 17:03:39 -0700297pub const EWOULDBLOCK: ::c_int = EAGAIN;
Alex Crichtond3d77922015-09-11 17:03:39 -0700298
299pub const EBFONT: ::c_int = 59;
300pub const ENOSTR: ::c_int = 60;
301pub const ENODATA: ::c_int = 61;
302pub const ETIME: ::c_int = 62;
303pub const ENOSR: ::c_int = 63;
304pub const ENONET: ::c_int = 64;
305pub const ENOPKG: ::c_int = 65;
306pub const EREMOTE: ::c_int = 66;
307pub const ENOLINK: ::c_int = 67;
308pub const EADV: ::c_int = 68;
309pub const ESRMNT: ::c_int = 69;
310pub const ECOMM: ::c_int = 70;
311pub const EPROTO: ::c_int = 71;
Alex Crichtond3d77922015-09-11 17:03:39 -0700312pub const EDOTDOT: ::c_int = 73;
Alex Crichtond3d77922015-09-11 17:03:39 -0700313
314pub const AF_PACKET: ::c_int = 17;
315pub const IPPROTO_RAW: ::c_int = 255;
316
Alex Crichtond3d77922015-09-11 17:03:39 -0700317pub const PROT_GROWSDOWN: ::c_int = 0x1000000;
318pub const PROT_GROWSUP: ::c_int = 0x2000000;
319
320pub const MAP_TYPE: ::c_int = 0x000f;
Alex Crichtond3d77922015-09-11 17:03:39 -0700321
322pub const MADV_NORMAL: ::c_int = 0;
323pub const MADV_RANDOM: ::c_int = 1;
324pub const MADV_SEQUENTIAL: ::c_int = 2;
325pub const MADV_WILLNEED: ::c_int = 3;
326pub const MADV_DONTNEED: ::c_int = 4;
327pub const MADV_REMOVE: ::c_int = 9;
328pub const MADV_DONTFORK: ::c_int = 10;
329pub const MADV_DOFORK: ::c_int = 11;
330pub const MADV_MERGEABLE: ::c_int = 12;
331pub const MADV_UNMERGEABLE: ::c_int = 13;
332pub const MADV_HWPOISON: ::c_int = 100;
333
334pub const IFF_LOOPBACK: ::c_int = 0x8;
335
336pub const AF_UNIX: ::c_int = 1;
337pub const AF_INET: ::c_int = 2;
338pub const AF_INET6: ::c_int = 10;
Alex Crichtond3d77922015-09-11 17:03:39 -0700339pub const SOCK_RAW: ::c_int = 3;
340pub const IPPROTO_TCP: ::c_int = 6;
341pub const IPPROTO_IP: ::c_int = 0;
342pub const IPPROTO_IPV6: ::c_int = 41;
343pub const IP_MULTICAST_TTL: ::c_int = 33;
344pub const IP_MULTICAST_LOOP: ::c_int = 34;
345pub const IP_TTL: ::c_int = 2;
346pub const IP_HDRINCL: ::c_int = 3;
347pub const IP_ADD_MEMBERSHIP: ::c_int = 35;
348pub const IP_DROP_MEMBERSHIP: ::c_int = 36;
Jakab Kristófd614a3f2016-01-19 18:07:14 +0100349pub const IP_TRANSPARENT: ::c_int = 19;
Alex Crichtond3d77922015-09-11 17:03:39 -0700350pub const IPV6_ADD_MEMBERSHIP: ::c_int = 20;
351pub const IPV6_DROP_MEMBERSHIP: ::c_int = 21;
352
353pub const TCP_NODELAY: ::c_int = 1;
354pub const TCP_MAXSEG: ::c_int = 2;
355pub const TCP_CORK: ::c_int = 3;
356pub const TCP_KEEPIDLE: ::c_int = 4;
357pub const TCP_KEEPINTVL: ::c_int = 5;
358pub const TCP_KEEPCNT: ::c_int = 6;
359pub const TCP_SYNCNT: ::c_int = 7;
360pub const TCP_LINGER2: ::c_int = 8;
361pub const TCP_DEFER_ACCEPT: ::c_int = 9;
362pub const TCP_WINDOW_CLAMP: ::c_int = 10;
363pub const TCP_INFO: ::c_int = 11;
364pub const TCP_QUICKACK: ::c_int = 12;
365pub const TCP_CONGESTION: ::c_int = 13;
366
Alex Crichtonbabf3902015-09-18 17:16:51 -0700367pub const IPV6_MULTICAST_LOOP: ::c_int = 19;
368pub const IPV6_V6ONLY: ::c_int = 26;
369
Alex Crichtond3d77922015-09-11 17:03:39 -0700370pub const SO_DEBUG: ::c_int = 1;
Alex Crichtond3d77922015-09-11 17:03:39 -0700371
372pub const SHUT_RD: ::c_int = 0;
373pub const SHUT_WR: ::c_int = 1;
374pub const SHUT_RDWR: ::c_int = 2;
375
376pub const LOCK_SH: ::c_int = 1;
377pub const LOCK_EX: ::c_int = 2;
378pub const LOCK_NB: ::c_int = 4;
379pub const LOCK_UN: ::c_int = 8;
380
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700381pub const SIGSTKSZ: ::size_t = 8192;
382
Alex Crichton07d3a0d2015-10-30 10:21:32 -0700383pub const SA_NODEFER: ::c_int = 0x40000000;
384pub const SA_RESETHAND: ::c_int = 0x80000000;
385pub const SA_RESTART: ::c_int = 0x10000000;
386pub const SA_NOCLDSTOP: ::c_int = 0x00000001;
387
David Hotham8b296bd2015-12-12 11:52:54 +0000388pub const PATH_MAX: ::c_int = 4096;
389
Alex Crichton07d3a0d2015-10-30 10:21:32 -0700390pub const FD_SETSIZE: usize = 1024;
391
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800392pub const EPOLLIN: ::c_int = 0x1;
393pub const EPOLLPRI: ::c_int = 0x2;
394pub const EPOLLOUT: ::c_int = 0x4;
395pub const EPOLLRDNORM: ::c_int = 0x40;
396pub const EPOLLRDBAND: ::c_int = 0x80;
397pub const EPOLLWRNORM: ::c_int = 0x100;
398pub const EPOLLWRBAND: ::c_int = 0x200;
399pub const EPOLLMSG: ::c_int = 0x400;
400pub const EPOLLERR: ::c_int = 0x8;
401pub const EPOLLHUP: ::c_int = 0x10;
402pub const EPOLLET: ::c_int = 0x80000000;
403
404pub const EPOLL_CTL_ADD: ::c_int = 1;
405pub const EPOLL_CTL_MOD: ::c_int = 3;
406pub const EPOLL_CTL_DEL: ::c_int = 2;
407
408pub const MNT_DETACH: ::c_int = 0x2;
409pub const MNT_EXPIRE: ::c_int = 0x4;
410
411pub const Q_GETFMT: ::c_int = 0x800004;
412pub const Q_GETINFO: ::c_int = 0x800005;
413pub const Q_SETINFO: ::c_int = 0x800006;
414pub const QIF_BLIMITS: ::uint32_t = 1;
415pub const QIF_SPACE: ::uint32_t = 2;
416pub const QIF_ILIMITS: ::uint32_t = 4;
417pub const QIF_INODES: ::uint32_t = 8;
418pub const QIF_BTIME: ::uint32_t = 16;
419pub const QIF_ITIME: ::uint32_t = 32;
420pub const QIF_LIMITS: ::uint32_t = 5;
421pub const QIF_USAGE: ::uint32_t = 10;
422pub const QIF_TIMES: ::uint32_t = 48;
423pub const QIF_ALL: ::uint32_t = 63;
424
425pub const CBAUD: ::tcflag_t = 0o0010017;
426
427pub const EFD_CLOEXEC: ::c_int = 0x80000;
428
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800429pub const MNT_FORCE: ::c_int = 0x1;
430
431pub const Q_SYNC: ::c_int = 0x800001;
432pub const Q_QUOTAON: ::c_int = 0x800002;
433pub const Q_QUOTAOFF: ::c_int = 0x800003;
434pub const Q_GETQUOTA: ::c_int = 0x800007;
435pub const Q_SETQUOTA: ::c_int = 0x800008;
436
437pub const TCIOFF: ::c_int = 2;
438pub const TCION: ::c_int = 3;
439pub const TCOOFF: ::c_int = 0;
440pub const TCOON: ::c_int = 1;
441pub const TCIFLUSH: ::c_int = 0;
442pub const TCOFLUSH: ::c_int = 1;
443pub const TCIOFLUSH: ::c_int = 2;
444pub const NL0: ::c_int = 0x00000000;
445pub const NL1: ::c_int = 0x00000100;
446pub const TAB0: ::c_int = 0x00000000;
447pub const TAB1: ::c_int = 0x00000800;
448pub const TAB2: ::c_int = 0x00001000;
449pub const TAB3: ::c_int = 0x00001800;
450pub const CR0: ::c_int = 0x00000000;
451pub const CR1: ::c_int = 0x00000200;
452pub const CR2: ::c_int = 0x00000400;
453pub const CR3: ::c_int = 0x00000600;
454pub const FF0: ::c_int = 0x00000000;
455pub const FF1: ::c_int = 0x00008000;
456pub const BS0: ::c_int = 0x00000000;
457pub const BS1: ::c_int = 0x00002000;
458pub const VT0: ::c_int = 0x00000000;
459pub const VT1: ::c_int = 0x00004000;
460pub const VERASE: usize = 2;
461pub const VWERASE: usize = 14;
462pub const VKILL: usize = 3;
463pub const VREPRINT: usize = 12;
464pub const VINTR: usize = 0;
465pub const VQUIT: usize = 1;
466pub const VSUSP: usize = 10;
467pub const VSTART: usize = 8;
468pub const VSTOP: usize = 9;
469pub const VLNEXT: usize = 15;
470pub const VDISCARD: usize = 13;
471pub const VTIME: usize = 5;
472pub const IGNBRK: ::tcflag_t = 0x00000001;
473pub const BRKINT: ::tcflag_t = 0x00000002;
474pub const IGNPAR: ::tcflag_t = 0x00000004;
475pub const PARMRK: ::tcflag_t = 0x00000008;
476pub const INPCK: ::tcflag_t = 0x00000010;
477pub const ISTRIP: ::tcflag_t = 0x00000020;
478pub const INLCR: ::tcflag_t = 0x00000040;
479pub const IGNCR: ::tcflag_t = 0x00000080;
480pub const ICRNL: ::tcflag_t = 0x00000100;
481pub const IXON: ::tcflag_t = 0x00000400;
482pub const IXOFF: ::tcflag_t = 0x00001000;
483pub const IXANY: ::tcflag_t = 0x00000800;
484pub const IMAXBEL: ::tcflag_t = 0x00002000;
485pub const OPOST: ::tcflag_t = 0x1;
486pub const ONLCR: ::tcflag_t = 0x4;
487pub const CSIZE: ::tcflag_t = 0x00000030;
488pub const CS5: ::tcflag_t = 0x00000000;
489pub const CS6: ::tcflag_t = 0x00000010;
490pub const CS7: ::tcflag_t = 0x00000020;
491pub const CS8: ::tcflag_t = 0x00000030;
492pub const CSTOPB: ::tcflag_t = 0x00000040;
493pub const CREAD: ::tcflag_t = 0x00000080;
494pub const PARENB: ::tcflag_t = 0x00000100;
495pub const PARODD: ::tcflag_t = 0x00000200;
496pub const HUPCL: ::tcflag_t = 0x00000400;
497pub const CLOCAL: ::tcflag_t = 0x00000800;
498pub const CRTSCTS: ::tcflag_t = 0x80000000;
499pub const ECHOKE: ::tcflag_t = 0x00000800;
500pub const ECHOE: ::tcflag_t = 0x00000010;
501pub const ECHOK: ::tcflag_t = 0x00000020;
502pub const ECHO: ::tcflag_t = 0x00000008;
503pub const ECHONL: ::tcflag_t = 0x00000040;
504pub const ECHOPRT: ::tcflag_t = 0x00000400;
505pub const ECHOCTL: ::tcflag_t = 0x00000200;
506pub const ISIG: ::tcflag_t = 0x00000001;
507pub const ICANON: ::tcflag_t = 0x00000002;
508pub const PENDIN: ::tcflag_t = 0x00004000;
509pub const NOFLSH: ::tcflag_t = 0x00000080;
510
511pub const CLONE_VM: ::c_int = 0x100;
512pub const CLONE_FS: ::c_int = 0x200;
513pub const CLONE_FILES: ::c_int = 0x400;
514pub const CLONE_SIGHAND: ::c_int = 0x800;
515pub const CLONE_PTRACE: ::c_int = 0x2000;
516pub const CLONE_VFORK: ::c_int = 0x4000;
517pub const CLONE_PARENT: ::c_int = 0x8000;
518pub const CLONE_THREAD: ::c_int = 0x10000;
519pub const CLONE_NEWNS: ::c_int = 0x20000;
520pub const CLONE_SYSVSEM: ::c_int = 0x40000;
521pub const CLONE_SETTLS: ::c_int = 0x80000;
522pub const CLONE_PARENT_SETTID: ::c_int = 0x100000;
523pub const CLONE_CHILD_CLEARTID: ::c_int = 0x200000;
524pub const CLONE_DETACHED: ::c_int = 0x400000;
525pub const CLONE_UNTRACED: ::c_int = 0x800000;
526pub const CLONE_CHILD_SETTID: ::c_int = 0x01000000;
527
Nikita Baksalyar25726a62016-01-17 21:41:34 +0300528pub const WNOHANG: ::c_int = 1;
529
Kamal Marhubi0cfc25f2016-02-04 15:57:10 -0500530pub const SPLICE_F_MOVE: ::c_uint = 0x01;
531pub const SPLICE_F_NONBLOCK: ::c_uint = 0x02;
532pub const SPLICE_F_MORE: ::c_uint = 0x04;
533pub const SPLICE_F_GIFT: ::c_uint = 0x08;
534
Alex Crichton29de5982016-02-04 13:48:13 -0800535pub const RTLD_LOCAL: ::c_int = 0;
536
Alex Crichton07d3a0d2015-10-30 10:21:32 -0700537f! {
538 pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () {
539 let fd = fd as usize;
Alex Crichtonef66d122015-11-09 23:53:57 -0800540 let size = mem::size_of_val(&(*set).fds_bits[0]) * 8;
Alex Crichton07d3a0d2015-10-30 10:21:32 -0700541 (*set).fds_bits[fd / size] &= !(1 << (fd % size));
542 return
543 }
544
545 pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool {
546 let fd = fd as usize;
Alex Crichtonef66d122015-11-09 23:53:57 -0800547 let size = mem::size_of_val(&(*set).fds_bits[0]) * 8;
Alex Crichton07d3a0d2015-10-30 10:21:32 -0700548 return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0
549 }
550
551 pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () {
552 let fd = fd as usize;
Alex Crichtonef66d122015-11-09 23:53:57 -0800553 let size = mem::size_of_val(&(*set).fds_bits[0]) * 8;
Alex Crichton07d3a0d2015-10-30 10:21:32 -0700554 (*set).fds_bits[fd / size] |= 1 << (fd % size);
555 return
556 }
557
558 pub fn FD_ZERO(set: *mut fd_set) -> () {
559 for slot in (*set).fds_bits.iter_mut() {
560 *slot = 0;
561 }
562 }
563
564 pub fn WIFEXITED(status: ::c_int) -> bool {
565 (status & 0xff) == 0
566 }
567
568 pub fn WEXITSTATUS(status: ::c_int) -> ::c_int {
569 (status >> 8) & 0xff
570 }
571
572 pub fn WTERMSIG(status: ::c_int) -> ::c_int {
573 status & 0x7f
574 }
575}
576
Alex Crichtond3d77922015-09-11 17:03:39 -0700577extern {
Nikita Baksalyarbff38922016-01-17 22:17:20 +0300578 pub fn getpwuid_r(uid: ::uid_t,
579 pwd: *mut passwd,
580 buf: *mut ::c_char,
581 buflen: ::size_t,
582 result: *mut *mut passwd) -> ::c_int;
Alex Crichtond3d77922015-09-11 17:03:39 -0700583 pub fn fdatasync(fd: ::c_int) -> ::c_int;
Alex Crichton8293ced2015-09-15 17:05:19 -0700584 pub fn mincore(addr: *mut ::c_void, len: ::size_t,
585 vec: *mut ::c_uchar) -> ::c_int;
Alex Crichtoncd9b33e2015-09-17 14:47:40 -0700586 pub fn clock_gettime(clk_id: ::c_int, tp: *mut ::timespec) -> ::c_int;
587 pub fn prctl(option: ::c_int, ...) -> ::c_int;
588 pub fn pthread_getattr_np(native: ::pthread_t,
589 attr: *mut ::pthread_attr_t) -> ::c_int;
590 pub fn pthread_attr_getguardsize(attr: *const ::pthread_attr_t,
591 guardsize: *mut ::size_t) -> ::c_int;
592 pub fn pthread_attr_getstack(attr: *const ::pthread_attr_t,
593 stackaddr: *mut *mut ::c_void,
594 stacksize: *mut ::size_t) -> ::c_int;
Alex Crichtonde9736d2015-09-17 15:47:44 -0700595 pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void;
596 pub fn setgroups(ngroups: ::size_t,
597 ptr: *const ::gid_t) -> ::c_int;
Alexander Polakove09951c2015-11-26 14:00:03 +0300598 pub fn sched_setscheduler(pid: ::pid_t, policy: ::c_int, param: *const sched_param) -> ::c_int;
599 pub fn sched_getscheduler(pid: ::pid_t) -> ::c_int;
Alexander Polakov557c6702015-11-30 16:55:51 +0300600 pub fn sched_get_priority_max(policy: ::c_int) -> ::c_int;
601 pub fn sched_get_priority_min(policy: ::c_int) -> ::c_int;
Alex Crichton8dce9ad2015-12-03 11:44:14 -0800602 pub fn epoll_create(size: ::c_int) -> ::c_int;
603 pub fn epoll_ctl(epfd: ::c_int,
604 op: ::c_int,
605 fd: ::c_int,
606 event: *mut epoll_event) -> ::c_int;
607 pub fn epoll_wait(epfd: ::c_int,
608 events: *mut epoll_event,
609 maxevents: ::c_int,
610 timeout: ::c_int) -> ::c_int;
611 pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int;
612 pub fn mount(src: *const ::c_char,
613 target: *const ::c_char,
614 fstype: *const ::c_char,
615 flags: ::c_ulong,
616 data: *const ::c_void) -> ::c_int;
617 pub fn umount(target: *const ::c_char) -> ::c_int;
618 pub fn umount2(target: *const ::c_char, flags: ::c_int) -> ::c_int;
619 pub fn clone(cb: extern fn(*mut ::c_void) -> ::c_int,
620 child_stack: *mut ::c_void,
621 flags: ::c_int,
622 arg: *mut ::c_void, ...) -> ::c_int;
623 pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int;
624 pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int;
Florian Hahn6bb23a12015-12-16 12:28:51 +0100625 pub fn memrchr(cx: *const ::c_void, c: ::c_int, n: ::size_t) -> *mut ::c_void;
Alex Crichton881ef9b2015-12-01 09:04:13 -0800626 pub fn syscall(num: ::c_long, ...) -> ::c_long;
Kamal Marhubi0cfc25f2016-02-04 15:57:10 -0500627 pub fn splice(fd_in: ::c_int,
628 off_in: *mut ::loff_t,
629 fd_out: ::c_int,
630 off_out: *mut ::loff_t,
631 len: ::size_t,
632 flags: ::c_uint) -> ::ssize_t;
633 pub fn tee(fd_in: ::c_int,
634 fd_out: ::c_int,
635 len: ::size_t,
636 flags: ::c_uint) -> ::ssize_t;
637 pub fn vmsplice(fd: ::c_int,
638 iov: *const ::iovec,
639 nr_segs: ::size_t,
640 flags: ::c_uint) -> ::ssize_t;
641
Alex Crichton5d6cf052015-09-11 14:52:34 -0700642}
643
644cfg_if! {
Brian Anderson7d1d5752015-11-26 23:27:45 +0000645 if #[cfg(any(target_os = "linux",
646 target_os = "emscripten"))] {
Alex Crichton5d6cf052015-09-11 14:52:34 -0700647 mod linux;
648 pub use self::linux::*;
649 } else if #[cfg(target_os = "android")] {
650 mod android;
651 pub use self::android::*;
652 } else {
653 // ...
654 }
655}