]> git.proxmox.com Git - rustc.git/blob - src/vendor/libc/src/unix/haiku/mod.rs
New upstream version 1.17.0+dfsg1
[rustc.git] / src / vendor / libc / src / unix / haiku / mod.rs
1 use dox::{mem, Option};
2
3 pub type rlim_t = ::uintptr_t;
4 pub type sa_family_t = u8;
5 pub type pthread_key_t = ::c_int;
6 pub type nfds_t = ::c_long;
7 pub type tcflag_t = ::c_uint;
8 pub type speed_t = ::c_uint;
9 pub type c_char = i8;
10 pub type clock_t = i32;
11 pub type clockid_t = i32;
12 pub type time_t = i32;
13 pub type suseconds_t = i32;
14 pub type wchar_t = i32;
15 pub type off_t = i64;
16 pub type ino_t = i64;
17 pub type blkcnt_t = i64;
18 pub type blksize_t = i32;
19 pub type dev_t = i32;
20 pub type mode_t = u32;
21 pub type nlink_t = i32;
22 pub type useconds_t = u32;
23 pub type socklen_t = u32;
24 pub type pthread_t = ::uintptr_t;
25 pub type pthread_mutexattr_t = ::uintptr_t;
26 pub type sigset_t = u64;
27 pub type fsblkcnt_t = i64;
28 pub type fsfilcnt_t = i64;
29 pub type pthread_attr_t = *mut ::c_void;
30 pub type nl_item = ::c_int;
31 pub type id_t = i32;
32 pub type idtype_t = ::c_uint;
33
34 pub enum timezone {}
35
36 s! {
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
148 pub struct cmsghdr {
149 pub cmsg_len: ::size_t,
150 pub cmsg_level: ::c_int,
151 pub cmsg_type: ::c_int,
152 }
153
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
172 pub struct stat {
173 pub st_dev: dev_t,
174 pub st_ino: ino_t,
175 pub st_mode: mode_t,
176 pub st_nlink: nlink_t,
177 pub st_uid: ::uid_t,
178 pub st_gid: ::gid_t,
179 pub st_size: off_t,
180 pub st_rdev: dev_t,
181 pub st_blksize: blksize_t,
182 pub st_atime: time_t,
183 pub st_atime_nsec: c_long,
184 pub st_mtime: time_t,
185 pub st_mtime_nsec: c_long,
186 pub st_ctime: time_t,
187 pub st_ctime_nsec: c_long,
188 pub st_crtime: time_t,
189 pub st_crtime_nsec: c_long,
190 pub st_type: u32,
191 pub st_blocks: blkcnt_t,
192 }
193
194 pub struct dirent {
195 pub d_dev: dev_t,
196 pub d_pdev: dev_t,
197 pub d_ino: ino_t,
198 pub d_pino: i64,
199 pub d_reclen: ::c_ushort,
200 pub d_name: [::c_char; 1024], // Max length is _POSIX_PATH_MAX
201 }
202
203 pub struct glob_t {
204 pub gl_pathc: ::size_t,
205 __unused1: ::size_t,
206 pub gl_offs: ::size_t,
207 __unused2: ::size_t,
208 pub gl_pathv: *mut *mut c_char,
209
210 __unused3: *mut ::c_void,
211 __unused4: *mut ::c_void,
212 __unused5: *mut ::c_void,
213 __unused6: *mut ::c_void,
214 __unused7: *mut ::c_void,
215 __unused8: *mut ::c_void,
216 }
217
218 pub struct pthread_mutex_t {
219 flags: u32,
220 lock: i32,
221 unused: i32,
222 owner: i32,
223 owner_count: i32,
224 }
225
226 pub struct pthread_cond_t {
227 flags: u32,
228 unused: i32,
229 mutex: *mut ::c_void,
230 waiter_count: i32,
231 lock: i32,
232 }
233
234 pub struct pthread_rwlock_t {
235 flags: u32,
236 owner: i32,
237 lock_sem: i32, // this is actually a union
238 lock_count: i32,
239 reader_count: i32,
240 writer_count: i32,
241 waiters: [*mut ::c_void; 2],
242 }
243
244 pub struct passwd {
245 pub pw_name: *mut ::c_char,
246 pub pw_passwd: *mut ::c_char,
247 pub pw_uid: ::uid_t,
248 pub pw_gid: ::gid_t,
249 pub pw_dir: *mut ::c_char,
250 pub pw_shell: *mut ::c_char,
251 pub pw_gecos: *mut ::c_char,
252 }
253
254 pub struct statvfs {
255 pub f_bsize: ::c_ulong,
256 pub f_frsize: ::c_ulong,
257 pub f_blocks: ::fsblkcnt_t,
258 pub f_bfree: ::fsblkcnt_t,
259 pub f_bavail: ::fsblkcnt_t,
260 pub f_files: ::fsfilcnt_t,
261 pub f_ffree: ::fsfilcnt_t,
262 pub f_favail: ::fsfilcnt_t,
263 pub f_fsid: ::c_ulong,
264 pub f_flag: ::c_ulong,
265 pub f_namemax: ::c_ulong,
266 }
267
268 pub struct stack_t {
269 pub ss_sp: *mut ::c_void,
270 pub ss_size: ::size_t,
271 pub ss_flags: ::c_int,
272 }
273
274 pub struct siginfo_t {
275 pub si_signo: ::c_int,
276 pub si_code: ::c_int,
277 pub si_errno: ::c_int,
278 pub si_pid: ::pid_t,
279 pub si_uid: ::uid_t,
280 pub si_addr: *mut ::c_void,
281 pub si_status: ::c_int,
282 pub si_band: c_long,
283 pub sigval: *mut ::c_void,
284 }
285
286 pub struct sigaction {
287 pub sa_sigaction: ::sighandler_t,
288 pub sa_mask: ::sigset_t,
289 pub sa_flags: ::c_int,
290 sa_userdata: *mut ::c_void,
291 }
292
293 pub struct sem_t {
294 pub se_type: i32,
295 pub se_named_id: i32, // this is actually a union
296 pub se_unnamed: i32,
297 pub se_padding: [i32; 4],
298 }
299
300 pub struct pthread_condattr_t {
301 pub process_shared: bool,
302 pub clock_id: i32,
303 }
304 }
305
306 // intentionally not public, only used for fd_set
307 cfg_if! {
308 if #[cfg(target_pointer_width = "32")] {
309 const ULONG_SIZE: usize = 32;
310 } else if #[cfg(target_pointer_width = "64")] {
311 const ULONG_SIZE: usize = 64;
312 } else {
313 // Unknown target_pointer_width
314 }
315 }
316
317 pub const EXIT_FAILURE: ::c_int = 1;
318 pub const EXIT_SUCCESS: ::c_int = 0;
319 pub const RAND_MAX: ::c_int = 2147483647;
320 pub const EOF: ::c_int = -1;
321 pub const SEEK_SET: ::c_int = 0;
322 pub const SEEK_CUR: ::c_int = 1;
323 pub const SEEK_END: ::c_int = 2;
324 pub const _IOFBF: ::c_int = 0;
325 pub const _IONBF: ::c_int = 2;
326 pub const _IOLBF: ::c_int = 1;
327
328 pub const F_DUPFD: ::c_int = 0x0001;
329 pub const F_GETFD: ::c_int = 0x0002;
330 pub const F_SETFD: ::c_int = 0x0004;
331 pub const F_GETFL: ::c_int = 0x0008;
332 pub const F_SETFL: ::c_int = 0x0010;
333
334 pub const SIGTRAP: ::c_int = 22;
335
336 pub const PTHREAD_CREATE_JOINABLE: ::c_int = 0;
337 pub const PTHREAD_CREATE_DETACHED: ::c_int = 1;
338
339 pub const CLOCK_REALTIME: ::c_int = -1;
340 pub const CLOCK_MONOTONIC: ::c_int = 0;
341
342 pub const RLIMIT_CORE: ::c_int = 0;
343 pub const RLIMIT_CPU: ::c_int = 1;
344 pub const RLIMIT_DATA: ::c_int = 2;
345 pub const RLIMIT_FSIZE: ::c_int = 3;
346 pub const RLIMIT_NOFILE: ::c_int = 4;
347 pub const RLIMIT_AS: ::c_int = 6;
348 // Haiku specific
349 pub const RLIMIT_NOVMON: ::c_int = 7;
350 pub const RLIMIT_NLIMITS: ::c_int = 8;
351
352 pub const RUSAGE_SELF: ::c_int = 0;
353
354 pub const NCCS: usize = 11;
355
356 pub const O_RDONLY: ::c_int = 0x0000;
357 pub const O_WRONLY: ::c_int = 0x0001;
358 pub const O_RDWR: ::c_int = 0x0002;
359 pub const O_ACCMODE: ::c_int = 0x0003;
360
361 pub const O_EXCL: ::c_int = 0x0100;
362 pub const O_CREAT: ::c_int = 0x0200;
363 pub const O_TRUNC: ::c_int = 0x0400;
364 pub const O_NOCTTY: ::c_int = 0x1000;
365 pub const O_NOTRAVERSE: ::c_int = 0x2000;
366
367 pub const O_CLOEXEC: ::c_int = 0x00000040;
368 pub const O_NONBLOCK: ::c_int = 0x00000080;
369 pub const O_APPEND: ::c_int = 0x00000800;
370 pub const O_SYNC: ::c_int = 0x00010000;
371 pub const O_RSYNC: ::c_int = 0x00020000;
372 pub const O_DSYNC: ::c_int = 0x00040000;
373 pub const O_NOFOLLOW: ::c_int = 0x00080000;
374 pub const O_NOCACHE: ::c_int = 0x00100000;
375 pub const O_DIRECTORY: ::c_int = 0x00200000;
376
377 pub const S_IFIFO: ::mode_t = 61440;
378 pub const S_IFCHR: ::mode_t = 49152;
379 pub const S_IFBLK: ::mode_t = 24576;
380 pub const S_IFDIR: ::mode_t = 16384;
381 pub const S_IFREG: ::mode_t = 32768;
382 pub const S_IFLNK: ::mode_t = 40960;
383 pub const S_IFSOCK: ::mode_t = 49152;
384 pub const S_IFMT: ::mode_t = 61440;
385 pub const S_IRWXU: ::mode_t = 448;
386 pub const S_IXUSR: ::mode_t = 64;
387 pub const S_IWUSR: ::mode_t = 128;
388 pub const S_IRUSR: ::mode_t = 256;
389 pub const S_IRWXG: ::mode_t = 70;
390 pub const S_IXGRP: ::mode_t = 10;
391 pub const S_IWGRP: ::mode_t = 20;
392 pub const S_IRGRP: ::mode_t = 40;
393 pub const S_IRWXO: ::mode_t = 7;
394 pub const S_IXOTH: ::mode_t = 1;
395 pub const S_IWOTH: ::mode_t = 2;
396 pub const S_IROTH: ::mode_t = 4;
397 pub const F_OK: ::c_int = 0;
398 pub const R_OK: ::c_int = 4;
399 pub const W_OK: ::c_int = 2;
400 pub const X_OK: ::c_int = 1;
401 pub const STDIN_FILENO: ::c_int = 0;
402 pub const STDOUT_FILENO: ::c_int = 1;
403 pub const STDERR_FILENO: ::c_int = 2;
404 pub const SIGHUP: ::c_int = 1;
405 pub const SIGINT: ::c_int = 2;
406 pub const SIGQUIT: ::c_int = 3;
407 pub const SIGILL: ::c_int = 4;
408 pub const SIGABRT: ::c_int = 6;
409 pub const SIGFPE: ::c_int = 8;
410 pub const SIGKILL: ::c_int = 9;
411 pub const SIGSEGV: ::c_int = 11;
412 pub const SIGPIPE: ::c_int = 7;
413 pub const SIGALRM: ::c_int = 14;
414 pub const SIGTERM: ::c_int = 15;
415
416 pub const EAI_SYSTEM: ::c_int = 11;
417
418 pub const PROT_NONE: ::c_int = 0;
419 pub const PROT_READ: ::c_int = 1;
420 pub const PROT_WRITE: ::c_int = 2;
421 pub const PROT_EXEC: ::c_int = 4;
422
423 pub const LC_ALL: ::c_int = 0;
424 pub const LC_COLLATE: ::c_int = 1;
425 pub const LC_CTYPE: ::c_int = 2;
426 pub const LC_MONETARY: ::c_int = 3;
427 pub const LC_NUMERIC: ::c_int = 4;
428 pub const LC_TIME: ::c_int = 5;
429 pub const LC_MESSAGES: ::c_int = 6;
430
431 // TODO: Haiku does not have MAP_FILE, but libstd/os.rs requires it
432 pub const MAP_FILE: ::c_int = 0x00;
433 pub const MAP_SHARED: ::c_int = 0x01;
434 pub const MAP_PRIVATE: ::c_int = 0x02;
435 pub const MAP_FIXED: ::c_int = 0x004;
436
437 pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void;
438
439 pub const MS_ASYNC: ::c_int = 0x01;
440 pub const MS_INVALIDATE: ::c_int = 0x04;
441 pub const MS_SYNC: ::c_int = 0x02;
442
443 pub const EPERM : ::c_int = -2147483633;
444 pub const ENOENT : ::c_int = -2147459069;
445 pub const ESRCH : ::c_int = -2147454963;
446 pub const EINTR : ::c_int = -2147483638;
447 pub const EIO : ::c_int = -2147483647;
448 pub const ENXIO : ::c_int = -2147454965;
449 pub const E2BIG : ::c_int = -2147454975;
450 pub const ENOEXEC : ::c_int = -2147478782;
451 pub const EBADF : ::c_int = -2147459072;
452 pub const ECHILD : ::c_int = -2147454974;
453 pub const EDEADLK : ::c_int = -2147454973;
454 pub const ENOMEM : ::c_int = -2147454976;
455 pub const EACCES : ::c_int = -2147483646;
456 pub const EFAULT : ::c_int = -2147478783;
457 // pub const ENOTBLK : ::c_int = 15;
458 pub const EBUSY : ::c_int = -2147483634;
459 pub const EEXIST : ::c_int = -2147459070;
460 pub const EXDEV : ::c_int = -2147459061;
461 pub const ENODEV : ::c_int = -2147454969;
462 pub const ENOTDIR : ::c_int = -2147459067;
463 pub const EISDIR : ::c_int = -2147459063;
464 pub const EINVAL : ::c_int = -2147483643;
465 pub const ENFILE : ::c_int = -2147454970;
466 pub const EMFILE : ::c_int = -2147459062;
467 pub const ENOTTY : ::c_int = -2147454966;
468 pub const ETXTBSY : ::c_int = -2147454917;
469 pub const EFBIG : ::c_int = -2147454972;
470 pub const ENOSPC : ::c_int = -2147459065;
471 pub const ESPIPE : ::c_int = -2147454964;
472 pub const EROFS : ::c_int = -2147459064;
473 pub const EMLINK : ::c_int = -2147454971;
474 pub const EPIPE : ::c_int = -2147459059;
475 pub const EDOM : ::c_int = -2147454960;
476 pub const ERANGE : ::c_int = -2147454959;
477 pub const EAGAIN : ::c_int = -2147483637;
478 pub const EWOULDBLOCK : ::c_int = -2147483637;
479
480 pub const EINPROGRESS : ::c_int = -2147454940;
481 pub const EALREADY : ::c_int = -2147454939;
482 pub const ENOTSOCK : ::c_int = -2147454932;
483 pub const EDESTADDRREQ : ::c_int = -2147454928;
484 pub const EMSGSIZE : ::c_int = -2147454934;
485 pub const EPROTOTYPE : ::c_int = -2147454958;
486 pub const ENOPROTOOPT : ::c_int = -2147454942;
487 pub const EPROTONOSUPPORT : ::c_int = -2147454957;
488 pub const EOPNOTSUPP : ::c_int = -2147454933;
489 pub const EPFNOSUPPORT : ::c_int = -2147454956;
490 pub const EAFNOSUPPORT : ::c_int = -2147454955;
491 pub const EADDRINUSE : ::c_int = -2147454954;
492 pub const EADDRNOTAVAIL : ::c_int = -2147454953;
493 pub const ENETDOWN : ::c_int = -2147454953;
494 pub const ENETUNREACH : ::c_int = -2147454951;
495 pub const ENETRESET : ::c_int = -2147454950;
496 pub const ECONNABORTED : ::c_int = -2147454949;
497 pub const ECONNRESET : ::c_int = -2147454948;
498 pub const ENOBUFS : ::c_int = -2147454941;
499 pub const EISCONN : ::c_int = -2147454947;
500 pub const ENOTCONN : ::c_int = -2147454946;
501 pub const ESHUTDOWN : ::c_int = -2147454945;
502 pub const ETIMEDOUT : ::c_int = -2147483639;
503 pub const ECONNREFUSED : ::c_int = -2147454944;
504 pub const ELOOP : ::c_int = -2147459060;
505 pub const ENAMETOOLONG : ::c_int = -2147459068;
506 pub const EHOSTDOWN : ::c_int = -2147454931;
507 pub const EHOSTUNREACH : ::c_int = -2147454943;
508 pub const ENOTEMPTY : ::c_int = -2147459066;
509 pub const EDQUOT : ::c_int = -2147454927;
510 pub const ESTALE : ::c_int = -2147454936;
511 pub const ENOLCK : ::c_int = -2147454968;
512 pub const ENOSYS : ::c_int = -2147454967;
513 pub const EIDRM : ::c_int = -2147454926;
514 pub const ENOMSG : ::c_int = -2147454937;
515 pub const EOVERFLOW : ::c_int = -2147454935;
516 pub const ECANCELED : ::c_int = -2147454929;
517 pub const EILSEQ : ::c_int = -2147454938;
518 pub const ENOATTR : ::c_int = -2147454916;
519 pub const EBADMSG : ::c_int = -2147454930;
520 pub const EMULTIHOP : ::c_int = -2147454925;
521 pub const ENOLINK : ::c_int = -2147454923;
522 pub const EPROTO : ::c_int = -2147454919;
523
524 pub const IPPROTO_RAW: ::c_int = 255;
525
526 // These are prefixed with POSIX_ on Haiku
527 pub const MADV_NORMAL: ::c_int = 1;
528 pub const MADV_SEQUENTIAL: ::c_int = 2;
529 pub const MADV_RANDOM: ::c_int = 3;
530 pub const MADV_WILLNEED: ::c_int = 4;
531 pub const MADV_DONTNEED: ::c_int = 5;
532
533 pub const IFF_LOOPBACK: ::c_int = 0x0008;
534
535 pub const AF_UNIX: ::c_int = 9;
536 pub const AF_INET: ::c_int = 1;
537 pub const AF_INET6: ::c_int = 6;
538 pub const SOCK_RAW: ::c_int = 3;
539 pub const IPPROTO_ICMP: ::c_int = 1;
540 pub const IPPROTO_ICMPV6: ::c_int = 58;
541 pub const IPPROTO_TCP: ::c_int = 6;
542 pub const IPPROTO_IP: ::c_int = 0;
543 pub const IPPROTO_IPV6: ::c_int = 41;
544 pub const IP_MULTICAST_TTL: ::c_int = 10;
545 pub const IP_MULTICAST_LOOP: ::c_int = 11;
546 pub const IP_TTL: ::c_int = 4;
547 pub const IP_HDRINCL: ::c_int = 2;
548 pub const IP_ADD_MEMBERSHIP: ::c_int = 12;
549 pub const IP_DROP_MEMBERSHIP: ::c_int = 13;
550
551 pub const TCP_NODELAY: ::c_int = 0x01;
552 pub const TCP_MAXSEG: ::c_int = 0x02;
553 pub const TCP_NOPUSH: ::c_int = 0x04;
554 pub const TCP_NOOPT: ::c_int = 0x08;
555
556 pub const IPV6_MULTICAST_LOOP: ::c_int = 26;
557 pub const IPV6_JOIN_GROUP: ::c_int = 28;
558 pub const IPV6_LEAVE_GROUP: ::c_int = 29;
559 pub const IPV6_V6ONLY: ::c_int = 30;
560
561 pub const SO_DEBUG: ::c_int = 0x00000004;
562
563 pub const MSG_PEEK: ::c_int = 0x2;
564 pub const MSG_NOSIGNAL: ::c_int = 0x0800;
565
566 pub const SHUT_RD: ::c_int = 0;
567 pub const SHUT_WR: ::c_int = 1;
568 pub const SHUT_RDWR: ::c_int = 2;
569
570 pub const LOCK_SH: ::c_int = 0x01;
571 pub const LOCK_EX: ::c_int = 0x02;
572 pub const LOCK_NB: ::c_int = 0x04;
573 pub const LOCK_UN: ::c_int = 0x08;
574
575 pub const SIGSTKSZ: ::size_t = 16384;
576
577 pub const SA_NODEFER: ::c_int = 0x08;
578 pub const SA_RESETHAND: ::c_int = 0x04;
579 pub const SA_RESTART: ::c_int = 0x10;
580 pub const SA_NOCLDSTOP: ::c_int = 0x01;
581
582 pub const FD_SETSIZE: usize = 1024;
583
584 pub const RTLD_NOW: ::c_int = 0x1;
585 pub const RTLD_DEFAULT: *mut ::c_void = 0isize as *mut ::c_void;
586
587 pub const BUFSIZ: ::c_uint = 8192;
588 pub const FILENAME_MAX: ::c_uint = 256;
589 pub const FOPEN_MAX: ::c_uint = 128;
590 pub const L_tmpnam: ::c_uint = 512;
591 pub const TMP_MAX: ::c_uint = 32768;
592 pub const _PC_NAME_MAX: ::c_int = 4;
593
594 pub const FIONBIO: ::c_int = 0xbe000000;
595
596 pub const _SC_IOV_MAX : ::c_int = 32;
597 pub const _SC_GETGR_R_SIZE_MAX : ::c_int = 25;
598 pub const _SC_GETPW_R_SIZE_MAX : ::c_int = 26;
599 pub const _SC_PAGESIZE : ::c_int = 27;
600 pub const _SC_THREAD_ATTR_STACKADDR : ::c_int = 48;
601 pub const _SC_THREAD_ATTR_STACKSIZE : ::c_int = 49;
602 pub const _SC_THREAD_PRIORITY_SCHEDULING : ::c_int = 50;
603 pub const _SC_THREAD_PROCESS_SHARED : ::c_int = 46;
604 pub const _SC_THREAD_STACK_MIN : ::c_int = 47;
605 pub const _SC_THREADS : ::c_int = 31;
606 pub const _SC_ATEXIT_MAX : ::c_int = 37;
607
608 pub const PTHREAD_STACK_MIN: ::size_t = 8192;
609
610 pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
611 flags: 0,
612 lock: 0,
613 unused: -42,
614 owner: -1,
615 owner_count: 0,
616 };
617 pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
618 flags: 0,
619 unused: -42,
620 mutex: 0 as *mut _,
621 waiter_count: 0,
622 lock: 0,
623 };
624 pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
625 flags: 0,
626 owner: 0,
627 lock_sem: 0,
628 lock_count: 0,
629 reader_count: 0,
630 writer_count: 0,
631 waiters: [0 as *mut _; 2],
632 };
633
634 pub const PTHREAD_MUTEX_DEFAULT: ::c_int = 0;
635 pub const PTHREAD_MUTEX_NORMAL: ::c_int = 1;
636 pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2;
637 pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 3;
638
639 pub const FIOCLEX: c_ulong = 0; // TODO: does not exist on Haiku!
640
641 pub const SA_ONSTACK: c_ulong = 0x20;
642 pub const SA_SIGINFO: c_ulong = 0x40;
643 pub const SA_NOCLDWAIT: c_ulong = 0x02;
644
645 pub const SIGCHLD: ::c_int = 5;
646 pub const SIGBUS: ::c_int = 30;
647 pub const SIG_SETMASK: ::c_int = 3;
648
649 pub const RUSAGE_CHILDREN: ::c_int = -1;
650
651 pub const SOCK_STREAM: ::c_int = 1;
652 pub const SOCK_DGRAM: ::c_int = 2;
653
654 pub const SOL_SOCKET: ::c_int = -1;
655 pub const SO_ACCEPTCONN: ::c_int = 0x00000001;
656 pub const SO_BROADCAST: ::c_int = 0x00000002;
657 pub const SO_DONTROUTE: ::c_int = 0x00000008;
658 pub const SO_KEEPALIVE: ::c_int = 0x00000010;
659 pub const SO_OOBINLINE: ::c_int = 0x00000020;
660 pub const SO_REUSEADDR: ::c_int = 0x00000040;
661 pub const SO_REUSEPORT: ::c_int = 0x00000080;
662 pub const SO_USELOOPBACK: ::c_int = 0x00000100;
663 pub const SO_LINGER: ::c_int = 0x00000200;
664 pub const SO_SNDBUF: ::c_int = 0x40000001;
665 pub const SO_SNDLOWAT: ::c_int = 0x40000002;
666 pub const SO_SNDTIMEO: ::c_int = 0x40000003;
667 pub const SO_RCVBUF: ::c_int = 0x40000004;
668 pub const SO_RCVLOWAT: ::c_int = 0x40000005;
669 pub const SO_RCVTIMEO: ::c_int = 0x40000006;
670 pub const SO_ERROR: ::c_int = 0x40000007;
671 pub const SO_TYPE: ::c_int = 0x40000008;
672 pub const SO_NONBLOCK: ::c_int = 0x40000009;
673 pub const SO_BINDTODEVICE: ::c_int = 0x4000000a;
674 pub const SO_PEERCRED: ::c_int = 0x4000000b;
675
676 pub const NI_MAXHOST: ::size_t = 1025;
677
678 pub const WNOHANG: ::c_int = 0x01;
679 pub const WUNTRACED: ::c_int = 0x02;
680 pub const WCONTINUED: ::c_int = 0x04;
681 pub const WEXITED: ::c_int = 0x08;
682 pub const WSTOPPED: ::c_int = 0x10;
683 pub const WNOWAIT: ::c_int = 0x20;
684
685 pub const P_ALL: idtype_t = 0;
686 pub const P_PID: idtype_t = 1;
687 pub const P_PGID: idtype_t = 2;
688
689 f! {
690 pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () {
691 let fd = fd as usize;
692 let size = mem::size_of_val(&(*set).fds_bits[0]) * 8;
693 (*set).fds_bits[fd / size] &= !(1 << (fd % size));
694 return
695 }
696
697 pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool {
698 let fd = fd as usize;
699 let size = mem::size_of_val(&(*set).fds_bits[0]) * 8;
700 return ((*set).fds_bits[fd / size] & (1 << (fd % size))) != 0
701 }
702
703 pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () {
704 let fd = fd as usize;
705 let size = mem::size_of_val(&(*set).fds_bits[0]) * 8;
706 (*set).fds_bits[fd / size] |= 1 << (fd % size);
707 return
708 }
709
710 pub fn FD_ZERO(set: *mut fd_set) -> () {
711 for slot in (*set).fds_bits.iter_mut() {
712 *slot = 0;
713 }
714 }
715
716 pub fn WIFEXITED(status: ::c_int) -> bool {
717 (status >> 8) == 0
718 }
719
720 pub fn WEXITSTATUS(status: ::c_int) -> ::c_int {
721 (status & 0xff)
722 }
723
724 pub fn WTERMSIG(status: ::c_int) -> ::c_int {
725 (status >> 8) & 0xff
726 }
727 }
728
729 extern {
730 pub fn clock_gettime(clk_id: ::c_int, tp: *mut ::timespec) -> ::c_int;
731 pub fn clock_settime(clk_id: ::c_int, tp: *const ::timespec) -> ::c_int;
732 pub fn pthread_attr_getguardsize(attr: *const ::pthread_attr_t,
733 guardsize: *mut ::size_t) -> ::c_int;
734 pub fn pthread_attr_getstack(attr: *const ::pthread_attr_t,
735 stackaddr: *mut *mut ::c_void,
736 stacksize: *mut ::size_t) -> ::c_int;
737 pub fn pthread_condattr_getclock(attr: *const pthread_condattr_t,
738 clock_id: *mut clockid_t) -> ::c_int;
739 pub fn pthread_condattr_setclock(attr: *mut pthread_condattr_t,
740 clock_id: clockid_t) -> ::c_int;
741 pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void;
742 pub fn setgroups(ngroups: ::size_t,
743 ptr: *const ::gid_t) -> ::c_int;
744 pub fn getpwuid_r(uid: ::uid_t,
745 pwd: *mut passwd,
746 buffer: *mut ::c_char,
747 bufferSize: ::size_t,
748 result: *mut *mut passwd) -> ::c_int;
749 pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int;
750 pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int)
751 -> ::c_int;
752 pub fn getnameinfo(sa: *const ::sockaddr,
753 salen: ::socklen_t,
754 host: *mut ::c_char,
755 hostlen: ::size_t,
756 serv: *mut ::c_char,
757 sevlen: ::size_t,
758 flags: ::c_int) -> ::c_int;
759 pub fn pthread_mutex_timedlock(lock: *mut pthread_mutex_t,
760 abstime: *const ::timespec) -> ::c_int;
761 pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t,
762 options: ::c_int) -> ::c_int;
763
764 pub fn glob(pattern: *const ::c_char,
765 flags: ::c_int,
766 errfunc: Option<extern fn(epath: *const ::c_char,
767 errno: ::c_int) -> ::c_int>,
768 pglob: *mut ::glob_t) -> ::c_int;
769 pub fn globfree(pglob: *mut ::glob_t);
770
771 pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int)
772 -> ::c_int;
773
774 pub fn shm_unlink(name: *const ::c_char) -> ::c_int;
775
776 pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long);
777
778 pub fn telldir(dirp: *mut ::DIR) -> ::c_long;
779 pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int)
780 -> ::c_int;
781
782 pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int;
783
784 pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t,
785 flags: ::c_int, addr: *mut ::sockaddr,
786 addrlen: *mut ::socklen_t) -> ::ssize_t;
787 pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int;
788 pub fn futimes(fd: ::c_int, times: *const ::timeval) -> ::c_int;
789 pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char;
790
791 pub fn bind(socket: ::c_int, address: *const ::sockaddr,
792 address_len: ::socklen_t) -> ::c_int;
793
794 pub fn writev(fd: ::c_int,
795 iov: *const ::iovec,
796 iovcnt: ::c_int) -> ::ssize_t;
797 pub fn readv(fd: ::c_int,
798 iov: *const ::iovec,
799 iovcnt: ::c_int) -> ::ssize_t;
800
801 pub fn sendmsg(fd: ::c_int,
802 msg: *const ::msghdr,
803 flags: ::c_int) -> ::ssize_t;
804 pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int)
805 -> ::ssize_t;
806 }
807
808 cfg_if! {
809 if #[cfg(target_pointer_width = "64")] {
810 mod b64;
811 pub use self::b64::*;
812 } else {
813 mod b32;
814 pub use self::b32::*;
815 }
816 }