]> git.proxmox.com Git - rustc.git/blob - src/liblibc/src/unix/notbsd/mod.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / liblibc / src / unix / notbsd / mod.rs
1 use dox::mem;
2
3 pub type sa_family_t = u16;
4 pub type pthread_key_t = ::c_uint;
5 pub type speed_t = ::c_uint;
6 pub type tcflag_t = ::c_uint;
7 pub type loff_t = ::c_longlong;
8 pub type clockid_t = ::c_int;
9
10 pub enum timezone {}
11
12 s! {
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
54 #[cfg(any(target_os = "linux", target_os = "emscripten"))]
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
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
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 }
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
119 #[cfg_attr(any(all(target_arch = "x86", not(target_env = "musl")),
120 target_arch = "x86_64"),
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 }
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 }
162 }
163
164 // intentionally not public, only used for fd_set
165 cfg_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 }
174
175 pub const EXIT_FAILURE: ::c_int = 1;
176 pub const EXIT_SUCCESS: ::c_int = 0;
177 pub const RAND_MAX: ::c_int = 2147483647;
178 pub const EOF: ::c_int = -1;
179 pub const SEEK_SET: ::c_int = 0;
180 pub const SEEK_CUR: ::c_int = 1;
181 pub const SEEK_END: ::c_int = 2;
182 pub const _IOFBF: ::c_int = 0;
183 pub const _IONBF: ::c_int = 2;
184 pub const _IOLBF: ::c_int = 1;
185
186 pub const F_DUPFD: ::c_int = 0;
187 pub const F_GETFD: ::c_int = 1;
188 pub const F_SETFD: ::c_int = 2;
189 pub const F_GETFL: ::c_int = 3;
190 pub const F_SETFL: ::c_int = 4;
191
192 // Linux-specific fcntls
193 pub const F_SETLEASE: ::c_int = 1024;
194 pub const F_GETLEASE: ::c_int = 1025;
195 pub const F_NOTIFY: ::c_int = 1026;
196 pub const F_DUPFD_CLOEXEC: ::c_int = 1030;
197 pub const F_SETPIPE_SZ: ::c_int = 1031;
198 pub const F_GETPIPE_SZ: ::c_int = 1032;
199
200 // TODO(#235): Include file sealing fcntls once we have a way to verify them.
201
202 pub const SIGTRAP: ::c_int = 5;
203
204 pub const PTHREAD_CREATE_JOINABLE: ::c_int = 0;
205 pub const PTHREAD_CREATE_DETACHED: ::c_int = 1;
206
207 pub const CLOCK_REALTIME: clockid_t = 0;
208 pub const CLOCK_MONOTONIC: clockid_t = 1;
209 pub const CLOCK_PROCESS_CPUTIME_ID: clockid_t = 2;
210 pub const CLOCK_THREAD_CPUTIME_ID: clockid_t = 3;
211 pub const CLOCK_MONOTONIC_RAW: clockid_t = 4;
212 pub const CLOCK_REALTIME_COARSE: clockid_t = 5;
213 pub const CLOCK_MONOTONIC_COARSE: clockid_t = 6;
214 pub const CLOCK_BOOTTIME: clockid_t = 7;
215 pub const CLOCK_REALTIME_ALARM: clockid_t = 8;
216 pub 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;
221
222 pub const RLIMIT_CPU: ::c_int = 0;
223 pub const RLIMIT_FSIZE: ::c_int = 1;
224 pub const RLIMIT_DATA: ::c_int = 2;
225 pub const RLIMIT_STACK: ::c_int = 3;
226 pub const RLIMIT_CORE: ::c_int = 4;
227 pub const RLIMIT_LOCKS: ::c_int = 10;
228 pub const RLIMIT_SIGPENDING: ::c_int = 11;
229 pub const RLIMIT_MSGQUEUE: ::c_int = 12;
230 pub const RLIMIT_NICE: ::c_int = 13;
231 pub const RLIMIT_RTPRIO: ::c_int = 14;
232
233 pub const RUSAGE_SELF: ::c_int = 0;
234
235 pub const O_RDONLY: ::c_int = 0;
236 pub const O_WRONLY: ::c_int = 1;
237 pub const O_RDWR: ::c_int = 2;
238 pub const O_TRUNC: ::c_int = 512;
239 pub const O_CLOEXEC: ::c_int = 0x80000;
240
241 pub const SOCK_CLOEXEC: ::c_int = O_CLOEXEC;
242
243 pub const S_IFIFO: ::mode_t = 4096;
244 pub const S_IFCHR: ::mode_t = 8192;
245 pub const S_IFBLK: ::mode_t = 24576;
246 pub const S_IFDIR: ::mode_t = 16384;
247 pub const S_IFREG: ::mode_t = 32768;
248 pub const S_IFLNK: ::mode_t = 40960;
249 pub const S_IFSOCK: ::mode_t = 49152;
250 pub const S_IFMT: ::mode_t = 61440;
251 pub const S_IRWXU: ::mode_t = 448;
252 pub const S_IXUSR: ::mode_t = 64;
253 pub const S_IWUSR: ::mode_t = 128;
254 pub const S_IRUSR: ::mode_t = 256;
255 pub const S_IRWXG: ::mode_t = 56;
256 pub const S_IXGRP: ::mode_t = 8;
257 pub const S_IWGRP: ::mode_t = 16;
258 pub const S_IRGRP: ::mode_t = 32;
259 pub const S_IRWXO: ::mode_t = 7;
260 pub const S_IXOTH: ::mode_t = 1;
261 pub const S_IWOTH: ::mode_t = 2;
262 pub const S_IROTH: ::mode_t = 4;
263 pub const F_OK: ::c_int = 0;
264 pub const R_OK: ::c_int = 4;
265 pub const W_OK: ::c_int = 2;
266 pub const X_OK: ::c_int = 1;
267 pub const STDIN_FILENO: ::c_int = 0;
268 pub const STDOUT_FILENO: ::c_int = 1;
269 pub const STDERR_FILENO: ::c_int = 2;
270 pub const SIGHUP: ::c_int = 1;
271 pub const SIGINT: ::c_int = 2;
272 pub const SIGQUIT: ::c_int = 3;
273 pub const SIGILL: ::c_int = 4;
274 pub const SIGABRT: ::c_int = 6;
275 pub const SIGFPE: ::c_int = 8;
276 pub const SIGKILL: ::c_int = 9;
277 pub const SIGSEGV: ::c_int = 11;
278 pub const SIGPIPE: ::c_int = 13;
279 pub const SIGALRM: ::c_int = 14;
280 pub const SIGTERM: ::c_int = 15;
281
282 pub const PROT_NONE: ::c_int = 0;
283 pub const PROT_READ: ::c_int = 1;
284 pub const PROT_WRITE: ::c_int = 2;
285 pub const PROT_EXEC: ::c_int = 4;
286
287 pub const LC_CTYPE: ::c_int = 0;
288 pub const LC_NUMERIC: ::c_int = 1;
289 pub const LC_TIME: ::c_int = 2;
290 pub const LC_COLLATE: ::c_int = 3;
291 pub const LC_MONETARY: ::c_int = 4;
292 pub const LC_MESSAGES: ::c_int = 5;
293 pub const LC_ALL: ::c_int = 6;
294
295 pub const MAP_FILE: ::c_int = 0x0000;
296 pub const MAP_SHARED: ::c_int = 0x0001;
297 pub const MAP_PRIVATE: ::c_int = 0x0002;
298 pub const MAP_FIXED: ::c_int = 0x0010;
299
300 pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void;
301
302 pub const MCL_CURRENT: ::c_int = 0x0001;
303 pub const MCL_FUTURE: ::c_int = 0x0002;
304
305 // MS_ flags for msync(2)
306 pub const MS_ASYNC: ::c_int = 0x0001;
307 pub const MS_INVALIDATE: ::c_int = 0x0002;
308 pub const MS_SYNC: ::c_int = 0x0004;
309
310 // MS_ flags for mount(2)
311 pub const MS_RDONLY: ::c_ulong = 0x01;
312 pub const MS_NOSUID: ::c_ulong = 0x02;
313 pub const MS_NODEV: ::c_ulong = 0x04;
314 pub const MS_NOEXEC: ::c_ulong = 0x08;
315 pub const MS_SYNCHRONOUS: ::c_ulong = 0x10;
316 pub const MS_REMOUNT: ::c_ulong = 0x20;
317 pub const MS_MANDLOCK: ::c_ulong = 0x40;
318 pub const MS_DIRSYNC: ::c_ulong = 0x80;
319 pub const MS_NOATIME: ::c_ulong = 0x0400;
320 pub const MS_NODIRATIME: ::c_ulong = 0x0800;
321 pub const MS_BIND: ::c_ulong = 0x1000;
322 pub const MS_MOVE: ::c_ulong = 0x2000;
323 pub const MS_REC: ::c_ulong = 0x4000;
324 pub const MS_SILENT: ::c_ulong = 0x8000;
325 pub const MS_POSIXACL: ::c_ulong = 0x010000;
326 pub const MS_UNBINDABLE: ::c_ulong = 0x020000;
327 pub const MS_PRIVATE: ::c_ulong = 0x040000;
328 pub const MS_SLAVE: ::c_ulong = 0x080000;
329 pub const MS_SHARED: ::c_ulong = 0x100000;
330 pub const MS_RELATIME: ::c_ulong = 0x200000;
331 pub const MS_KERNMOUNT: ::c_ulong = 0x400000;
332 pub const MS_I_VERSION: ::c_ulong = 0x800000;
333 pub const MS_STRICTATIME: ::c_ulong = 0x1000000;
334 pub const MS_ACTIVE: ::c_ulong = 0x40000000;
335 pub const MS_NOUSER: ::c_ulong = 0x80000000;
336 pub const MS_MGC_VAL: ::c_ulong = 0xc0ed0000;
337 pub const MS_MGC_MSK: ::c_ulong = 0xffff0000;
338 pub const MS_RMT_MASK: ::c_ulong = 0x800051;
339
340 pub const EPERM: ::c_int = 1;
341 pub const ENOENT: ::c_int = 2;
342 pub const ESRCH: ::c_int = 3;
343 pub const EINTR: ::c_int = 4;
344 pub const EIO: ::c_int = 5;
345 pub const ENXIO: ::c_int = 6;
346 pub const E2BIG: ::c_int = 7;
347 pub const ENOEXEC: ::c_int = 8;
348 pub const EBADF: ::c_int = 9;
349 pub const ECHILD: ::c_int = 10;
350 pub const EAGAIN: ::c_int = 11;
351 pub const ENOMEM: ::c_int = 12;
352 pub const EACCES: ::c_int = 13;
353 pub const EFAULT: ::c_int = 14;
354 pub const ENOTBLK: ::c_int = 15;
355 pub const EBUSY: ::c_int = 16;
356 pub const EEXIST: ::c_int = 17;
357 pub const EXDEV: ::c_int = 18;
358 pub const ENODEV: ::c_int = 19;
359 pub const ENOTDIR: ::c_int = 20;
360 pub const EISDIR: ::c_int = 21;
361 pub const EINVAL: ::c_int = 22;
362 pub const ENFILE: ::c_int = 23;
363 pub const EMFILE: ::c_int = 24;
364 pub const ENOTTY: ::c_int = 25;
365 pub const ETXTBSY: ::c_int = 26;
366 pub const EFBIG: ::c_int = 27;
367 pub const ENOSPC: ::c_int = 28;
368 pub const ESPIPE: ::c_int = 29;
369 pub const EROFS: ::c_int = 30;
370 pub const EMLINK: ::c_int = 31;
371 pub const EPIPE: ::c_int = 32;
372 pub const EDOM: ::c_int = 33;
373 pub const ERANGE: ::c_int = 34;
374 pub const EWOULDBLOCK: ::c_int = EAGAIN;
375
376 pub const EBFONT: ::c_int = 59;
377 pub const ENOSTR: ::c_int = 60;
378 pub const ENODATA: ::c_int = 61;
379 pub const ETIME: ::c_int = 62;
380 pub const ENOSR: ::c_int = 63;
381 pub const ENONET: ::c_int = 64;
382 pub const ENOPKG: ::c_int = 65;
383 pub const EREMOTE: ::c_int = 66;
384 pub const ENOLINK: ::c_int = 67;
385 pub const EADV: ::c_int = 68;
386 pub const ESRMNT: ::c_int = 69;
387 pub const ECOMM: ::c_int = 70;
388 pub const EPROTO: ::c_int = 71;
389 pub const EDOTDOT: ::c_int = 73;
390
391 pub const AF_PACKET: ::c_int = 17;
392 pub const IPPROTO_RAW: ::c_int = 255;
393
394 pub const PROT_GROWSDOWN: ::c_int = 0x1000000;
395 pub const PROT_GROWSUP: ::c_int = 0x2000000;
396
397 pub const MAP_TYPE: ::c_int = 0x000f;
398
399 pub const MADV_NORMAL: ::c_int = 0;
400 pub const MADV_RANDOM: ::c_int = 1;
401 pub const MADV_SEQUENTIAL: ::c_int = 2;
402 pub const MADV_WILLNEED: ::c_int = 3;
403 pub const MADV_DONTNEED: ::c_int = 4;
404 pub const MADV_REMOVE: ::c_int = 9;
405 pub const MADV_DONTFORK: ::c_int = 10;
406 pub const MADV_DOFORK: ::c_int = 11;
407 pub const MADV_MERGEABLE: ::c_int = 12;
408 pub const MADV_UNMERGEABLE: ::c_int = 13;
409 pub const MADV_HWPOISON: ::c_int = 100;
410
411 pub const IFF_LOOPBACK: ::c_int = 0x8;
412
413 pub const AF_UNIX: ::c_int = 1;
414 pub const AF_INET: ::c_int = 2;
415 pub const AF_INET6: ::c_int = 10;
416 pub const SOCK_RAW: ::c_int = 3;
417 pub const IPPROTO_TCP: ::c_int = 6;
418 pub const IPPROTO_IP: ::c_int = 0;
419 pub const IPPROTO_IPV6: ::c_int = 41;
420 pub const IP_MULTICAST_TTL: ::c_int = 33;
421 pub const IP_MULTICAST_LOOP: ::c_int = 34;
422 pub const IP_TTL: ::c_int = 2;
423 pub const IP_HDRINCL: ::c_int = 3;
424 pub const IP_ADD_MEMBERSHIP: ::c_int = 35;
425 pub const IP_DROP_MEMBERSHIP: ::c_int = 36;
426 pub const IP_TRANSPARENT: ::c_int = 19;
427 pub const IPV6_ADD_MEMBERSHIP: ::c_int = 20;
428 pub const IPV6_DROP_MEMBERSHIP: ::c_int = 21;
429
430 pub const TCP_NODELAY: ::c_int = 1;
431 pub const TCP_MAXSEG: ::c_int = 2;
432 pub const TCP_CORK: ::c_int = 3;
433 pub const TCP_KEEPIDLE: ::c_int = 4;
434 pub const TCP_KEEPINTVL: ::c_int = 5;
435 pub const TCP_KEEPCNT: ::c_int = 6;
436 pub const TCP_SYNCNT: ::c_int = 7;
437 pub const TCP_LINGER2: ::c_int = 8;
438 pub const TCP_DEFER_ACCEPT: ::c_int = 9;
439 pub const TCP_WINDOW_CLAMP: ::c_int = 10;
440 pub const TCP_INFO: ::c_int = 11;
441 pub const TCP_QUICKACK: ::c_int = 12;
442 pub const TCP_CONGESTION: ::c_int = 13;
443
444 pub const IPV6_MULTICAST_LOOP: ::c_int = 19;
445 pub const IPV6_V6ONLY: ::c_int = 26;
446
447 pub const SO_DEBUG: ::c_int = 1;
448
449 pub const SHUT_RD: ::c_int = 0;
450 pub const SHUT_WR: ::c_int = 1;
451 pub const SHUT_RDWR: ::c_int = 2;
452
453 pub const LOCK_SH: ::c_int = 1;
454 pub const LOCK_EX: ::c_int = 2;
455 pub const LOCK_NB: ::c_int = 4;
456 pub const LOCK_UN: ::c_int = 8;
457
458 pub const SIGSTKSZ: ::size_t = 8192;
459
460 pub const SA_NODEFER: ::c_int = 0x40000000;
461 pub const SA_RESETHAND: ::c_int = 0x80000000;
462 pub const SA_RESTART: ::c_int = 0x10000000;
463 pub const SA_NOCLDSTOP: ::c_int = 0x00000001;
464
465 pub const SS_ONSTACK: ::c_int = 1;
466 pub const SS_DISABLE: ::c_int = 2;
467
468 pub const PATH_MAX: ::c_int = 4096;
469
470 pub const FD_SETSIZE: usize = 1024;
471
472 pub const EPOLLIN: ::c_int = 0x1;
473 pub const EPOLLPRI: ::c_int = 0x2;
474 pub const EPOLLOUT: ::c_int = 0x4;
475 pub const EPOLLRDNORM: ::c_int = 0x40;
476 pub const EPOLLRDBAND: ::c_int = 0x80;
477 pub const EPOLLWRNORM: ::c_int = 0x100;
478 pub const EPOLLWRBAND: ::c_int = 0x200;
479 pub const EPOLLMSG: ::c_int = 0x400;
480 pub const EPOLLERR: ::c_int = 0x8;
481 pub const EPOLLHUP: ::c_int = 0x10;
482 pub const EPOLLET: ::c_int = 0x80000000;
483
484 pub const EPOLL_CTL_ADD: ::c_int = 1;
485 pub const EPOLL_CTL_MOD: ::c_int = 3;
486 pub const EPOLL_CTL_DEL: ::c_int = 2;
487
488 pub const MNT_DETACH: ::c_int = 0x2;
489 pub const MNT_EXPIRE: ::c_int = 0x4;
490
491 pub const Q_GETFMT: ::c_int = 0x800004;
492 pub const Q_GETINFO: ::c_int = 0x800005;
493 pub const Q_SETINFO: ::c_int = 0x800006;
494 pub const QIF_BLIMITS: ::uint32_t = 1;
495 pub const QIF_SPACE: ::uint32_t = 2;
496 pub const QIF_ILIMITS: ::uint32_t = 4;
497 pub const QIF_INODES: ::uint32_t = 8;
498 pub const QIF_BTIME: ::uint32_t = 16;
499 pub const QIF_ITIME: ::uint32_t = 32;
500 pub const QIF_LIMITS: ::uint32_t = 5;
501 pub const QIF_USAGE: ::uint32_t = 10;
502 pub const QIF_TIMES: ::uint32_t = 48;
503 pub const QIF_ALL: ::uint32_t = 63;
504
505 pub const CBAUD: ::tcflag_t = 0o0010017;
506
507 pub const EFD_CLOEXEC: ::c_int = 0x80000;
508
509 pub const MNT_FORCE: ::c_int = 0x1;
510
511 pub const Q_SYNC: ::c_int = 0x800001;
512 pub const Q_QUOTAON: ::c_int = 0x800002;
513 pub const Q_QUOTAOFF: ::c_int = 0x800003;
514 pub const Q_GETQUOTA: ::c_int = 0x800007;
515 pub const Q_SETQUOTA: ::c_int = 0x800008;
516
517 pub const TCIOFF: ::c_int = 2;
518 pub const TCION: ::c_int = 3;
519 pub const TCOOFF: ::c_int = 0;
520 pub const TCOON: ::c_int = 1;
521 pub const TCIFLUSH: ::c_int = 0;
522 pub const TCOFLUSH: ::c_int = 1;
523 pub const TCIOFLUSH: ::c_int = 2;
524 pub const NL0: ::c_int = 0x00000000;
525 pub const NL1: ::c_int = 0x00000100;
526 pub const TAB0: ::c_int = 0x00000000;
527 pub const TAB1: ::c_int = 0x00000800;
528 pub const TAB2: ::c_int = 0x00001000;
529 pub const TAB3: ::c_int = 0x00001800;
530 pub const CR0: ::c_int = 0x00000000;
531 pub const CR1: ::c_int = 0x00000200;
532 pub const CR2: ::c_int = 0x00000400;
533 pub const CR3: ::c_int = 0x00000600;
534 pub const FF0: ::c_int = 0x00000000;
535 pub const FF1: ::c_int = 0x00008000;
536 pub const BS0: ::c_int = 0x00000000;
537 pub const BS1: ::c_int = 0x00002000;
538 pub const VT0: ::c_int = 0x00000000;
539 pub const VT1: ::c_int = 0x00004000;
540 pub const VERASE: usize = 2;
541 pub const VWERASE: usize = 14;
542 pub const VKILL: usize = 3;
543 pub const VREPRINT: usize = 12;
544 pub const VINTR: usize = 0;
545 pub const VQUIT: usize = 1;
546 pub const VSUSP: usize = 10;
547 pub const VSTART: usize = 8;
548 pub const VSTOP: usize = 9;
549 pub const VLNEXT: usize = 15;
550 pub const VDISCARD: usize = 13;
551 pub const VTIME: usize = 5;
552 pub const IGNBRK: ::tcflag_t = 0x00000001;
553 pub const BRKINT: ::tcflag_t = 0x00000002;
554 pub const IGNPAR: ::tcflag_t = 0x00000004;
555 pub const PARMRK: ::tcflag_t = 0x00000008;
556 pub const INPCK: ::tcflag_t = 0x00000010;
557 pub const ISTRIP: ::tcflag_t = 0x00000020;
558 pub const INLCR: ::tcflag_t = 0x00000040;
559 pub const IGNCR: ::tcflag_t = 0x00000080;
560 pub const ICRNL: ::tcflag_t = 0x00000100;
561 pub const IXON: ::tcflag_t = 0x00000400;
562 pub const IXOFF: ::tcflag_t = 0x00001000;
563 pub const IXANY: ::tcflag_t = 0x00000800;
564 pub const IMAXBEL: ::tcflag_t = 0x00002000;
565 pub const OPOST: ::tcflag_t = 0x1;
566 pub const ONLCR: ::tcflag_t = 0x4;
567 pub const CSIZE: ::tcflag_t = 0x00000030;
568 pub const CS5: ::tcflag_t = 0x00000000;
569 pub const CS6: ::tcflag_t = 0x00000010;
570 pub const CS7: ::tcflag_t = 0x00000020;
571 pub const CS8: ::tcflag_t = 0x00000030;
572 pub const CSTOPB: ::tcflag_t = 0x00000040;
573 pub const CREAD: ::tcflag_t = 0x00000080;
574 pub const PARENB: ::tcflag_t = 0x00000100;
575 pub const PARODD: ::tcflag_t = 0x00000200;
576 pub const HUPCL: ::tcflag_t = 0x00000400;
577 pub const CLOCAL: ::tcflag_t = 0x00000800;
578 pub const CRTSCTS: ::tcflag_t = 0x80000000;
579 pub const ECHOKE: ::tcflag_t = 0x00000800;
580 pub const ECHOE: ::tcflag_t = 0x00000010;
581 pub const ECHOK: ::tcflag_t = 0x00000020;
582 pub const ECHO: ::tcflag_t = 0x00000008;
583 pub const ECHONL: ::tcflag_t = 0x00000040;
584 pub const ECHOPRT: ::tcflag_t = 0x00000400;
585 pub const ECHOCTL: ::tcflag_t = 0x00000200;
586 pub const ISIG: ::tcflag_t = 0x00000001;
587 pub const ICANON: ::tcflag_t = 0x00000002;
588 pub const PENDIN: ::tcflag_t = 0x00004000;
589 pub const NOFLSH: ::tcflag_t = 0x00000080;
590
591 pub const CLONE_VM: ::c_int = 0x100;
592 pub const CLONE_FS: ::c_int = 0x200;
593 pub const CLONE_FILES: ::c_int = 0x400;
594 pub const CLONE_SIGHAND: ::c_int = 0x800;
595 pub const CLONE_PTRACE: ::c_int = 0x2000;
596 pub const CLONE_VFORK: ::c_int = 0x4000;
597 pub const CLONE_PARENT: ::c_int = 0x8000;
598 pub const CLONE_THREAD: ::c_int = 0x10000;
599 pub const CLONE_NEWNS: ::c_int = 0x20000;
600 pub const CLONE_SYSVSEM: ::c_int = 0x40000;
601 pub const CLONE_SETTLS: ::c_int = 0x80000;
602 pub const CLONE_PARENT_SETTID: ::c_int = 0x100000;
603 pub const CLONE_CHILD_CLEARTID: ::c_int = 0x200000;
604 pub const CLONE_DETACHED: ::c_int = 0x400000;
605 pub const CLONE_UNTRACED: ::c_int = 0x800000;
606 pub const CLONE_CHILD_SETTID: ::c_int = 0x01000000;
607 pub const CLONE_NEWUTS: ::c_int = 0x04000000;
608 pub const CLONE_NEWIPC: ::c_int = 0x08000000;
609 pub const CLONE_NEWUSER: ::c_int = 0x10000000;
610 pub const CLONE_NEWPID: ::c_int = 0x20000000;
611 pub const CLONE_NEWNET: ::c_int = 0x40000000;
612 pub const CLONE_IO: ::c_int = 0x80000000;
613
614 pub const WNOHANG: ::c_int = 1;
615
616 pub const SPLICE_F_MOVE: ::c_uint = 0x01;
617 pub const SPLICE_F_NONBLOCK: ::c_uint = 0x02;
618 pub const SPLICE_F_MORE: ::c_uint = 0x04;
619 pub const SPLICE_F_GIFT: ::c_uint = 0x08;
620
621 pub const RTLD_LOCAL: ::c_int = 0;
622
623 pub const POSIX_FADV_NORMAL: ::c_int = 0;
624 pub const POSIX_FADV_RANDOM: ::c_int = 1;
625 pub const POSIX_FADV_SEQUENTIAL: ::c_int = 2;
626 pub const POSIX_FADV_WILLNEED: ::c_int = 3;
627 pub const POSIX_FADV_DONTNEED: ::c_int = 4;
628 pub const POSIX_FADV_NOREUSE: ::c_int = 5;
629
630 pub const AT_FDCWD: ::c_int = -100;
631 pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x100;
632
633 f! {
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
673 extern {
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;
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;
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;
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;
695 pub fn sched_setscheduler(pid: ::pid_t,
696 policy: ::c_int,
697 param: *const sched_param) -> ::c_int;
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;
724 pub fn memrchr(cx: *const ::c_void,
725 c: ::c_int,
726 n: ::size_t) -> *mut ::c_void;
727 pub fn syscall(num: ::c_long, ...) -> ::c_long;
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
747 pub fn posix_fadvise(fd: ::c_int, offset: ::off_t, len: ::off_t,
748 advise: ::c_int) -> ::c_int;
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;
752 }
753
754 cfg_if! {
755 if #[cfg(any(target_os = "linux",
756 target_os = "emscripten"))] {
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 {
763 // Unknown target_os
764 }
765 }