]> git.proxmox.com Git - rustc.git/blame - src/vendor/libc/src/unix/haiku/mod.rs
New upstream version 1.23.0+dfsg1
[rustc.git] / src / vendor / libc / src / unix / haiku / mod.rs
CommitLineData
8bb4bdeb 1use dox::{mem, Option};
476ff2be
SL
2
3pub type rlim_t = ::uintptr_t;
4pub type sa_family_t = u8;
5pub type pthread_key_t = ::c_int;
6pub type nfds_t = ::c_long;
7pub type tcflag_t = ::c_uint;
8pub type speed_t = ::c_uint;
9pub type c_char = i8;
10pub type clock_t = i32;
11pub type clockid_t = i32;
476ff2be
SL
12pub type suseconds_t = i32;
13pub type wchar_t = i32;
14pub type off_t = i64;
15pub type ino_t = i64;
16pub type blkcnt_t = i64;
17pub type blksize_t = i32;
18pub type dev_t = i32;
19pub type mode_t = u32;
20pub type nlink_t = i32;
21pub type useconds_t = u32;
22pub type socklen_t = u32;
23pub type pthread_t = ::uintptr_t;
24pub type pthread_mutexattr_t = ::uintptr_t;
041b39d2 25pub type pthread_rwlockattr_t = ::uintptr_t;
476ff2be
SL
26pub type sigset_t = u64;
27pub type fsblkcnt_t = i64;
28pub type fsfilcnt_t = i64;
29pub type pthread_attr_t = *mut ::c_void;
30pub type nl_item = ::c_int;
8bb4bdeb
XL
31pub type id_t = i32;
32pub type idtype_t = ::c_uint;
476ff2be
SL
33
34pub enum timezone {}
35
36s! {
37 pub struct sockaddr {
38 pub sa_len: u8,
39 pub sa_family: sa_family_t,
40 pub sa_data: [::c_char; 30],
41 }
42
43 pub struct sockaddr_in {
44 pub sin_len: u8,
45 pub sin_family: sa_family_t,
46 pub sin_port: ::in_port_t,
47 pub sin_addr: ::in_addr,
48 pub sin_zero: [u8; 24],
49 }
50
51 pub struct sockaddr_in6 {
52 pub sin6_len: u8,
53 pub sin6_family: sa_family_t,
54 pub sin6_port: ::in_port_t,
55 pub sin6_flowinfo: u32,
56 pub sin6_addr: ::in6_addr,
57 pub sin6_scope_id: u32,
58 }
59
60 pub struct sockaddr_un {
61 pub sun_len: u8,
62 pub sun_family: sa_family_t,
63 pub sun_path: [::c_char; 126]
64 }
65
66 pub struct sockaddr_storage {
67 pub ss_len: u8,
68 pub ss_family: sa_family_t,
69 __ss_pad1: [u8; 6],
70 __ss_pad2: u64,
71 __ss_pad3: [u8; 112],
72 }
73
74 pub struct addrinfo {
75 pub ai_flags: ::c_int,
76 pub ai_family: ::c_int,
77 pub ai_socktype: ::c_int,
78 pub ai_protocol: ::c_int,
79 pub ai_addrlen: socklen_t,
80 pub ai_canonname: *mut c_char,
81 pub ai_addr: *mut ::sockaddr,
82 pub ai_next: *mut addrinfo,
83 }
84
85 pub struct fd_set {
86 fds_bits: [c_ulong; FD_SETSIZE / ULONG_SIZE],
87 }
88
89 pub struct tm {
90 pub tm_sec: ::c_int,
91 pub tm_min: ::c_int,
92 pub tm_hour: ::c_int,
93 pub tm_mday: ::c_int,
94 pub tm_mon: ::c_int,
95 pub tm_year: ::c_int,
96 pub tm_wday: ::c_int,
97 pub tm_yday: ::c_int,
98 pub tm_isdst: ::c_int,
99 pub tm_gmtoff: ::c_long,
100 pub tm_zone: *const ::c_char,
101 }
102
103 pub struct utsname {
104 pub sysname: [::c_char; 32],
105 pub nodename: [::c_char; 32],
106 pub release: [::c_char; 32],
107 pub version: [::c_char; 32],
108 pub machine: [::c_char; 32],
109 }
110
111 pub struct lconv {
112 pub decimal_point: *mut ::c_char,
113 pub thousands_sep: *mut ::c_char,
114 pub grouping: *mut ::c_char,
115 pub int_curr_symbol: *mut ::c_char,
116 pub currency_symbol: *mut ::c_char,
117 pub mon_decimal_point: *mut ::c_char,
118 pub mon_thousands_sep: *mut ::c_char,
119 pub mon_grouping: *mut ::c_char,
120 pub positive_sign: *mut ::c_char,
121 pub negative_sign: *mut ::c_char,
122 pub int_frac_digits: ::c_char,
123 pub frac_digits: ::c_char,
124 pub p_cs_precedes: ::c_char,
125 pub p_sep_by_space: ::c_char,
126 pub n_cs_precedes: ::c_char,
127 pub n_sep_by_space: ::c_char,
128 pub p_sign_posn: ::c_char,
129 pub n_sign_posn: ::c_char,
130 pub int_p_cs_precedes: ::c_char,
131 pub int_p_sep_by_space: ::c_char,
132 pub int_n_cs_precedes: ::c_char,
133 pub int_n_sep_by_space: ::c_char,
134 pub int_p_sign_posn: ::c_char,
135 pub int_n_sign_posn: ::c_char,
136 }
137
138 pub struct msghdr {
139 pub msg_name: *mut ::c_void,
140 pub msg_namelen: ::socklen_t,
141 pub msg_iov: *mut ::iovec,
142 pub msg_iovlen: ::c_int,
143 pub msg_control: *mut ::c_void,
144 pub msg_controllen: ::socklen_t,
145 pub msg_flags: ::c_int,
146 }
147
8bb4bdeb
XL
148 pub struct cmsghdr {
149 pub cmsg_len: ::size_t,
150 pub cmsg_level: ::c_int,
151 pub cmsg_type: ::c_int,
152 }
153
476ff2be
SL
154 pub struct Dl_info {
155 pub dli_fname: *const ::c_char,
156 pub dli_fbase: *mut ::c_void,
157 pub dli_sname: *const ::c_char,
158 pub dli_saddr: *mut ::c_void,
159 }
160
161 pub struct termios {
162 pub c_iflag: ::tcflag_t,
163 pub c_oflag: ::tcflag_t,
164 pub c_cflag: ::tcflag_t,
165 pub c_lflag: ::tcflag_t,
166 pub c_line: ::c_char,
167 pub c_ispeed: ::speed_t,
168 pub c_ospeed: ::speed_t,
169 pub c_cc: [::cc_t; ::NCCS],
170 }
171
abe05a73
XL
172 pub struct flock {
173 pub l_type: ::c_short,
174 pub l_whence: ::c_short,
175 pub l_start: ::off_t,
176 pub l_len: ::off_t,
177 pub l_pid: ::pid_t,
178 }
179
476ff2be
SL
180 pub struct stat {
181 pub st_dev: dev_t,
182 pub st_ino: ino_t,
183 pub st_mode: mode_t,
184 pub st_nlink: nlink_t,
185 pub st_uid: ::uid_t,
186 pub st_gid: ::gid_t,
187 pub st_size: off_t,
188 pub st_rdev: dev_t,
189 pub st_blksize: blksize_t,
190 pub st_atime: time_t,
191 pub st_atime_nsec: c_long,
192 pub st_mtime: time_t,
193 pub st_mtime_nsec: c_long,
194 pub st_ctime: time_t,
195 pub st_ctime_nsec: c_long,
196 pub st_crtime: time_t,
197 pub st_crtime_nsec: c_long,
198 pub st_type: u32,
199 pub st_blocks: blkcnt_t,
200 }
201
202 pub struct dirent {
203 pub d_dev: dev_t,
204 pub d_pdev: dev_t,
205 pub d_ino: ino_t,
206 pub d_pino: i64,
207 pub d_reclen: ::c_ushort,
208 pub d_name: [::c_char; 1024], // Max length is _POSIX_PATH_MAX
209 }
210
211 pub struct glob_t {
212 pub gl_pathc: ::size_t,
213 __unused1: ::size_t,
214 pub gl_offs: ::size_t,
215 __unused2: ::size_t,
216 pub gl_pathv: *mut *mut c_char,
217
218 __unused3: *mut ::c_void,
219 __unused4: *mut ::c_void,
220 __unused5: *mut ::c_void,
221 __unused6: *mut ::c_void,
222 __unused7: *mut ::c_void,
223 __unused8: *mut ::c_void,
224 }
225
226 pub struct pthread_mutex_t {
227 flags: u32,
228 lock: i32,
229 unused: i32,
230 owner: i32,
231 owner_count: i32,
232 }
233
234 pub struct pthread_cond_t {
235 flags: u32,
236 unused: i32,
237 mutex: *mut ::c_void,
238 waiter_count: i32,
239 lock: i32,
240 }
241
242 pub struct pthread_rwlock_t {
243 flags: u32,
244 owner: i32,
245 lock_sem: i32, // this is actually a union
246 lock_count: i32,
247 reader_count: i32,
248 writer_count: i32,
249 waiters: [*mut ::c_void; 2],
250 }
251
252 pub struct passwd {
253 pub pw_name: *mut ::c_char,
254 pub pw_passwd: *mut ::c_char,
255 pub pw_uid: ::uid_t,
256 pub pw_gid: ::gid_t,
257 pub pw_dir: *mut ::c_char,
258 pub pw_shell: *mut ::c_char,
259 pub pw_gecos: *mut ::c_char,
260 }
261
262 pub struct statvfs {
263 pub f_bsize: ::c_ulong,
264 pub f_frsize: ::c_ulong,
265 pub f_blocks: ::fsblkcnt_t,
266 pub f_bfree: ::fsblkcnt_t,
267 pub f_bavail: ::fsblkcnt_t,
268 pub f_files: ::fsfilcnt_t,
269 pub f_ffree: ::fsfilcnt_t,
270 pub f_favail: ::fsfilcnt_t,
271 pub f_fsid: ::c_ulong,
272 pub f_flag: ::c_ulong,
273 pub f_namemax: ::c_ulong,
274 }
275
276 pub struct stack_t {
277 pub ss_sp: *mut ::c_void,
278 pub ss_size: ::size_t,
279 pub ss_flags: ::c_int,
280 }
281
282 pub struct siginfo_t {
283 pub si_signo: ::c_int,
284 pub si_code: ::c_int,
285 pub si_errno: ::c_int,
286 pub si_pid: ::pid_t,
287 pub si_uid: ::uid_t,
288 pub si_addr: *mut ::c_void,
289 pub si_status: ::c_int,
290 pub si_band: c_long,
291 pub sigval: *mut ::c_void,
292 }
293
294 pub struct sigaction {
295 pub sa_sigaction: ::sighandler_t,
296 pub sa_mask: ::sigset_t,
297 pub sa_flags: ::c_int,
298 sa_userdata: *mut ::c_void,
299 }
300
abe05a73
XL
301 pub struct sigevent {
302 pub sigev_notify: ::c_int,
303 pub sigev_signo: ::c_int,
304 pub sigev_value: ::sigval,
305 __unused1: *mut ::c_void, // actually a function pointer
306 pub sigev_notify_attributes: *mut ::pthread_attr_t,
307 }
308
476ff2be
SL
309 pub struct sem_t {
310 pub se_type: i32,
311 pub se_named_id: i32, // this is actually a union
312 pub se_unnamed: i32,
313 pub se_padding: [i32; 4],
314 }
315
316 pub struct pthread_condattr_t {
317 pub process_shared: bool,
318 pub clock_id: i32,
319 }
320}
321
322// intentionally not public, only used for fd_set
323cfg_if! {
324 if #[cfg(target_pointer_width = "32")] {
325 const ULONG_SIZE: usize = 32;
326 } else if #[cfg(target_pointer_width = "64")] {
327 const ULONG_SIZE: usize = 64;
328 } else {
329 // Unknown target_pointer_width
330 }
331}
332
333pub const EXIT_FAILURE: ::c_int = 1;
334pub const EXIT_SUCCESS: ::c_int = 0;
335pub const RAND_MAX: ::c_int = 2147483647;
336pub const EOF: ::c_int = -1;
337pub const SEEK_SET: ::c_int = 0;
338pub const SEEK_CUR: ::c_int = 1;
339pub const SEEK_END: ::c_int = 2;
340pub const _IOFBF: ::c_int = 0;
341pub const _IONBF: ::c_int = 2;
342pub const _IOLBF: ::c_int = 1;
343
344pub const F_DUPFD: ::c_int = 0x0001;
345pub const F_GETFD: ::c_int = 0x0002;
346pub const F_SETFD: ::c_int = 0x0004;
347pub const F_GETFL: ::c_int = 0x0008;
348pub const F_SETFL: ::c_int = 0x0010;
abe05a73
XL
349pub const F_GETLK: ::c_int = 0x0020;
350pub const F_SETLK: ::c_int = 0x0080;
351pub const F_SETLKW: ::c_int = 0x0100;
352pub const F_DUPFD_CLOEXEC: ::c_int = 0x0200;
353
354pub const AT_FDCWD: ::c_int = -1;
355pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x01;
356pub const AT_SYMLINK_FOLLOW: ::c_int = 0x02;
357pub const AT_REMOVEDIR: ::c_int = 0x04;
358pub const AT_EACCESS: ::c_int = 0x08;
359
360pub const POLLIN: ::c_short = 0x0001;
361pub const POLLOUT: ::c_short = 0x0002;
362pub const POLLRDNORM: ::c_short = POLLIN;
363pub const POLLWRNORM: ::c_short = POLLOUT;
364pub const POLLRDBAND: ::c_short = 0x0008;
365pub const POLLWRBAND: ::c_short = 0x0010;
366pub const POLLPRI: ::c_short = 0x0020;
367pub const POLLERR: ::c_short = 0x0004;
368pub const POLLHUP: ::c_short = 0x0080;
369pub const POLLNVAL: ::c_short = 0x1000;
476ff2be 370
476ff2be
SL
371pub const PTHREAD_CREATE_JOINABLE: ::c_int = 0;
372pub const PTHREAD_CREATE_DETACHED: ::c_int = 1;
373
374pub const CLOCK_REALTIME: ::c_int = -1;
375pub const CLOCK_MONOTONIC: ::c_int = 0;
376
377pub const RLIMIT_CORE: ::c_int = 0;
378pub const RLIMIT_CPU: ::c_int = 1;
379pub const RLIMIT_DATA: ::c_int = 2;
380pub const RLIMIT_FSIZE: ::c_int = 3;
381pub const RLIMIT_NOFILE: ::c_int = 4;
382pub const RLIMIT_AS: ::c_int = 6;
383// Haiku specific
384pub const RLIMIT_NOVMON: ::c_int = 7;
385pub const RLIMIT_NLIMITS: ::c_int = 8;
386
387pub const RUSAGE_SELF: ::c_int = 0;
388
abe05a73
XL
389pub const RTLD_LAXY: ::c_int = 0;
390
476ff2be
SL
391pub const NCCS: usize = 11;
392
393pub const O_RDONLY: ::c_int = 0x0000;
394pub const O_WRONLY: ::c_int = 0x0001;
395pub const O_RDWR: ::c_int = 0x0002;
396pub const O_ACCMODE: ::c_int = 0x0003;
397
398pub const O_EXCL: ::c_int = 0x0100;
399pub const O_CREAT: ::c_int = 0x0200;
400pub const O_TRUNC: ::c_int = 0x0400;
401pub const O_NOCTTY: ::c_int = 0x1000;
402pub const O_NOTRAVERSE: ::c_int = 0x2000;
403
404pub const O_CLOEXEC: ::c_int = 0x00000040;
405pub const O_NONBLOCK: ::c_int = 0x00000080;
406pub const O_APPEND: ::c_int = 0x00000800;
407pub const O_SYNC: ::c_int = 0x00010000;
408pub const O_RSYNC: ::c_int = 0x00020000;
409pub const O_DSYNC: ::c_int = 0x00040000;
410pub const O_NOFOLLOW: ::c_int = 0x00080000;
411pub const O_NOCACHE: ::c_int = 0x00100000;
412pub const O_DIRECTORY: ::c_int = 0x00200000;
413
414pub const S_IFIFO: ::mode_t = 61440;
415pub const S_IFCHR: ::mode_t = 49152;
416pub const S_IFBLK: ::mode_t = 24576;
417pub const S_IFDIR: ::mode_t = 16384;
418pub const S_IFREG: ::mode_t = 32768;
419pub const S_IFLNK: ::mode_t = 40960;
420pub const S_IFSOCK: ::mode_t = 49152;
421pub const S_IFMT: ::mode_t = 61440;
422pub const S_IRWXU: ::mode_t = 448;
423pub const S_IXUSR: ::mode_t = 64;
424pub const S_IWUSR: ::mode_t = 128;
425pub const S_IRUSR: ::mode_t = 256;
426pub const S_IRWXG: ::mode_t = 70;
427pub const S_IXGRP: ::mode_t = 10;
428pub const S_IWGRP: ::mode_t = 20;
429pub const S_IRGRP: ::mode_t = 40;
430pub const S_IRWXO: ::mode_t = 7;
431pub const S_IXOTH: ::mode_t = 1;
432pub const S_IWOTH: ::mode_t = 2;
433pub const S_IROTH: ::mode_t = 4;
434pub const F_OK: ::c_int = 0;
435pub const R_OK: ::c_int = 4;
436pub const W_OK: ::c_int = 2;
437pub const X_OK: ::c_int = 1;
438pub const STDIN_FILENO: ::c_int = 0;
439pub const STDOUT_FILENO: ::c_int = 1;
440pub const STDERR_FILENO: ::c_int = 2;
ea8adc8c 441
476ff2be
SL
442pub const SIGHUP: ::c_int = 1;
443pub const SIGINT: ::c_int = 2;
444pub const SIGQUIT: ::c_int = 3;
445pub const SIGILL: ::c_int = 4;
ea8adc8c 446pub const SIGCHLD: ::c_int = 5;
476ff2be 447pub const SIGABRT: ::c_int = 6;
ea8adc8c 448pub const SIGPIPE: ::c_int = 7;
476ff2be
SL
449pub const SIGFPE: ::c_int = 8;
450pub const SIGKILL: ::c_int = 9;
ea8adc8c 451pub const SIGSTOP: ::c_int = 10;
476ff2be 452pub const SIGSEGV: ::c_int = 11;
ea8adc8c
XL
453pub const SIGCONT: ::c_int = 12;
454pub const SIGTSTP: ::c_int = 13;
476ff2be
SL
455pub const SIGALRM: ::c_int = 14;
456pub const SIGTERM: ::c_int = 15;
ea8adc8c
XL
457pub const SIGTTIN: ::c_int = 16;
458pub const SIGTTOU: ::c_int = 17;
459pub const SIGUSR1: ::c_int = 18;
460pub const SIGUSR2: ::c_int = 19;
461pub const SIGWINCH: ::c_int = 20;
462pub const SIGKILLTHR: ::c_int = 21;
463pub const SIGTRAP: ::c_int = 22;
464pub const SIGPOLL: ::c_int = 23;
465pub const SIGPROF: ::c_int = 24;
466pub const SIGSYS: ::c_int = 25;
467pub const SIGURG: ::c_int = 26;
468pub const SIGVTALRM: ::c_int = 27;
469pub const SIGXCPU: ::c_int = 28;
470pub const SIGXFSZ: ::c_int = 29;
471pub const SIGBUS: ::c_int = 30;
476ff2be 472
abe05a73
XL
473pub const SIG_BLOCK: ::c_int = 1;
474pub const SIG_UNBLOCK: ::c_int = 2;
475pub const SIG_SETMASK: ::c_int = 3;
476
477pub const SIGEV_NONE: ::c_int = 0;
478pub const SIGEV_SIGNAL: ::c_int = 1;
479pub const SIGEV_THREAD: ::c_int = 2;
480
476ff2be
SL
481pub const EAI_SYSTEM: ::c_int = 11;
482
483pub const PROT_NONE: ::c_int = 0;
484pub const PROT_READ: ::c_int = 1;
485pub const PROT_WRITE: ::c_int = 2;
486pub const PROT_EXEC: ::c_int = 4;
487
488pub const LC_ALL: ::c_int = 0;
489pub const LC_COLLATE: ::c_int = 1;
490pub const LC_CTYPE: ::c_int = 2;
491pub const LC_MONETARY: ::c_int = 3;
492pub const LC_NUMERIC: ::c_int = 4;
493pub const LC_TIME: ::c_int = 5;
494pub const LC_MESSAGES: ::c_int = 6;
495
496// TODO: Haiku does not have MAP_FILE, but libstd/os.rs requires it
497pub const MAP_FILE: ::c_int = 0x00;
498pub const MAP_SHARED: ::c_int = 0x01;
499pub const MAP_PRIVATE: ::c_int = 0x02;
abe05a73
XL
500pub const MAP_FIXED: ::c_int = 0x04;
501pub const MAP_ANONYMOUS: ::c_int = 0x08;
502pub const MAP_ANON: ::c_int = MAP_ANONYMOUS;
476ff2be
SL
503
504pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void;
505
506pub const MS_ASYNC: ::c_int = 0x01;
507pub const MS_INVALIDATE: ::c_int = 0x04;
508pub const MS_SYNC: ::c_int = 0x02;
509
476ff2be 510pub const E2BIG : ::c_int = -2147454975;
476ff2be
SL
511pub const ECHILD : ::c_int = -2147454974;
512pub const EDEADLK : ::c_int = -2147454973;
ea8adc8c
XL
513pub const EFBIG : ::c_int = -2147454972;
514pub const EMLINK : ::c_int = -2147454971;
476ff2be 515pub const ENFILE : ::c_int = -2147454970;
ea8adc8c
XL
516pub const ENODEV : ::c_int = -2147454969;
517pub const ENOLCK : ::c_int = -2147454968;
518pub const ENOSYS : ::c_int = -2147454967;
476ff2be 519pub const ENOTTY : ::c_int = -2147454966;
ea8adc8c 520pub const ENXIO : ::c_int = -2147454965;
476ff2be 521pub const ESPIPE : ::c_int = -2147454964;
ea8adc8c
XL
522pub const ESRCH : ::c_int = -2147454963;
523pub const EFPOS : ::c_int = -2147457962;
524pub const ESIGPARM : ::c_int = -2147457961;
476ff2be
SL
525pub const EDOM : ::c_int = -2147454960;
526pub const ERANGE : ::c_int = -2147454959;
476ff2be 527pub const EPROTOTYPE : ::c_int = -2147454958;
476ff2be 528pub const EPROTONOSUPPORT : ::c_int = -2147454957;
476ff2be
SL
529pub const EPFNOSUPPORT : ::c_int = -2147454956;
530pub const EAFNOSUPPORT : ::c_int = -2147454955;
531pub const EADDRINUSE : ::c_int = -2147454954;
532pub const EADDRNOTAVAIL : ::c_int = -2147454953;
ea8adc8c 533pub const ENETDOWN : ::c_int = -2147454952;
476ff2be
SL
534pub const ENETUNREACH : ::c_int = -2147454951;
535pub const ENETRESET : ::c_int = -2147454950;
536pub const ECONNABORTED : ::c_int = -2147454949;
537pub const ECONNRESET : ::c_int = -2147454948;
476ff2be
SL
538pub const EISCONN : ::c_int = -2147454947;
539pub const ENOTCONN : ::c_int = -2147454946;
540pub const ESHUTDOWN : ::c_int = -2147454945;
476ff2be 541pub const ECONNREFUSED : ::c_int = -2147454944;
476ff2be 542pub const EHOSTUNREACH : ::c_int = -2147454943;
ea8adc8c
XL
543pub const ENOPROTOOPT : ::c_int = -2147454942;
544pub const ENOBUFS : ::c_int = -2147454941;
545pub const EINPROGRESS : ::c_int = -2147454940;
546pub const EALREADY : ::c_int = -2147454939;
547pub const EILSEQ : ::c_int = -2147454938;
476ff2be 548pub const ENOMSG : ::c_int = -2147454937;
ea8adc8c 549pub const ESTALE : ::c_int = -2147454936;
476ff2be 550pub const EOVERFLOW : ::c_int = -2147454935;
ea8adc8c
XL
551pub const EMSGSIZE : ::c_int = -2147454934;
552pub const EOPNOTSUPP : ::c_int = -2147454933;
553pub const ENOTSOCK : ::c_int = -2147454932;
554pub const EHOSTDOWN : ::c_int = -2147454931;
476ff2be 555pub const EBADMSG : ::c_int = -2147454930;
ea8adc8c
XL
556pub const ECANCELED : ::c_int = -2147454929;
557pub const EDESTADDRREQ : ::c_int = -2147454928;
558pub const EDQUOT : ::c_int = -2147454927;
559pub const EIDRM : ::c_int = -2147454926;
476ff2be 560pub const EMULTIHOP : ::c_int = -2147454925;
ea8adc8c 561pub const ENODATA : ::c_int = -2147454924;
476ff2be 562pub const ENOLINK : ::c_int = -2147454923;
ea8adc8c
XL
563pub const ENOSR : ::c_int = -2147454922;
564pub const ENOSTR : ::c_int = -2147454921;
565pub const ENOTSUP : ::c_int = -2147454920;
476ff2be 566pub const EPROTO : ::c_int = -2147454919;
ea8adc8c
XL
567pub const ETIME : ::c_int = -2147454918;
568pub const ETXTBSY : ::c_int = -2147454917;
569pub const ENOATTR : ::c_int = -2147454916;
570
571// INT_MIN
572pub const ENOMEM : ::c_int = -2147454976;
573
574// POSIX errors that can be mapped to BeOS error codes
575pub const EACCES : ::c_int = -2147483646;
576pub const EINTR : ::c_int = -2147483638;
577pub const EIO : ::c_int = -2147483647;
578pub const EBUSY : ::c_int = -2147483634;
579pub const EFAULT : ::c_int = -2147478783;
580pub const ETIMEDOUT : ::c_int = -2147483639;
581pub const EAGAIN : ::c_int = -2147483637;
582pub const EWOULDBLOCK : ::c_int = -2147483637;
583pub const EBADF : ::c_int = -2147459072;
584pub const EEXIST : ::c_int = -2147459070;
585pub const EINVAL : ::c_int = -2147483643;
586pub const ENAMETOOLONG : ::c_int = -2147459068;
587pub const ENOENT : ::c_int = -2147459069;
588pub const EPERM : ::c_int = -2147483633;
589pub const ENOTDIR : ::c_int = -2147459067;
590pub const EISDIR : ::c_int = -2147459063;
591pub const ENOTEMPTY : ::c_int = -2147459066;
592pub const ENOSPC : ::c_int = -2147459065;
593pub const EROFS : ::c_int = -2147459064;
abe05a73 594pub const EMFILE : ::c_int = -2147459062;
ea8adc8c
XL
595pub const EXDEV : ::c_int = -2147459061;
596pub const ELOOP : ::c_int = -2147459060;
597pub const ENOEXEC : ::c_int = -2147478782;
598pub const EPIPE : ::c_int = -2147459059;
476ff2be
SL
599
600pub const IPPROTO_RAW: ::c_int = 255;
601
602// These are prefixed with POSIX_ on Haiku
603pub const MADV_NORMAL: ::c_int = 1;
604pub const MADV_SEQUENTIAL: ::c_int = 2;
605pub const MADV_RANDOM: ::c_int = 3;
606pub const MADV_WILLNEED: ::c_int = 4;
607pub const MADV_DONTNEED: ::c_int = 5;
608
609pub const IFF_LOOPBACK: ::c_int = 0x0008;
610
abe05a73 611pub const AF_UNSEC: ::c_int = 0;
476ff2be 612pub const AF_INET: ::c_int = 1;
abe05a73
XL
613pub const AF_APPLETALK: ::c_int = 2;
614pub const AF_ROUTE: ::c_int = 3;
615pub const AF_LINK: ::c_int = 4;
616pub const AF_INET6: ::c_int = 5;
617pub const AF_DLI: ::c_int = 6;
618pub const AF_IPX: ::c_int = 7;
619pub const AF_NOTIFY: ::c_int = 8;
620pub const AF_LOCAL: ::c_int = 9;
621pub const AF_UNIX: ::c_int = AF_LOCAL;
622pub const AF_BLUETOOTH: ::c_int = 10;
623pub const AF_MAX: ::c_int = 11;
624
476ff2be
SL
625pub const IP_MULTICAST_TTL: ::c_int = 10;
626pub const IP_MULTICAST_LOOP: ::c_int = 11;
627pub const IP_TTL: ::c_int = 4;
628pub const IP_HDRINCL: ::c_int = 2;
629pub const IP_ADD_MEMBERSHIP: ::c_int = 12;
630pub const IP_DROP_MEMBERSHIP: ::c_int = 13;
631
632pub const TCP_NODELAY: ::c_int = 0x01;
633pub const TCP_MAXSEG: ::c_int = 0x02;
634pub const TCP_NOPUSH: ::c_int = 0x04;
635pub const TCP_NOOPT: ::c_int = 0x08;
636
637pub const IPV6_MULTICAST_LOOP: ::c_int = 26;
638pub const IPV6_JOIN_GROUP: ::c_int = 28;
639pub const IPV6_LEAVE_GROUP: ::c_int = 29;
640pub const IPV6_V6ONLY: ::c_int = 30;
641
abe05a73
XL
642pub const MSG_OOB: ::c_int = 0x0001;
643pub const MSG_PEEK: ::c_int = 0x0002;
644pub const MSG_DONTROUTE: ::c_int = 0x0004;
645pub const MSG_EOR: ::c_int = 0x0008;
646pub const MSG_TRUNC: ::c_int = 0x0010;
647pub const MSG_CTRUNC: ::c_int = 0x0020;
648pub const MSG_WAITALL: ::c_int = 0x0040;
649pub const MSG_DONTWAIT: ::c_int = 0x0080;
650pub const MSG_BCAST: ::c_int = 0x0100;
651pub const MSG_MCAST: ::c_int = 0x0200;
652pub const MSG_EOF: ::c_int = 0x0400;
476ff2be
SL
653pub const MSG_NOSIGNAL: ::c_int = 0x0800;
654
655pub const SHUT_RD: ::c_int = 0;
656pub const SHUT_WR: ::c_int = 1;
657pub const SHUT_RDWR: ::c_int = 2;
658
659pub const LOCK_SH: ::c_int = 0x01;
660pub const LOCK_EX: ::c_int = 0x02;
661pub const LOCK_NB: ::c_int = 0x04;
662pub const LOCK_UN: ::c_int = 0x08;
663
664pub const SIGSTKSZ: ::size_t = 16384;
665
abe05a73
XL
666pub const PATH_MAX: ::c_int = 1024;
667
668pub const SA_NOCLDSTOP: ::c_int = 0x01;
669pub const SA_NOCLDWAIT: ::c_int = 0x02;
476ff2be 670pub const SA_RESETHAND: ::c_int = 0x04;
abe05a73 671pub const SA_NODEFER: ::c_int = 0x08;
476ff2be 672pub const SA_RESTART: ::c_int = 0x10;
abe05a73
XL
673pub const SA_ONSTACK: ::c_int = 0x20;
674pub const SA_SIGINFO: ::c_int = 0x40;
675pub const SA_NOMASK: ::c_int = SA_NODEFER;
676pub const SA_STACK: ::c_int = SA_ONSTACK;
677pub const SA_ONESHOT: ::c_int = SA_RESETHAND;
476ff2be
SL
678
679pub const FD_SETSIZE: usize = 1024;
680
681pub const RTLD_NOW: ::c_int = 0x1;
682pub const RTLD_DEFAULT: *mut ::c_void = 0isize as *mut ::c_void;
683
684pub const BUFSIZ: ::c_uint = 8192;
685pub const FILENAME_MAX: ::c_uint = 256;
686pub const FOPEN_MAX: ::c_uint = 128;
687pub const L_tmpnam: ::c_uint = 512;
688pub const TMP_MAX: ::c_uint = 32768;
abe05a73
XL
689
690pub const _PC_CHOWN_RESTRICTED: ::c_int = 1;
691pub const _PC_MAX_CANON: ::c_int = 2;
692pub const _PC_MAX_INPUT: ::c_int = 3;
476ff2be 693pub const _PC_NAME_MAX: ::c_int = 4;
abe05a73
XL
694pub const _PC_NO_TRUNC: ::c_int = 5;
695pub const _PC_PATH_MAX: ::c_int = 6;
696pub const _PC_PIPE_BUF: ::c_int = 7;
697pub const _PC_VDISABLE: ::c_int = 8;
698pub const _PC_LINK_MAX: ::c_int = 25;
699pub const _PC_SYNC_IO: ::c_int = 26;
700pub const _PC_ASYNC_IO: ::c_int = 27;
701pub const _PC_PRIO_IO: ::c_int = 28;
702pub const _PC_SOCK_MAXBUF: ::c_int = 29;
703pub const _PC_FILESIZEBITS: ::c_int = 30;
704pub const _PC_REC_INCR_XFER_SIZE: ::c_int = 31;
705pub const _PC_REC_MAX_XFER_SIZE: ::c_int = 32;
706pub const _PC_REC_MIN_XFER_SIZE: ::c_int = 33;
707pub const _PC_REC_XFER_ALIGN: ::c_int = 34;
708pub const _PC_ALLOC_SIZE_MIN: ::c_int = 35;
709pub const _PC_SYMLINK_MAX: ::c_int = 36;
710pub const _PC_2_SYMLINKS: ::c_int = 37;
711pub const _PC_XATTR_EXISTS: ::c_int = 38;
712pub const _PC_XATTR_ENABLED: ::c_int = 39;
476ff2be
SL
713
714pub const FIONBIO: ::c_int = 0xbe000000;
715
abe05a73
XL
716pub const _SC_ARG_MAX : ::c_int = 15;
717pub const _SC_CHILD_MAX : ::c_int = 16;
718pub const _SC_CLK_TCK : ::c_int = 17;
719pub const _SC_JOB_CONTROL : ::c_int = 18;
720pub const _SC_NGROUPS_MAX : ::c_int = 19;
721pub const _SC_OPEN_MAX : ::c_int = 20;
722pub const _SC_SAVED_IDS : ::c_int = 21;
723pub const _SC_STREAM_MAX : ::c_int = 22;
724pub const _SC_TZNAME_MAX : ::c_int = 23;
725pub const _SC_VERSION : ::c_int = 24;
476ff2be
SL
726pub const _SC_GETGR_R_SIZE_MAX : ::c_int = 25;
727pub const _SC_GETPW_R_SIZE_MAX : ::c_int = 26;
728pub const _SC_PAGESIZE : ::c_int = 27;
abe05a73
XL
729pub const _SC_PAGE_SIZE : ::c_int = 27;
730pub const _SC_SEM_NSEMS_MAX : ::c_int = 28;
731pub const _SC_SEM_VALUE_MAX : ::c_int = 29;
732pub const _SC_SEMAPHORES : ::c_int = 30;
733pub const _SC_THREADS : ::c_int = 31;
734pub const _SC_IOV_MAX : ::c_int = 32;
735pub const _SC_UIO_MAXIOV : ::c_int = 32;
736pub const _SC_NPROCESSORS_CONF : ::c_int = 34;
737pub const _SC_NPROCESSORS_ONLN : ::c_int = 35;
738pub const _SC_ATEXIT_MAX : ::c_int = 37;
739pub const _SC_PASS_MAX : ::c_int = 39;
740pub const _SC_PHYS_PAGES : ::c_int = 40;
741pub const _SC_AVPHYS_PAGES : ::c_int = 41;
742pub const _SC_PIPE : ::c_int = 42;
743pub const _SC_SELECT : ::c_int = 43;
744pub const _SC_POLL : ::c_int = 44;
745pub const _SC_MAPPED_FILES : ::c_int = 45;
746pub const _SC_THREAD_PROCESS_SHARED : ::c_int = 46;
747pub const _SC_THREAD_STACK_MIN : ::c_int = 47;
476ff2be
SL
748pub const _SC_THREAD_ATTR_STACKADDR : ::c_int = 48;
749pub const _SC_THREAD_ATTR_STACKSIZE : ::c_int = 49;
750pub const _SC_THREAD_PRIORITY_SCHEDULING : ::c_int = 50;
abe05a73
XL
751pub const _SC_REALTIME_SIGNALS : ::c_int = 51;
752pub const _SC_MEMORY_PROTECTION : ::c_int = 52;
753pub const _SC_SIGQUEUE_MAX : ::c_int = 53;
754pub const _SC_RTSIG_MAX : ::c_int = 54;
755pub const _SC_MONOTONIC_CLOCK : ::c_int = 55;
756pub const _SC_DELAYTIMER_MAX : ::c_int = 56;
757pub const _SC_TIMER_MAX : ::c_int = 57;
758pub const _SC_TIMERS : ::c_int = 58;
759pub const _SC_CPUTIME : ::c_int = 59;
760pub const _SC_THREAD_CPUTIME : ::c_int = 60;
476ff2be
SL
761
762pub const PTHREAD_STACK_MIN: ::size_t = 8192;
763
764pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
765 flags: 0,
766 lock: 0,
767 unused: -42,
768 owner: -1,
769 owner_count: 0,
770};
771pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
772 flags: 0,
773 unused: -42,
774 mutex: 0 as *mut _,
775 waiter_count: 0,
776 lock: 0,
777};
778pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
779 flags: 0,
ea8adc8c 780 owner: -1,
476ff2be
SL
781 lock_sem: 0,
782 lock_count: 0,
783 reader_count: 0,
784 writer_count: 0,
785 waiters: [0 as *mut _; 2],
786};
787
788pub const PTHREAD_MUTEX_DEFAULT: ::c_int = 0;
789pub const PTHREAD_MUTEX_NORMAL: ::c_int = 1;
790pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2;
791pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 3;
792
793pub const FIOCLEX: c_ulong = 0; // TODO: does not exist on Haiku!
794
476ff2be
SL
795pub const RUSAGE_CHILDREN: ::c_int = -1;
796
797pub const SOCK_STREAM: ::c_int = 1;
798pub const SOCK_DGRAM: ::c_int = 2;
ea8adc8c
XL
799pub const SOCK_RAW: ::c_int = 3;
800pub const SOCK_SEQPACKET: ::c_int = 5;
476ff2be
SL
801
802pub const SOL_SOCKET: ::c_int = -1;
803pub const SO_ACCEPTCONN: ::c_int = 0x00000001;
804pub const SO_BROADCAST: ::c_int = 0x00000002;
abe05a73 805pub const SO_DEBUG: ::c_int = 0x00000004;
476ff2be
SL
806pub const SO_DONTROUTE: ::c_int = 0x00000008;
807pub const SO_KEEPALIVE: ::c_int = 0x00000010;
808pub const SO_OOBINLINE: ::c_int = 0x00000020;
809pub const SO_REUSEADDR: ::c_int = 0x00000040;
810pub const SO_REUSEPORT: ::c_int = 0x00000080;
811pub const SO_USELOOPBACK: ::c_int = 0x00000100;
812pub const SO_LINGER: ::c_int = 0x00000200;
813pub const SO_SNDBUF: ::c_int = 0x40000001;
814pub const SO_SNDLOWAT: ::c_int = 0x40000002;
815pub const SO_SNDTIMEO: ::c_int = 0x40000003;
816pub const SO_RCVBUF: ::c_int = 0x40000004;
817pub const SO_RCVLOWAT: ::c_int = 0x40000005;
818pub const SO_RCVTIMEO: ::c_int = 0x40000006;
819pub const SO_ERROR: ::c_int = 0x40000007;
820pub const SO_TYPE: ::c_int = 0x40000008;
821pub const SO_NONBLOCK: ::c_int = 0x40000009;
822pub const SO_BINDTODEVICE: ::c_int = 0x4000000a;
823pub const SO_PEERCRED: ::c_int = 0x4000000b;
824
abe05a73
XL
825pub const SCM_RIGHTS: ::c_int = 0x01;
826
476ff2be
SL
827pub const NI_MAXHOST: ::size_t = 1025;
828
8bb4bdeb
XL
829pub const WNOHANG: ::c_int = 0x01;
830pub const WUNTRACED: ::c_int = 0x02;
831pub const WCONTINUED: ::c_int = 0x04;
832pub const WEXITED: ::c_int = 0x08;
833pub const WSTOPPED: ::c_int = 0x10;
834pub const WNOWAIT: ::c_int = 0x20;
835
836pub const P_ALL: idtype_t = 0;
837pub const P_PID: idtype_t = 1;
838pub const P_PGID: idtype_t = 2;
839
041b39d2
XL
840pub const VINTR: usize = 0;
841pub const VQUIT: usize = 1;
842pub const VERASE: usize = 2;
843pub const VKILL: usize = 3;
844pub const VEOF: usize = 4;
845pub const VEOL: usize = 5;
846pub const VMIN: usize = 4;
847pub const VTIME: usize = 5;
848pub const VEOL2: usize = 6;
849pub const VSWTCH: usize = 7;
850pub const VSTART: usize = 8;
851pub const VSTOP: usize = 9;
852pub const VSUSP: usize = 10;
abe05a73
XL
853
854pub const IGNBRK: ::tcflag_t = 0x01;
855pub const BRKINT: ::tcflag_t = 0x02;
856pub const IGNPAR: ::tcflag_t = 0x04;
857pub const PARMRK: ::tcflag_t = 0x08;
858pub const INPCK: ::tcflag_t = 0x10;
859pub const ISTRIP: ::tcflag_t = 0x20;
860pub const INLCR: ::tcflag_t = 0x40;
861pub const IGNCR: ::tcflag_t = 0x80;
862pub const ICRNL: ::tcflag_t = 0x100;
863pub const IUCLC: ::tcflag_t = 0x200;
864pub const IXON: ::tcflag_t = 0x400;
865pub const IXANY: ::tcflag_t = 0x800;
866pub const IXOFF: ::tcflag_t = 0x1000;
867
868pub const OPOST: ::tcflag_t = 0x00000001;
869pub const OLCUC: ::tcflag_t = 0x00000002;
870pub const ONLCR: ::tcflag_t = 0x00000004;
871pub const OCRNL: ::tcflag_t = 0x00000008;
872pub const ONOCR: ::tcflag_t = 0x00000010;
873pub const ONLRET: ::tcflag_t = 0x00000020;
874pub const OFILL: ::tcflag_t = 0x00000040;
875pub const OFDEL: ::tcflag_t = 0x00000080;
876pub const NLDLY: ::tcflag_t = 0x00000100;
877pub const NL0: ::tcflag_t = 0x00000000;
878pub const NL1: ::tcflag_t = 0x00000100;
879pub const CRDLY: ::tcflag_t = 0x00000600;
880pub const CR0: ::tcflag_t = 0x00000000;
881pub const CR1: ::tcflag_t = 0x00000200;
882pub const CR2: ::tcflag_t = 0x00000400;
883pub const CR3: ::tcflag_t = 0x00000600;
884pub const TABDLY: ::tcflag_t = 0x00001800;
885pub const TAB0: ::tcflag_t = 0x00000000;
886pub const TAB1: ::tcflag_t = 0x00000800;
887pub const TAB2: ::tcflag_t = 0x00001000;
888pub const TAB3: ::tcflag_t = 0x00001800;
889pub const BSDLY: ::tcflag_t = 0x00002000;
890pub const BS0: ::tcflag_t = 0x00000000;
891pub const BS1: ::tcflag_t = 0x00002000;
892pub const VTDLY: ::tcflag_t = 0x00004000;
893pub const VT0: ::tcflag_t = 0x00000000;
894pub const VT1: ::tcflag_t = 0x00004000;
895pub const FFDLY: ::tcflag_t = 0x00008000;
896pub const FF0: ::tcflag_t = 0x00000000;
897pub const FF1: ::tcflag_t = 0x00008000;
898
899pub const CSIZE: ::tcflag_t = 0x00000020;
900pub const CS5: ::tcflag_t = 0x00000000;
901pub const CS6: ::tcflag_t = 0x00000000;
902pub const CS7: ::tcflag_t = 0x00000000;
903pub const CS8: ::tcflag_t = 0x00000020;
904pub const CSTOPB: ::tcflag_t = 0x00000040;
905pub const CREAD: ::tcflag_t = 0x00000080;
906pub const PARENB: ::tcflag_t = 0x00000100;
907pub const PARODD: ::tcflag_t = 0x00000200;
908pub const HUPCL: ::tcflag_t = 0x00000400;
909pub const CLOCAL: ::tcflag_t = 0x00000800;
910pub const XLOBLK: ::tcflag_t = 0x00001000;
911pub const CTSFLOW: ::tcflag_t = 0x00002000;
912pub const RTSFLOW: ::tcflag_t = 0x00004000;
913pub const CRTSCTS: ::tcflag_t = RTSFLOW | CTSFLOW;
914
915pub const ISIG: ::tcflag_t = 0x00000001;
916pub const ICANON: ::tcflag_t = 0x00000002;
917pub const XCASE: ::tcflag_t = 0x00000004;
918pub const ECHO: ::tcflag_t = 0x00000008;
919pub const ECHOE: ::tcflag_t = 0x00000010;
920pub const ECHOK: ::tcflag_t = 0x00000020;
921pub const ECHONL: ::tcflag_t = 0x00000040;
922pub const NOFLSH: ::tcflag_t = 0x00000080;
923pub const TOSTOP: ::tcflag_t = 0x00000100;
924pub const IEXTEN: ::tcflag_t = 0x00000200;
925pub const ECHOCTL: ::tcflag_t = 0x00000400;
926pub const ECHOPRT: ::tcflag_t = 0x00000800;
927pub const ECHOKE: ::tcflag_t = 0x00001000;
928pub const FLUSHO: ::tcflag_t = 0x00002000;
929pub const PENDIN: ::tcflag_t = 0x00004000;
041b39d2
XL
930
931pub const TCGB_CTS: ::c_int = 0x01;
932pub const TCGB_DSR: ::c_int = 0x02;
933pub const TCGB_RI: ::c_int = 0x04;
934pub const TCGB_DCD: ::c_int = 0x08;
935pub const TIOCM_CTS: ::c_int = TCGB_CTS;
936pub const TIOCM_CD: ::c_int = TCGB_DCD;
937pub const TIOCM_CAR: ::c_int = TIOCM_CD;
938pub const TIOCM_RI: ::c_int = TCGB_RI;
ea8adc8c 939pub const TIOCM_DSR: ::c_int = TCGB_DSR;
041b39d2
XL
940pub const TIOCM_DTR: ::c_int = 0x10;
941pub const TIOCM_RTS: ::c_int = 0x20;
942
abe05a73
XL
943pub const B0: speed_t = 0x00;
944pub const B50: speed_t = 0x01;
945pub const B75: speed_t = 0x02;
946pub const B110: speed_t = 0x03;
947pub const B134: speed_t = 0x04;
948pub const B150: speed_t = 0x05;
949pub const B200: speed_t = 0x06;
950pub const B300: speed_t = 0x07;
951pub const B600: speed_t = 0x08;
952pub const B1200: speed_t = 0x09;
953pub const B1800: speed_t = 0x0A;
954pub const B2400: speed_t = 0x0B;
955pub const B4800: speed_t = 0x0C;
956pub const B9600: speed_t = 0x0D;
957pub const B19200: speed_t = 0x0E;
958pub const B38400: speed_t = 0x0F;
959pub const B57600: speed_t = 0x10;
960pub const B115200: speed_t = 0x11;
961pub const B230400: speed_t = 0x12;
962pub const B31250: speed_t = 0x13;
963
964pub const TCSANOW: ::c_int = 0x01;
965pub const TCSADRAIN: ::c_int = 0x02;
966pub const TCSAFLUSH: ::c_int = 0x04;
967
968pub const TCOOFF: ::c_int = 0x01;
969pub const TCOON: ::c_int = 0x02;
970pub const TCIOFF: ::c_int = 0x04;
971pub const TCION: ::c_int = 0x08;
972
973pub const TCIFLUSH: ::c_int = 0x01;
974pub const TCOFLUSH: ::c_int = 0x02;
975pub const TCIOFLUSH: ::c_int = 0x03;
976
476ff2be
SL
977f! {
978 pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () {
979 let fd = fd as usize;
980 let size = mem::size_of_val(&(*set).fds_bits[0]) * 8;
981 (*set).fds_bits[fd / size] &= !(1 << (fd % size));
982 return
983 }
984
985 pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool {
986 let fd = fd as usize;
987 let size = mem::size_of_val(&(*set).fds_bits[0]) * 8;
988 return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0
989 }
990
991 pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () {
992 let fd = fd as usize;
993 let size = mem::size_of_val(&(*set).fds_bits[0]) * 8;
994 (*set).fds_bits[fd / size] |= 1 << (fd % size);
995 return
996 }
997
998 pub fn FD_ZERO(set: *mut fd_set) -> () {
999 for slot in (*set).fds_bits.iter_mut() {
1000 *slot = 0;
1001 }
1002 }
1003
1004 pub fn WIFEXITED(status: ::c_int) -> bool {
abe05a73 1005 (status & !0xff) == 0
476ff2be
SL
1006 }
1007
1008 pub fn WEXITSTATUS(status: ::c_int) -> ::c_int {
1009 (status & 0xff)
1010 }
1011
abe05a73
XL
1012 pub fn WIFSIGNALED(status: ::c_int) -> bool {
1013 ((status >> 8) & 0xff) != 0
1014 }
1015
476ff2be
SL
1016 pub fn WTERMSIG(status: ::c_int) -> ::c_int {
1017 (status >> 8) & 0xff
1018 }
abe05a73
XL
1019
1020 pub fn WIFSTOPPED(status: ::c_int) -> bool {
1021 ((status >> 16) & 0xff) != 0
1022 }
1023
1024 pub fn WSTOPSIG(status: ::c_int) -> ::c_int {
1025 (status >> 16) & 0xff
1026 }
1027
1028 // actually WIFCORED, but this is used everywhere else
1029 pub fn WCOREDUMP(status: ::c_int) -> bool {
1030 (status & 0x10000) != 0
1031 }
1032
1033 pub fn WIFCONTINUED(status: ::c_int) -> bool {
1034 (status & 0x20000) != 0
1035 }
476ff2be
SL
1036}
1037
abe05a73 1038#[link(name = "bsd")]
476ff2be
SL
1039extern {
1040 pub fn clock_gettime(clk_id: ::c_int, tp: *mut ::timespec) -> ::c_int;
8bb4bdeb 1041 pub fn clock_settime(clk_id: ::c_int, tp: *const ::timespec) -> ::c_int;
ea8adc8c
XL
1042 pub fn pthread_create(thread: *mut ::pthread_t,
1043 attr: *const ::pthread_attr_t,
1044 f: extern fn(*mut ::c_void) -> *mut ::c_void,
1045 value: *mut ::c_void) -> ::c_int;
476ff2be
SL
1046 pub fn pthread_attr_getguardsize(attr: *const ::pthread_attr_t,
1047 guardsize: *mut ::size_t) -> ::c_int;
1048 pub fn pthread_attr_getstack(attr: *const ::pthread_attr_t,
1049 stackaddr: *mut *mut ::c_void,
1050 stacksize: *mut ::size_t) -> ::c_int;
1051 pub fn pthread_condattr_getclock(attr: *const pthread_condattr_t,
1052 clock_id: *mut clockid_t) -> ::c_int;
1053 pub fn pthread_condattr_setclock(attr: *mut pthread_condattr_t,
ea8adc8c 1054 clock_id: ::clockid_t) -> ::c_int;
476ff2be
SL
1055 pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void;
1056 pub fn setgroups(ngroups: ::size_t,
1057 ptr: *const ::gid_t) -> ::c_int;
476ff2be
SL
1058 pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int;
1059 pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int)
1060 -> ::c_int;
041b39d2 1061 pub fn dirfd(dirp: *mut ::DIR) -> ::c_int;
476ff2be
SL
1062 pub fn getnameinfo(sa: *const ::sockaddr,
1063 salen: ::socklen_t,
1064 host: *mut ::c_char,
1065 hostlen: ::size_t,
1066 serv: *mut ::c_char,
1067 sevlen: ::size_t,
1068 flags: ::c_int) -> ::c_int;
1069 pub fn pthread_mutex_timedlock(lock: *mut pthread_mutex_t,
1070 abstime: *const ::timespec) -> ::c_int;
8bb4bdeb
XL
1071 pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t,
1072 options: ::c_int) -> ::c_int;
1073
7cac9316 1074 pub fn fdopendir(fd: ::c_int) -> *mut ::DIR;
8bb4bdeb
XL
1075 pub fn glob(pattern: *const ::c_char,
1076 flags: ::c_int,
1077 errfunc: Option<extern fn(epath: *const ::c_char,
1078 errno: ::c_int) -> ::c_int>,
1079 pglob: *mut ::glob_t) -> ::c_int;
1080 pub fn globfree(pglob: *mut ::glob_t);
1081
1082 pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int)
1083 -> ::c_int;
1084
abe05a73
XL
1085 pub fn shm_open(name: *const ::c_char, oflag: ::c_int, mode: ::mode_t)
1086 -> ::c_int;
8bb4bdeb
XL
1087 pub fn shm_unlink(name: *const ::c_char) -> ::c_int;
1088
1089 pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long);
1090
1091 pub fn telldir(dirp: *mut ::DIR) -> ::c_long;
1092 pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int)
1093 -> ::c_int;
1094
1095 pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int;
1096
1097 pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t,
1098 flags: ::c_int, addr: *mut ::sockaddr,
1099 addrlen: *mut ::socklen_t) -> ::ssize_t;
1100 pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int;
1101 pub fn futimes(fd: ::c_int, times: *const ::timeval) -> ::c_int;
1102 pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char;
1103
1104 pub fn bind(socket: ::c_int, address: *const ::sockaddr,
1105 address_len: ::socklen_t) -> ::c_int;
1106
1107 pub fn writev(fd: ::c_int,
1108 iov: *const ::iovec,
1109 iovcnt: ::c_int) -> ::ssize_t;
1110 pub fn readv(fd: ::c_int,
1111 iov: *const ::iovec,
1112 iovcnt: ::c_int) -> ::ssize_t;
1113
1114 pub fn sendmsg(fd: ::c_int,
1115 msg: *const ::msghdr,
1116 flags: ::c_int) -> ::ssize_t;
1117 pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int)
1118 -> ::ssize_t;
3b2f2976
XL
1119 pub fn execvpe(file: *const ::c_char, argv: *const *const ::c_char,
1120 environment: *const *const ::c_char) -> ::c_int;
ea8adc8c
XL
1121 #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrgid_r")]
1122 pub fn getgrgid_r(uid: ::uid_t,
1123 grp: *mut ::group,
1124 buf: *mut ::c_char,
1125 buflen: ::size_t,
1126 result: *mut *mut ::group) -> ::c_int;
1127 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
1128 link_name = "sigaltstack$UNIX2003")]
1129 #[cfg_attr(target_os = "netbsd", link_name = "__sigaltstack14")]
1130 pub fn sigaltstack(ss: *const stack_t,
1131 oss: *mut stack_t) -> ::c_int;
1132 pub fn sem_close(sem: *mut sem_t) -> ::c_int;
1133 pub fn getdtablesize() -> ::c_int;
1134 #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrnam_r")]
1135 pub fn getgrnam_r(name: *const ::c_char,
1136 grp: *mut ::group,
1137 buf: *mut ::c_char,
1138 buflen: ::size_t,
1139 result: *mut *mut ::group) -> ::c_int;
1140 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
1141 link_name = "pthread_sigmask$UNIX2003")]
1142 pub fn pthread_sigmask(how: ::c_int, set: *const sigset_t,
1143 oldset: *mut sigset_t) -> ::c_int;
1144 pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t;
1145 pub fn getgrnam(name: *const ::c_char) -> *mut ::group;
1146 pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int;
1147 pub fn sem_unlink(name: *const ::c_char) -> ::c_int;
1148 pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int;
1149 #[cfg_attr(target_os = "netbsd", link_name = "__getpwnam_r50")]
1150 #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwnam_r")]
1151 pub fn getpwnam_r(name: *const ::c_char,
1152 pwd: *mut passwd,
1153 buf: *mut ::c_char,
1154 buflen: ::size_t,
1155 result: *mut *mut passwd) -> ::c_int;
1156 #[cfg_attr(target_os = "netbsd", link_name = "__getpwuid_r50")]
1157 #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwuid_r")]
1158 pub fn getpwuid_r(uid: ::uid_t,
1159 pwd: *mut passwd,
1160 buf: *mut ::c_char,
1161 buflen: ::size_t,
1162 result: *mut *mut passwd) -> ::c_int;
1163 #[cfg_attr(all(target_os = "macos", target_arch ="x86"),
1164 link_name = "sigwait$UNIX2003")]
1165 #[cfg_attr(target_os = "solaris", link_name = "__posix_sigwait")]
1166 pub fn sigwait(set: *const sigset_t,
1167 sig: *mut ::c_int) -> ::c_int;
1168 pub fn pthread_atfork(prepare: Option<unsafe extern fn()>,
1169 parent: Option<unsafe extern fn()>,
1170 child: Option<unsafe extern fn()>) -> ::c_int;
1171 pub fn getgrgid(gid: ::gid_t) -> *mut ::group;
1172 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
1173 link_name = "popen$UNIX2003")]
1174 pub fn popen(command: *const c_char,
1175 mode: *const c_char) -> *mut ::FILE;
abe05a73
XL
1176 pub fn openpty(amaster: *mut ::c_int,
1177 aslave: *mut ::c_int,
1178 name: *mut ::c_char,
1179 termp: *mut termios,
1180 winp: *mut ::winsize) -> ::c_int;
1181 pub fn forkpty(amaster: *mut ::c_int,
1182 name: *mut ::c_char,
1183 termp: *mut termios,
1184 winp: *mut ::winsize) -> ::pid_t;
1185 pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int;
476ff2be
SL
1186}
1187
1188cfg_if! {
1189 if #[cfg(target_pointer_width = "64")] {
1190 mod b64;
1191 pub use self::b64::*;
1192 } else {
1193 mod b32;
1194 pub use self::b32::*;
1195 }
1196}