]> git.proxmox.com Git - rustc.git/blame - src/liblibc/src/unix/notbsd/mod.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / liblibc / src / unix / notbsd / mod.rs
CommitLineData
92a42be0
SL
1use dox::mem;
2
92a42be0
SL
3pub type sa_family_t = u16;
4pub type pthread_key_t = ::c_uint;
9cc50fc6
SL
5pub type speed_t = ::c_uint;
6pub type tcflag_t = ::c_uint;
7453a54e 7pub type loff_t = ::c_longlong;
54a0048b 8pub type clockid_t = ::c_int;
92a42be0
SL
9
10pub enum timezone {}
11
12s! {
13 pub struct sockaddr {
14 pub sa_family: sa_family_t,
15 pub sa_data: [::c_char; 14],
16 }
17
18 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
38 pub struct sockaddr_storage {
39 pub ss_family: sa_family_t,
40 __ss_align: ::size_t,
41 #[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
47 pub struct addrinfo {
48 pub ai_flags: ::c_int,
49 pub ai_family: ::c_int,
50 pub ai_socktype: ::c_int,
51 pub ai_protocol: ::c_int,
52 pub ai_addrlen: socklen_t,
53
9cc50fc6 54 #[cfg(any(target_os = "linux", target_os = "emscripten"))]
92a42be0
SL
55 pub ai_addr: *mut ::sockaddr,
56
57 pub ai_canonname: *mut c_char,
58
59 #[cfg(target_os = "android")]
60 pub ai_addr: *mut ::sockaddr,
61
62 pub ai_next: *mut addrinfo,
63 }
64
54a0048b
SL
65 pub struct sockaddr_nl {
66 pub nl_family: ::sa_family_t,
67 nl_pad: ::c_ushort,
68 pub nl_pid: u32,
69 pub nl_groups: u32
70 }
71
92a42be0
SL
72 pub struct sockaddr_ll {
73 pub sll_family: ::c_ushort,
74 pub sll_protocol: ::c_ushort,
75 pub sll_ifindex: ::c_int,
76 pub sll_hatype: ::c_ushort,
77 pub sll_pkttype: ::c_uchar,
78 pub sll_halen: ::c_uchar,
79 pub sll_addr: [::c_uchar; 8]
80 }
81
82 pub struct fd_set {
83 fds_bits: [::c_ulong; FD_SETSIZE / ULONG_SIZE],
84 }
85
86 pub struct tm {
87 pub tm_sec: ::c_int,
88 pub tm_min: ::c_int,
89 pub tm_hour: ::c_int,
90 pub tm_mday: ::c_int,
91 pub tm_mon: ::c_int,
92 pub tm_year: ::c_int,
93 pub tm_wday: ::c_int,
94 pub tm_yday: ::c_int,
95 pub tm_isdst: ::c_int,
96 pub tm_gmtoff: ::c_long,
97 pub tm_zone: *const ::c_char,
98 }
9cc50fc6
SL
99
100 pub struct sched_param {
101 pub sched_priority: ::c_int,
102 #[cfg(target_env = "musl")]
103 pub sched_ss_low_priority: ::c_int,
104 #[cfg(target_env = "musl")]
105 pub sched_ss_repl_period: ::timespec,
106 #[cfg(target_env = "musl")]
107 pub sched_ss_init_budget: ::timespec,
108 #[cfg(target_env = "musl")]
109 pub sched_ss_max_repl: ::c_int,
110 }
111
112 pub struct Dl_info {
113 pub dli_fname: *const ::c_char,
114 pub dli_fbase: *mut ::c_void,
115 pub dli_sname: *const ::c_char,
116 pub dli_saddr: *mut ::c_void,
117 }
118
7453a54e
SL
119 #[cfg_attr(any(all(target_arch = "x86", not(target_env = "musl")),
120 target_arch = "x86_64"),
9cc50fc6
SL
121 repr(packed))]
122 pub struct epoll_event {
123 pub events: ::uint32_t,
124 pub u64: ::uint64_t,
125 }
126
127 pub struct utsname {
128 pub sysname: [::c_char; 65],
129 pub nodename: [::c_char; 65],
130 pub release: [::c_char; 65],
131 pub version: [::c_char; 65],
132 pub machine: [::c_char; 65],
133 pub domainname: [::c_char; 65]
134 }
54a0048b
SL
135
136 pub struct lconv {
137 pub decimal_point: *mut ::c_char,
138 pub thousands_sep: *mut ::c_char,
139 pub grouping: *mut ::c_char,
140 pub int_curr_symbol: *mut ::c_char,
141 pub currency_symbol: *mut ::c_char,
142 pub mon_decimal_point: *mut ::c_char,
143 pub mon_thousands_sep: *mut ::c_char,
144 pub mon_grouping: *mut ::c_char,
145 pub positive_sign: *mut ::c_char,
146 pub negative_sign: *mut ::c_char,
147 pub int_frac_digits: ::c_char,
148 pub frac_digits: ::c_char,
149 pub p_cs_precedes: ::c_char,
150 pub p_sep_by_space: ::c_char,
151 pub n_cs_precedes: ::c_char,
152 pub n_sep_by_space: ::c_char,
153 pub p_sign_posn: ::c_char,
154 pub n_sign_posn: ::c_char,
155 pub int_p_cs_precedes: ::c_char,
156 pub int_p_sep_by_space: ::c_char,
157 pub int_n_cs_precedes: ::c_char,
158 pub int_n_sep_by_space: ::c_char,
159 pub int_p_sign_posn: ::c_char,
160 pub int_n_sign_posn: ::c_char,
161 }
92a42be0
SL
162}
163
164// intentionally not public, only used for fd_set
54a0048b
SL
165cfg_if! {
166 if #[cfg(target_pointer_width = "32")] {
167 const ULONG_SIZE: usize = 32;
168 } else if #[cfg(target_pointer_width = "64")] {
169 const ULONG_SIZE: usize = 64;
170 } else {
171 // Unknown target_pointer_width
172 }
173}
92a42be0
SL
174
175pub const EXIT_FAILURE: ::c_int = 1;
176pub const EXIT_SUCCESS: ::c_int = 0;
177pub const RAND_MAX: ::c_int = 2147483647;
178pub const EOF: ::c_int = -1;
179pub const SEEK_SET: ::c_int = 0;
180pub const SEEK_CUR: ::c_int = 1;
181pub const SEEK_END: ::c_int = 2;
182pub const _IOFBF: ::c_int = 0;
183pub const _IONBF: ::c_int = 2;
184pub const _IOLBF: ::c_int = 1;
185
186pub const F_DUPFD: ::c_int = 0;
187pub const F_GETFD: ::c_int = 1;
188pub const F_SETFD: ::c_int = 2;
189pub const F_GETFL: ::c_int = 3;
190pub const F_SETFL: ::c_int = 4;
191
54a0048b
SL
192// Linux-specific fcntls
193pub const F_SETLEASE: ::c_int = 1024;
194pub const F_GETLEASE: ::c_int = 1025;
195pub const F_NOTIFY: ::c_int = 1026;
196pub const F_DUPFD_CLOEXEC: ::c_int = 1030;
197pub const F_SETPIPE_SZ: ::c_int = 1031;
198pub const F_GETPIPE_SZ: ::c_int = 1032;
199
200// TODO(#235): Include file sealing fcntls once we have a way to verify them.
201
92a42be0
SL
202pub const SIGTRAP: ::c_int = 5;
203
204pub const PTHREAD_CREATE_JOINABLE: ::c_int = 0;
205pub const PTHREAD_CREATE_DETACHED: ::c_int = 1;
206
54a0048b
SL
207pub const CLOCK_REALTIME: clockid_t = 0;
208pub const CLOCK_MONOTONIC: clockid_t = 1;
209pub const CLOCK_PROCESS_CPUTIME_ID: clockid_t = 2;
210pub const CLOCK_THREAD_CPUTIME_ID: clockid_t = 3;
211pub const CLOCK_MONOTONIC_RAW: clockid_t = 4;
212pub const CLOCK_REALTIME_COARSE: clockid_t = 5;
213pub const CLOCK_MONOTONIC_COARSE: clockid_t = 6;
214pub const CLOCK_BOOTTIME: clockid_t = 7;
215pub const CLOCK_REALTIME_ALARM: clockid_t = 8;
216pub const CLOCK_BOOTTIME_ALARM: clockid_t = 9;
217// TODO(#247) Someday our Travis shall have glibc 2.21 (released in Sep
218// 2014.) See also musl/mod.rs
219// pub const CLOCK_SGI_CYCLE: clockid_t = 10;
220// pub const CLOCK_TAI: clockid_t = 11;
92a42be0
SL
221
222pub const RLIMIT_CPU: ::c_int = 0;
223pub const RLIMIT_FSIZE: ::c_int = 1;
224pub const RLIMIT_DATA: ::c_int = 2;
225pub const RLIMIT_STACK: ::c_int = 3;
226pub const RLIMIT_CORE: ::c_int = 4;
227pub const RLIMIT_LOCKS: ::c_int = 10;
228pub const RLIMIT_SIGPENDING: ::c_int = 11;
229pub const RLIMIT_MSGQUEUE: ::c_int = 12;
230pub const RLIMIT_NICE: ::c_int = 13;
231pub const RLIMIT_RTPRIO: ::c_int = 14;
232
233pub const RUSAGE_SELF: ::c_int = 0;
234
235pub const O_RDONLY: ::c_int = 0;
236pub const O_WRONLY: ::c_int = 1;
237pub const O_RDWR: ::c_int = 2;
238pub const O_TRUNC: ::c_int = 512;
239pub const O_CLOEXEC: ::c_int = 0x80000;
7453a54e
SL
240
241pub const SOCK_CLOEXEC: ::c_int = O_CLOEXEC;
242
92a42be0
SL
243pub const S_IFIFO: ::mode_t = 4096;
244pub const S_IFCHR: ::mode_t = 8192;
245pub const S_IFBLK: ::mode_t = 24576;
246pub const S_IFDIR: ::mode_t = 16384;
247pub const S_IFREG: ::mode_t = 32768;
248pub const S_IFLNK: ::mode_t = 40960;
249pub const S_IFSOCK: ::mode_t = 49152;
250pub const S_IFMT: ::mode_t = 61440;
251pub const S_IRWXU: ::mode_t = 448;
252pub const S_IXUSR: ::mode_t = 64;
253pub const S_IWUSR: ::mode_t = 128;
254pub const S_IRUSR: ::mode_t = 256;
255pub const S_IRWXG: ::mode_t = 56;
256pub const S_IXGRP: ::mode_t = 8;
257pub const S_IWGRP: ::mode_t = 16;
258pub const S_IRGRP: ::mode_t = 32;
259pub const S_IRWXO: ::mode_t = 7;
260pub const S_IXOTH: ::mode_t = 1;
261pub const S_IWOTH: ::mode_t = 2;
262pub const S_IROTH: ::mode_t = 4;
263pub const F_OK: ::c_int = 0;
264pub const R_OK: ::c_int = 4;
265pub const W_OK: ::c_int = 2;
266pub const X_OK: ::c_int = 1;
267pub const STDIN_FILENO: ::c_int = 0;
268pub const STDOUT_FILENO: ::c_int = 1;
269pub const STDERR_FILENO: ::c_int = 2;
270pub const SIGHUP: ::c_int = 1;
271pub const SIGINT: ::c_int = 2;
272pub const SIGQUIT: ::c_int = 3;
273pub const SIGILL: ::c_int = 4;
274pub const SIGABRT: ::c_int = 6;
275pub const SIGFPE: ::c_int = 8;
276pub const SIGKILL: ::c_int = 9;
277pub const SIGSEGV: ::c_int = 11;
278pub const SIGPIPE: ::c_int = 13;
279pub const SIGALRM: ::c_int = 14;
280pub const SIGTERM: ::c_int = 15;
281
282pub const PROT_NONE: ::c_int = 0;
283pub const PROT_READ: ::c_int = 1;
284pub const PROT_WRITE: ::c_int = 2;
285pub const PROT_EXEC: ::c_int = 4;
286
54a0048b
SL
287pub const LC_CTYPE: ::c_int = 0;
288pub const LC_NUMERIC: ::c_int = 1;
289pub const LC_TIME: ::c_int = 2;
290pub const LC_COLLATE: ::c_int = 3;
291pub const LC_MONETARY: ::c_int = 4;
292pub const LC_MESSAGES: ::c_int = 5;
293pub const LC_ALL: ::c_int = 6;
294
92a42be0
SL
295pub const MAP_FILE: ::c_int = 0x0000;
296pub const MAP_SHARED: ::c_int = 0x0001;
297pub const MAP_PRIVATE: ::c_int = 0x0002;
298pub const MAP_FIXED: ::c_int = 0x0010;
299
300pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void;
301
302pub const MCL_CURRENT: ::c_int = 0x0001;
303pub const MCL_FUTURE: ::c_int = 0x0002;
304
54a0048b 305// MS_ flags for msync(2)
92a42be0
SL
306pub const MS_ASYNC: ::c_int = 0x0001;
307pub const MS_INVALIDATE: ::c_int = 0x0002;
308pub const MS_SYNC: ::c_int = 0x0004;
54a0048b
SL
309
310// MS_ flags for mount(2)
9cc50fc6
SL
311pub const MS_RDONLY: ::c_ulong = 0x01;
312pub const MS_NOSUID: ::c_ulong = 0x02;
313pub const MS_NODEV: ::c_ulong = 0x04;
314pub const MS_NOEXEC: ::c_ulong = 0x08;
315pub const MS_SYNCHRONOUS: ::c_ulong = 0x10;
316pub const MS_REMOUNT: ::c_ulong = 0x20;
317pub const MS_MANDLOCK: ::c_ulong = 0x40;
318pub const MS_DIRSYNC: ::c_ulong = 0x80;
319pub const MS_NOATIME: ::c_ulong = 0x0400;
320pub const MS_NODIRATIME: ::c_ulong = 0x0800;
321pub const MS_BIND: ::c_ulong = 0x1000;
322pub const MS_MOVE: ::c_ulong = 0x2000;
323pub const MS_REC: ::c_ulong = 0x4000;
324pub const MS_SILENT: ::c_ulong = 0x8000;
325pub const MS_POSIXACL: ::c_ulong = 0x010000;
326pub const MS_UNBINDABLE: ::c_ulong = 0x020000;
327pub const MS_PRIVATE: ::c_ulong = 0x040000;
328pub const MS_SLAVE: ::c_ulong = 0x080000;
329pub const MS_SHARED: ::c_ulong = 0x100000;
54a0048b
SL
330pub const MS_RELATIME: ::c_ulong = 0x200000;
331pub const MS_KERNMOUNT: ::c_ulong = 0x400000;
332pub const MS_I_VERSION: ::c_ulong = 0x800000;
333pub const MS_STRICTATIME: ::c_ulong = 0x1000000;
9cc50fc6
SL
334pub const MS_ACTIVE: ::c_ulong = 0x40000000;
335pub const MS_NOUSER: ::c_ulong = 0x80000000;
336pub const MS_MGC_VAL: ::c_ulong = 0xc0ed0000;
337pub const MS_MGC_MSK: ::c_ulong = 0xffff0000;
338pub const MS_RMT_MASK: ::c_ulong = 0x800051;
92a42be0
SL
339
340pub const EPERM: ::c_int = 1;
341pub const ENOENT: ::c_int = 2;
342pub const ESRCH: ::c_int = 3;
343pub const EINTR: ::c_int = 4;
344pub const EIO: ::c_int = 5;
345pub const ENXIO: ::c_int = 6;
346pub const E2BIG: ::c_int = 7;
347pub const ENOEXEC: ::c_int = 8;
348pub const EBADF: ::c_int = 9;
349pub const ECHILD: ::c_int = 10;
350pub const EAGAIN: ::c_int = 11;
351pub const ENOMEM: ::c_int = 12;
352pub const EACCES: ::c_int = 13;
353pub const EFAULT: ::c_int = 14;
354pub const ENOTBLK: ::c_int = 15;
355pub const EBUSY: ::c_int = 16;
356pub const EEXIST: ::c_int = 17;
357pub const EXDEV: ::c_int = 18;
358pub const ENODEV: ::c_int = 19;
359pub const ENOTDIR: ::c_int = 20;
360pub const EISDIR: ::c_int = 21;
361pub const EINVAL: ::c_int = 22;
362pub const ENFILE: ::c_int = 23;
363pub const EMFILE: ::c_int = 24;
364pub const ENOTTY: ::c_int = 25;
365pub const ETXTBSY: ::c_int = 26;
366pub const EFBIG: ::c_int = 27;
367pub const ENOSPC: ::c_int = 28;
368pub const ESPIPE: ::c_int = 29;
369pub const EROFS: ::c_int = 30;
370pub const EMLINK: ::c_int = 31;
371pub const EPIPE: ::c_int = 32;
372pub const EDOM: ::c_int = 33;
373pub const ERANGE: ::c_int = 34;
374pub const EWOULDBLOCK: ::c_int = EAGAIN;
375
376pub const EBFONT: ::c_int = 59;
377pub const ENOSTR: ::c_int = 60;
378pub const ENODATA: ::c_int = 61;
379pub const ETIME: ::c_int = 62;
380pub const ENOSR: ::c_int = 63;
381pub const ENONET: ::c_int = 64;
382pub const ENOPKG: ::c_int = 65;
383pub const EREMOTE: ::c_int = 66;
384pub const ENOLINK: ::c_int = 67;
385pub const EADV: ::c_int = 68;
386pub const ESRMNT: ::c_int = 69;
387pub const ECOMM: ::c_int = 70;
388pub const EPROTO: ::c_int = 71;
389pub const EDOTDOT: ::c_int = 73;
390
391pub const AF_PACKET: ::c_int = 17;
392pub const IPPROTO_RAW: ::c_int = 255;
393
394pub const PROT_GROWSDOWN: ::c_int = 0x1000000;
395pub const PROT_GROWSUP: ::c_int = 0x2000000;
396
397pub const MAP_TYPE: ::c_int = 0x000f;
398
399pub const MADV_NORMAL: ::c_int = 0;
400pub const MADV_RANDOM: ::c_int = 1;
401pub const MADV_SEQUENTIAL: ::c_int = 2;
402pub const MADV_WILLNEED: ::c_int = 3;
403pub const MADV_DONTNEED: ::c_int = 4;
404pub const MADV_REMOVE: ::c_int = 9;
405pub const MADV_DONTFORK: ::c_int = 10;
406pub const MADV_DOFORK: ::c_int = 11;
407pub const MADV_MERGEABLE: ::c_int = 12;
408pub const MADV_UNMERGEABLE: ::c_int = 13;
409pub const MADV_HWPOISON: ::c_int = 100;
410
411pub const IFF_LOOPBACK: ::c_int = 0x8;
412
413pub const AF_UNIX: ::c_int = 1;
414pub const AF_INET: ::c_int = 2;
415pub const AF_INET6: ::c_int = 10;
416pub const SOCK_RAW: ::c_int = 3;
417pub const IPPROTO_TCP: ::c_int = 6;
418pub const IPPROTO_IP: ::c_int = 0;
419pub const IPPROTO_IPV6: ::c_int = 41;
420pub const IP_MULTICAST_TTL: ::c_int = 33;
421pub const IP_MULTICAST_LOOP: ::c_int = 34;
422pub const IP_TTL: ::c_int = 2;
423pub const IP_HDRINCL: ::c_int = 3;
424pub const IP_ADD_MEMBERSHIP: ::c_int = 35;
425pub const IP_DROP_MEMBERSHIP: ::c_int = 36;
7453a54e 426pub const IP_TRANSPARENT: ::c_int = 19;
92a42be0
SL
427pub const IPV6_ADD_MEMBERSHIP: ::c_int = 20;
428pub const IPV6_DROP_MEMBERSHIP: ::c_int = 21;
429
430pub const TCP_NODELAY: ::c_int = 1;
431pub const TCP_MAXSEG: ::c_int = 2;
432pub const TCP_CORK: ::c_int = 3;
433pub const TCP_KEEPIDLE: ::c_int = 4;
434pub const TCP_KEEPINTVL: ::c_int = 5;
435pub const TCP_KEEPCNT: ::c_int = 6;
436pub const TCP_SYNCNT: ::c_int = 7;
437pub const TCP_LINGER2: ::c_int = 8;
438pub const TCP_DEFER_ACCEPT: ::c_int = 9;
439pub const TCP_WINDOW_CLAMP: ::c_int = 10;
440pub const TCP_INFO: ::c_int = 11;
441pub const TCP_QUICKACK: ::c_int = 12;
442pub const TCP_CONGESTION: ::c_int = 13;
443
444pub const IPV6_MULTICAST_LOOP: ::c_int = 19;
445pub const IPV6_V6ONLY: ::c_int = 26;
446
447pub const SO_DEBUG: ::c_int = 1;
448
449pub const SHUT_RD: ::c_int = 0;
450pub const SHUT_WR: ::c_int = 1;
451pub const SHUT_RDWR: ::c_int = 2;
452
453pub const LOCK_SH: ::c_int = 1;
454pub const LOCK_EX: ::c_int = 2;
455pub const LOCK_NB: ::c_int = 4;
456pub const LOCK_UN: ::c_int = 8;
457
458pub const SIGSTKSZ: ::size_t = 8192;
459
460pub const SA_NODEFER: ::c_int = 0x40000000;
461pub const SA_RESETHAND: ::c_int = 0x80000000;
462pub const SA_RESTART: ::c_int = 0x10000000;
463pub const SA_NOCLDSTOP: ::c_int = 0x00000001;
464
7453a54e
SL
465pub const SS_ONSTACK: ::c_int = 1;
466pub const SS_DISABLE: ::c_int = 2;
467
9cc50fc6
SL
468pub const PATH_MAX: ::c_int = 4096;
469
92a42be0
SL
470pub const FD_SETSIZE: usize = 1024;
471
9cc50fc6
SL
472pub const EPOLLIN: ::c_int = 0x1;
473pub const EPOLLPRI: ::c_int = 0x2;
474pub const EPOLLOUT: ::c_int = 0x4;
475pub const EPOLLRDNORM: ::c_int = 0x40;
476pub const EPOLLRDBAND: ::c_int = 0x80;
477pub const EPOLLWRNORM: ::c_int = 0x100;
478pub const EPOLLWRBAND: ::c_int = 0x200;
479pub const EPOLLMSG: ::c_int = 0x400;
480pub const EPOLLERR: ::c_int = 0x8;
481pub const EPOLLHUP: ::c_int = 0x10;
482pub const EPOLLET: ::c_int = 0x80000000;
483
484pub const EPOLL_CTL_ADD: ::c_int = 1;
485pub const EPOLL_CTL_MOD: ::c_int = 3;
486pub const EPOLL_CTL_DEL: ::c_int = 2;
487
488pub const MNT_DETACH: ::c_int = 0x2;
489pub const MNT_EXPIRE: ::c_int = 0x4;
490
491pub const Q_GETFMT: ::c_int = 0x800004;
492pub const Q_GETINFO: ::c_int = 0x800005;
493pub const Q_SETINFO: ::c_int = 0x800006;
494pub const QIF_BLIMITS: ::uint32_t = 1;
495pub const QIF_SPACE: ::uint32_t = 2;
496pub const QIF_ILIMITS: ::uint32_t = 4;
497pub const QIF_INODES: ::uint32_t = 8;
498pub const QIF_BTIME: ::uint32_t = 16;
499pub const QIF_ITIME: ::uint32_t = 32;
500pub const QIF_LIMITS: ::uint32_t = 5;
501pub const QIF_USAGE: ::uint32_t = 10;
502pub const QIF_TIMES: ::uint32_t = 48;
503pub const QIF_ALL: ::uint32_t = 63;
504
505pub const CBAUD: ::tcflag_t = 0o0010017;
506
507pub const EFD_CLOEXEC: ::c_int = 0x80000;
508
9cc50fc6
SL
509pub const MNT_FORCE: ::c_int = 0x1;
510
511pub const Q_SYNC: ::c_int = 0x800001;
512pub const Q_QUOTAON: ::c_int = 0x800002;
513pub const Q_QUOTAOFF: ::c_int = 0x800003;
514pub const Q_GETQUOTA: ::c_int = 0x800007;
515pub const Q_SETQUOTA: ::c_int = 0x800008;
516
517pub const TCIOFF: ::c_int = 2;
518pub const TCION: ::c_int = 3;
519pub const TCOOFF: ::c_int = 0;
520pub const TCOON: ::c_int = 1;
521pub const TCIFLUSH: ::c_int = 0;
522pub const TCOFLUSH: ::c_int = 1;
523pub const TCIOFLUSH: ::c_int = 2;
524pub const NL0: ::c_int = 0x00000000;
525pub const NL1: ::c_int = 0x00000100;
526pub const TAB0: ::c_int = 0x00000000;
527pub const TAB1: ::c_int = 0x00000800;
528pub const TAB2: ::c_int = 0x00001000;
529pub const TAB3: ::c_int = 0x00001800;
530pub const CR0: ::c_int = 0x00000000;
531pub const CR1: ::c_int = 0x00000200;
532pub const CR2: ::c_int = 0x00000400;
533pub const CR3: ::c_int = 0x00000600;
534pub const FF0: ::c_int = 0x00000000;
535pub const FF1: ::c_int = 0x00008000;
536pub const BS0: ::c_int = 0x00000000;
537pub const BS1: ::c_int = 0x00002000;
538pub const VT0: ::c_int = 0x00000000;
539pub const VT1: ::c_int = 0x00004000;
540pub const VERASE: usize = 2;
541pub const VWERASE: usize = 14;
542pub const VKILL: usize = 3;
543pub const VREPRINT: usize = 12;
544pub const VINTR: usize = 0;
545pub const VQUIT: usize = 1;
546pub const VSUSP: usize = 10;
547pub const VSTART: usize = 8;
548pub const VSTOP: usize = 9;
549pub const VLNEXT: usize = 15;
550pub const VDISCARD: usize = 13;
551pub const VTIME: usize = 5;
552pub const IGNBRK: ::tcflag_t = 0x00000001;
553pub const BRKINT: ::tcflag_t = 0x00000002;
554pub const IGNPAR: ::tcflag_t = 0x00000004;
555pub const PARMRK: ::tcflag_t = 0x00000008;
556pub const INPCK: ::tcflag_t = 0x00000010;
557pub const ISTRIP: ::tcflag_t = 0x00000020;
558pub const INLCR: ::tcflag_t = 0x00000040;
559pub const IGNCR: ::tcflag_t = 0x00000080;
560pub const ICRNL: ::tcflag_t = 0x00000100;
561pub const IXON: ::tcflag_t = 0x00000400;
562pub const IXOFF: ::tcflag_t = 0x00001000;
563pub const IXANY: ::tcflag_t = 0x00000800;
564pub const IMAXBEL: ::tcflag_t = 0x00002000;
565pub const OPOST: ::tcflag_t = 0x1;
566pub const ONLCR: ::tcflag_t = 0x4;
567pub const CSIZE: ::tcflag_t = 0x00000030;
568pub const CS5: ::tcflag_t = 0x00000000;
569pub const CS6: ::tcflag_t = 0x00000010;
570pub const CS7: ::tcflag_t = 0x00000020;
571pub const CS8: ::tcflag_t = 0x00000030;
572pub const CSTOPB: ::tcflag_t = 0x00000040;
573pub const CREAD: ::tcflag_t = 0x00000080;
574pub const PARENB: ::tcflag_t = 0x00000100;
575pub const PARODD: ::tcflag_t = 0x00000200;
576pub const HUPCL: ::tcflag_t = 0x00000400;
577pub const CLOCAL: ::tcflag_t = 0x00000800;
578pub const CRTSCTS: ::tcflag_t = 0x80000000;
579pub const ECHOKE: ::tcflag_t = 0x00000800;
580pub const ECHOE: ::tcflag_t = 0x00000010;
581pub const ECHOK: ::tcflag_t = 0x00000020;
582pub const ECHO: ::tcflag_t = 0x00000008;
583pub const ECHONL: ::tcflag_t = 0x00000040;
584pub const ECHOPRT: ::tcflag_t = 0x00000400;
585pub const ECHOCTL: ::tcflag_t = 0x00000200;
586pub const ISIG: ::tcflag_t = 0x00000001;
587pub const ICANON: ::tcflag_t = 0x00000002;
588pub const PENDIN: ::tcflag_t = 0x00004000;
589pub const NOFLSH: ::tcflag_t = 0x00000080;
590
591pub const CLONE_VM: ::c_int = 0x100;
592pub const CLONE_FS: ::c_int = 0x200;
593pub const CLONE_FILES: ::c_int = 0x400;
594pub const CLONE_SIGHAND: ::c_int = 0x800;
595pub const CLONE_PTRACE: ::c_int = 0x2000;
596pub const CLONE_VFORK: ::c_int = 0x4000;
597pub const CLONE_PARENT: ::c_int = 0x8000;
598pub const CLONE_THREAD: ::c_int = 0x10000;
599pub const CLONE_NEWNS: ::c_int = 0x20000;
600pub const CLONE_SYSVSEM: ::c_int = 0x40000;
601pub const CLONE_SETTLS: ::c_int = 0x80000;
602pub const CLONE_PARENT_SETTID: ::c_int = 0x100000;
603pub const CLONE_CHILD_CLEARTID: ::c_int = 0x200000;
604pub const CLONE_DETACHED: ::c_int = 0x400000;
605pub const CLONE_UNTRACED: ::c_int = 0x800000;
606pub const CLONE_CHILD_SETTID: ::c_int = 0x01000000;
54a0048b
SL
607pub const CLONE_NEWUTS: ::c_int = 0x04000000;
608pub const CLONE_NEWIPC: ::c_int = 0x08000000;
609pub const CLONE_NEWUSER: ::c_int = 0x10000000;
610pub const CLONE_NEWPID: ::c_int = 0x20000000;
611pub const CLONE_NEWNET: ::c_int = 0x40000000;
612pub const CLONE_IO: ::c_int = 0x80000000;
9cc50fc6 613
7453a54e
SL
614pub const WNOHANG: ::c_int = 1;
615
616pub const SPLICE_F_MOVE: ::c_uint = 0x01;
617pub const SPLICE_F_NONBLOCK: ::c_uint = 0x02;
618pub const SPLICE_F_MORE: ::c_uint = 0x04;
619pub const SPLICE_F_GIFT: ::c_uint = 0x08;
620
621pub const RTLD_LOCAL: ::c_int = 0;
622
623pub const POSIX_FADV_NORMAL: ::c_int = 0;
624pub const POSIX_FADV_RANDOM: ::c_int = 1;
625pub const POSIX_FADV_SEQUENTIAL: ::c_int = 2;
626pub const POSIX_FADV_WILLNEED: ::c_int = 3;
627pub const POSIX_FADV_DONTNEED: ::c_int = 4;
628pub const POSIX_FADV_NOREUSE: ::c_int = 5;
629
54a0048b
SL
630pub const AT_FDCWD: ::c_int = -100;
631pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x100;
632
92a42be0
SL
633f! {
634 pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () {
635 let fd = fd as usize;
636 let size = mem::size_of_val(&(*set).fds_bits[0]) * 8;
637 (*set).fds_bits[fd / size] &= !(1 << (fd % size));
638 return
639 }
640
641 pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool {
642 let fd = fd as usize;
643 let size = mem::size_of_val(&(*set).fds_bits[0]) * 8;
644 return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0
645 }
646
647 pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () {
648 let fd = fd as usize;
649 let size = mem::size_of_val(&(*set).fds_bits[0]) * 8;
650 (*set).fds_bits[fd / size] |= 1 << (fd % size);
651 return
652 }
653
654 pub fn FD_ZERO(set: *mut fd_set) -> () {
655 for slot in (*set).fds_bits.iter_mut() {
656 *slot = 0;
657 }
658 }
659
660 pub fn WIFEXITED(status: ::c_int) -> bool {
661 (status & 0xff) == 0
662 }
663
664 pub fn WEXITSTATUS(status: ::c_int) -> ::c_int {
665 (status >> 8) & 0xff
666 }
667
668 pub fn WTERMSIG(status: ::c_int) -> ::c_int {
669 status & 0x7f
670 }
671}
672
673extern {
7453a54e
SL
674 pub fn getpwuid_r(uid: ::uid_t,
675 pwd: *mut passwd,
676 buf: *mut ::c_char,
677 buflen: ::size_t,
678 result: *mut *mut passwd) -> ::c_int;
92a42be0
SL
679 pub fn fdatasync(fd: ::c_int) -> ::c_int;
680 pub fn mincore(addr: *mut ::c_void, len: ::size_t,
681 vec: *mut ::c_uchar) -> ::c_int;
54a0048b
SL
682 pub fn clock_getres(clk_id: clockid_t, tp: *mut ::timespec) -> ::c_int;
683 pub fn clock_gettime(clk_id: clockid_t, tp: *mut ::timespec) -> ::c_int;
92a42be0
SL
684 pub fn prctl(option: ::c_int, ...) -> ::c_int;
685 pub fn pthread_getattr_np(native: ::pthread_t,
686 attr: *mut ::pthread_attr_t) -> ::c_int;
687 pub fn pthread_attr_getguardsize(attr: *const ::pthread_attr_t,
688 guardsize: *mut ::size_t) -> ::c_int;
689 pub fn pthread_attr_getstack(attr: *const ::pthread_attr_t,
690 stackaddr: *mut *mut ::c_void,
691 stacksize: *mut ::size_t) -> ::c_int;
692 pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void;
693 pub fn setgroups(ngroups: ::size_t,
694 ptr: *const ::gid_t) -> ::c_int;
54a0048b
SL
695 pub fn sched_setscheduler(pid: ::pid_t,
696 policy: ::c_int,
697 param: *const sched_param) -> ::c_int;
9cc50fc6
SL
698 pub fn sched_getscheduler(pid: ::pid_t) -> ::c_int;
699 pub fn sched_get_priority_max(policy: ::c_int) -> ::c_int;
700 pub fn sched_get_priority_min(policy: ::c_int) -> ::c_int;
701 pub fn epoll_create(size: ::c_int) -> ::c_int;
702 pub fn epoll_ctl(epfd: ::c_int,
703 op: ::c_int,
704 fd: ::c_int,
705 event: *mut epoll_event) -> ::c_int;
706 pub fn epoll_wait(epfd: ::c_int,
707 events: *mut epoll_event,
708 maxevents: ::c_int,
709 timeout: ::c_int) -> ::c_int;
710 pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int;
711 pub fn mount(src: *const ::c_char,
712 target: *const ::c_char,
713 fstype: *const ::c_char,
714 flags: ::c_ulong,
715 data: *const ::c_void) -> ::c_int;
716 pub fn umount(target: *const ::c_char) -> ::c_int;
717 pub fn umount2(target: *const ::c_char, flags: ::c_int) -> ::c_int;
718 pub fn clone(cb: extern fn(*mut ::c_void) -> ::c_int,
719 child_stack: *mut ::c_void,
720 flags: ::c_int,
721 arg: *mut ::c_void, ...) -> ::c_int;
722 pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int;
723 pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int;
54a0048b
SL
724 pub fn memrchr(cx: *const ::c_void,
725 c: ::c_int,
726 n: ::size_t) -> *mut ::c_void;
9cc50fc6 727 pub fn syscall(num: ::c_long, ...) -> ::c_long;
7453a54e
SL
728 pub fn sendfile(out_fd: ::c_int,
729 in_fd: ::c_int,
730 offset: *mut off_t,
731 count: ::size_t) -> ::ssize_t;
732 pub fn splice(fd_in: ::c_int,
733 off_in: *mut ::loff_t,
734 fd_out: ::c_int,
735 off_out: *mut ::loff_t,
736 len: ::size_t,
737 flags: ::c_uint) -> ::ssize_t;
738 pub fn tee(fd_in: ::c_int,
739 fd_out: ::c_int,
740 len: ::size_t,
741 flags: ::c_uint) -> ::ssize_t;
742 pub fn vmsplice(fd: ::c_int,
743 iov: *const ::iovec,
744 nr_segs: ::size_t,
745 flags: ::c_uint) -> ::ssize_t;
746
54a0048b 747 pub fn posix_fadvise(fd: ::c_int, offset: ::off_t, len: ::off_t,
7453a54e 748 advise: ::c_int) -> ::c_int;
54a0048b
SL
749 pub fn futimens(fd: ::c_int, times: *const ::timespec) -> ::c_int;
750 pub fn utimensat(dirfd: ::c_int, path: *const ::c_char,
751 times: *const ::timespec, flag: ::c_int) -> ::c_int;
92a42be0
SL
752}
753
754cfg_if! {
9cc50fc6
SL
755 if #[cfg(any(target_os = "linux",
756 target_os = "emscripten"))] {
92a42be0
SL
757 mod linux;
758 pub use self::linux::*;
759 } else if #[cfg(target_os = "android")] {
760 mod android;
761 pub use self::android::*;
762 } else {
54a0048b 763 // Unknown target_os
92a42be0
SL
764 }
765}