]> git.proxmox.com Git - rustc.git/blame - src/liblibc/src/unix/haiku/mod.rs
New upstream version 1.18.0+dfsg1
[rustc.git] / src / liblibc / src / unix / haiku / mod.rs
CommitLineData
cc61c64b 1use dox::{mem, Option};
9e0c209e
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;
12pub type time_t = i32;
13pub type suseconds_t = i32;
14pub type wchar_t = i32;
15pub type off_t = i64;
16pub type ino_t = i64;
17pub type blkcnt_t = i64;
18pub type blksize_t = i32;
19pub type dev_t = i32;
20pub type mode_t = u32;
21pub type nlink_t = i32;
22pub type useconds_t = u32;
23pub type socklen_t = u32;
24pub type pthread_t = ::uintptr_t;
25pub type pthread_mutexattr_t = ::uintptr_t;
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;
9e0c209e
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
32a655c1
SL
148 pub struct cmsghdr {
149 pub cmsg_len: ::size_t,
150 pub cmsg_level: ::c_int,
151 pub cmsg_type: ::c_int,
152 }
153
9e0c209e
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
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
307cfg_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
317pub const EXIT_FAILURE: ::c_int = 1;
318pub const EXIT_SUCCESS: ::c_int = 0;
319pub const RAND_MAX: ::c_int = 2147483647;
320pub const EOF: ::c_int = -1;
321pub const SEEK_SET: ::c_int = 0;
322pub const SEEK_CUR: ::c_int = 1;
323pub const SEEK_END: ::c_int = 2;
324pub const _IOFBF: ::c_int = 0;
325pub const _IONBF: ::c_int = 2;
326pub const _IOLBF: ::c_int = 1;
327
328pub const F_DUPFD: ::c_int = 0x0001;
329pub const F_GETFD: ::c_int = 0x0002;
330pub const F_SETFD: ::c_int = 0x0004;
331pub const F_GETFL: ::c_int = 0x0008;
332pub const F_SETFL: ::c_int = 0x0010;
333
334pub const SIGTRAP: ::c_int = 22;
335
336pub const PTHREAD_CREATE_JOINABLE: ::c_int = 0;
337pub const PTHREAD_CREATE_DETACHED: ::c_int = 1;
338
339pub const CLOCK_REALTIME: ::c_int = -1;
340pub const CLOCK_MONOTONIC: ::c_int = 0;
341
342pub const RLIMIT_CORE: ::c_int = 0;
343pub const RLIMIT_CPU: ::c_int = 1;
344pub const RLIMIT_DATA: ::c_int = 2;
345pub const RLIMIT_FSIZE: ::c_int = 3;
346pub const RLIMIT_NOFILE: ::c_int = 4;
347pub const RLIMIT_AS: ::c_int = 6;
348// Haiku specific
349pub const RLIMIT_NOVMON: ::c_int = 7;
350pub const RLIMIT_NLIMITS: ::c_int = 8;
351
352pub const RUSAGE_SELF: ::c_int = 0;
353
354pub const NCCS: usize = 11;
355
356pub const O_RDONLY: ::c_int = 0x0000;
357pub const O_WRONLY: ::c_int = 0x0001;
358pub const O_RDWR: ::c_int = 0x0002;
359pub const O_ACCMODE: ::c_int = 0x0003;
360
361pub const O_EXCL: ::c_int = 0x0100;
362pub const O_CREAT: ::c_int = 0x0200;
363pub const O_TRUNC: ::c_int = 0x0400;
364pub const O_NOCTTY: ::c_int = 0x1000;
365pub const O_NOTRAVERSE: ::c_int = 0x2000;
366
367pub const O_CLOEXEC: ::c_int = 0x00000040;
368pub const O_NONBLOCK: ::c_int = 0x00000080;
369pub const O_APPEND: ::c_int = 0x00000800;
370pub const O_SYNC: ::c_int = 0x00010000;
371pub const O_RSYNC: ::c_int = 0x00020000;
372pub const O_DSYNC: ::c_int = 0x00040000;
373pub const O_NOFOLLOW: ::c_int = 0x00080000;
374pub const O_NOCACHE: ::c_int = 0x00100000;
375pub const O_DIRECTORY: ::c_int = 0x00200000;
376
377pub const S_IFIFO: ::mode_t = 61440;
378pub const S_IFCHR: ::mode_t = 49152;
379pub const S_IFBLK: ::mode_t = 24576;
380pub const S_IFDIR: ::mode_t = 16384;
381pub const S_IFREG: ::mode_t = 32768;
382pub const S_IFLNK: ::mode_t = 40960;
383pub const S_IFSOCK: ::mode_t = 49152;
384pub const S_IFMT: ::mode_t = 61440;
385pub const S_IRWXU: ::mode_t = 448;
386pub const S_IXUSR: ::mode_t = 64;
387pub const S_IWUSR: ::mode_t = 128;
388pub const S_IRUSR: ::mode_t = 256;
389pub const S_IRWXG: ::mode_t = 70;
390pub const S_IXGRP: ::mode_t = 10;
391pub const S_IWGRP: ::mode_t = 20;
392pub const S_IRGRP: ::mode_t = 40;
393pub const S_IRWXO: ::mode_t = 7;
394pub const S_IXOTH: ::mode_t = 1;
395pub const S_IWOTH: ::mode_t = 2;
396pub const S_IROTH: ::mode_t = 4;
397pub const F_OK: ::c_int = 0;
398pub const R_OK: ::c_int = 4;
399pub const W_OK: ::c_int = 2;
400pub const X_OK: ::c_int = 1;
401pub const STDIN_FILENO: ::c_int = 0;
402pub const STDOUT_FILENO: ::c_int = 1;
403pub const STDERR_FILENO: ::c_int = 2;
404pub const SIGHUP: ::c_int = 1;
405pub const SIGINT: ::c_int = 2;
406pub const SIGQUIT: ::c_int = 3;
407pub const SIGILL: ::c_int = 4;
408pub const SIGABRT: ::c_int = 6;
409pub const SIGFPE: ::c_int = 8;
410pub const SIGKILL: ::c_int = 9;
411pub const SIGSEGV: ::c_int = 11;
412pub const SIGPIPE: ::c_int = 7;
413pub const SIGALRM: ::c_int = 14;
414pub const SIGTERM: ::c_int = 15;
415
416pub const EAI_SYSTEM: ::c_int = 11;
417
418pub const PROT_NONE: ::c_int = 0;
419pub const PROT_READ: ::c_int = 1;
420pub const PROT_WRITE: ::c_int = 2;
421pub const PROT_EXEC: ::c_int = 4;
422
423pub const LC_ALL: ::c_int = 0;
424pub const LC_COLLATE: ::c_int = 1;
425pub const LC_CTYPE: ::c_int = 2;
426pub const LC_MONETARY: ::c_int = 3;
427pub const LC_NUMERIC: ::c_int = 4;
428pub const LC_TIME: ::c_int = 5;
429pub const LC_MESSAGES: ::c_int = 6;
430
431// TODO: Haiku does not have MAP_FILE, but libstd/os.rs requires it
432pub const MAP_FILE: ::c_int = 0x00;
433pub const MAP_SHARED: ::c_int = 0x01;
434pub const MAP_PRIVATE: ::c_int = 0x02;
435pub const MAP_FIXED: ::c_int = 0x004;
436
437pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void;
438
439pub const MS_ASYNC: ::c_int = 0x01;
440pub const MS_INVALIDATE: ::c_int = 0x04;
441pub const MS_SYNC: ::c_int = 0x02;
442
443pub const EPERM : ::c_int = -2147483633;
444pub const ENOENT : ::c_int = -2147459069;
445pub const ESRCH : ::c_int = -2147454963;
446pub const EINTR : ::c_int = -2147483638;
447pub const EIO : ::c_int = -2147483647;
448pub const ENXIO : ::c_int = -2147454965;
449pub const E2BIG : ::c_int = -2147454975;
450pub const ENOEXEC : ::c_int = -2147478782;
451pub const EBADF : ::c_int = -2147459072;
452pub const ECHILD : ::c_int = -2147454974;
453pub const EDEADLK : ::c_int = -2147454973;
454pub const ENOMEM : ::c_int = -2147454976;
455pub const EACCES : ::c_int = -2147483646;
456pub const EFAULT : ::c_int = -2147478783;
457// pub const ENOTBLK : ::c_int = 15;
458pub const EBUSY : ::c_int = -2147483634;
459pub const EEXIST : ::c_int = -2147459070;
460pub const EXDEV : ::c_int = -2147459061;
461pub const ENODEV : ::c_int = -2147454969;
462pub const ENOTDIR : ::c_int = -2147459067;
463pub const EISDIR : ::c_int = -2147459063;
464pub const EINVAL : ::c_int = -2147483643;
465pub const ENFILE : ::c_int = -2147454970;
466pub const EMFILE : ::c_int = -2147459062;
467pub const ENOTTY : ::c_int = -2147454966;
468pub const ETXTBSY : ::c_int = -2147454917;
469pub const EFBIG : ::c_int = -2147454972;
470pub const ENOSPC : ::c_int = -2147459065;
471pub const ESPIPE : ::c_int = -2147454964;
472pub const EROFS : ::c_int = -2147459064;
473pub const EMLINK : ::c_int = -2147454971;
474pub const EPIPE : ::c_int = -2147459059;
475pub const EDOM : ::c_int = -2147454960;
476pub const ERANGE : ::c_int = -2147454959;
477pub const EAGAIN : ::c_int = -2147483637;
478pub const EWOULDBLOCK : ::c_int = -2147483637;
479
480pub const EINPROGRESS : ::c_int = -2147454940;
481pub const EALREADY : ::c_int = -2147454939;
482pub const ENOTSOCK : ::c_int = -2147454932;
483pub const EDESTADDRREQ : ::c_int = -2147454928;
484pub const EMSGSIZE : ::c_int = -2147454934;
485pub const EPROTOTYPE : ::c_int = -2147454958;
486pub const ENOPROTOOPT : ::c_int = -2147454942;
487pub const EPROTONOSUPPORT : ::c_int = -2147454957;
488pub const EOPNOTSUPP : ::c_int = -2147454933;
489pub const EPFNOSUPPORT : ::c_int = -2147454956;
490pub const EAFNOSUPPORT : ::c_int = -2147454955;
491pub const EADDRINUSE : ::c_int = -2147454954;
492pub const EADDRNOTAVAIL : ::c_int = -2147454953;
493pub const ENETDOWN : ::c_int = -2147454953;
494pub const ENETUNREACH : ::c_int = -2147454951;
495pub const ENETRESET : ::c_int = -2147454950;
496pub const ECONNABORTED : ::c_int = -2147454949;
497pub const ECONNRESET : ::c_int = -2147454948;
498pub const ENOBUFS : ::c_int = -2147454941;
499pub const EISCONN : ::c_int = -2147454947;
500pub const ENOTCONN : ::c_int = -2147454946;
501pub const ESHUTDOWN : ::c_int = -2147454945;
502pub const ETIMEDOUT : ::c_int = -2147483639;
503pub const ECONNREFUSED : ::c_int = -2147454944;
504pub const ELOOP : ::c_int = -2147459060;
505pub const ENAMETOOLONG : ::c_int = -2147459068;
506pub const EHOSTDOWN : ::c_int = -2147454931;
507pub const EHOSTUNREACH : ::c_int = -2147454943;
508pub const ENOTEMPTY : ::c_int = -2147459066;
509pub const EDQUOT : ::c_int = -2147454927;
510pub const ESTALE : ::c_int = -2147454936;
511pub const ENOLCK : ::c_int = -2147454968;
512pub const ENOSYS : ::c_int = -2147454967;
513pub const EIDRM : ::c_int = -2147454926;
514pub const ENOMSG : ::c_int = -2147454937;
515pub const EOVERFLOW : ::c_int = -2147454935;
516pub const ECANCELED : ::c_int = -2147454929;
517pub const EILSEQ : ::c_int = -2147454938;
518pub const ENOATTR : ::c_int = -2147454916;
519pub const EBADMSG : ::c_int = -2147454930;
520pub const EMULTIHOP : ::c_int = -2147454925;
521pub const ENOLINK : ::c_int = -2147454923;
522pub const EPROTO : ::c_int = -2147454919;
523
524pub const IPPROTO_RAW: ::c_int = 255;
525
526// These are prefixed with POSIX_ on Haiku
527pub const MADV_NORMAL: ::c_int = 1;
528pub const MADV_SEQUENTIAL: ::c_int = 2;
529pub const MADV_RANDOM: ::c_int = 3;
530pub const MADV_WILLNEED: ::c_int = 4;
531pub const MADV_DONTNEED: ::c_int = 5;
532
533pub const IFF_LOOPBACK: ::c_int = 0x0008;
534
535pub const AF_UNIX: ::c_int = 9;
536pub const AF_INET: ::c_int = 1;
537pub const AF_INET6: ::c_int = 6;
538pub const SOCK_RAW: ::c_int = 3;
8bb4bdeb
XL
539pub const IPPROTO_ICMP: ::c_int = 1;
540pub const IPPROTO_ICMPV6: ::c_int = 58;
9e0c209e
SL
541pub const IPPROTO_TCP: ::c_int = 6;
542pub const IPPROTO_IP: ::c_int = 0;
543pub const IPPROTO_IPV6: ::c_int = 41;
544pub const IP_MULTICAST_TTL: ::c_int = 10;
545pub const IP_MULTICAST_LOOP: ::c_int = 11;
546pub const IP_TTL: ::c_int = 4;
547pub const IP_HDRINCL: ::c_int = 2;
548pub const IP_ADD_MEMBERSHIP: ::c_int = 12;
549pub const IP_DROP_MEMBERSHIP: ::c_int = 13;
550
551pub const TCP_NODELAY: ::c_int = 0x01;
552pub const TCP_MAXSEG: ::c_int = 0x02;
553pub const TCP_NOPUSH: ::c_int = 0x04;
554pub const TCP_NOOPT: ::c_int = 0x08;
555
556pub const IPV6_MULTICAST_LOOP: ::c_int = 26;
557pub const IPV6_JOIN_GROUP: ::c_int = 28;
558pub const IPV6_LEAVE_GROUP: ::c_int = 29;
559pub const IPV6_V6ONLY: ::c_int = 30;
560
561pub const SO_DEBUG: ::c_int = 0x00000004;
562
8bb4bdeb 563pub const MSG_PEEK: ::c_int = 0x2;
9e0c209e
SL
564pub const MSG_NOSIGNAL: ::c_int = 0x0800;
565
566pub const SHUT_RD: ::c_int = 0;
567pub const SHUT_WR: ::c_int = 1;
568pub const SHUT_RDWR: ::c_int = 2;
569
570pub const LOCK_SH: ::c_int = 0x01;
571pub const LOCK_EX: ::c_int = 0x02;
572pub const LOCK_NB: ::c_int = 0x04;
573pub const LOCK_UN: ::c_int = 0x08;
574
575pub const SIGSTKSZ: ::size_t = 16384;
576
577pub const SA_NODEFER: ::c_int = 0x08;
578pub const SA_RESETHAND: ::c_int = 0x04;
579pub const SA_RESTART: ::c_int = 0x10;
580pub const SA_NOCLDSTOP: ::c_int = 0x01;
581
582pub const FD_SETSIZE: usize = 1024;
583
584pub const RTLD_NOW: ::c_int = 0x1;
585pub const RTLD_DEFAULT: *mut ::c_void = 0isize as *mut ::c_void;
586
587pub const BUFSIZ: ::c_uint = 8192;
588pub const FILENAME_MAX: ::c_uint = 256;
589pub const FOPEN_MAX: ::c_uint = 128;
590pub const L_tmpnam: ::c_uint = 512;
591pub const TMP_MAX: ::c_uint = 32768;
592pub const _PC_NAME_MAX: ::c_int = 4;
593
594pub const FIONBIO: ::c_int = 0xbe000000;
595
596pub const _SC_IOV_MAX : ::c_int = 32;
597pub const _SC_GETGR_R_SIZE_MAX : ::c_int = 25;
598pub const _SC_GETPW_R_SIZE_MAX : ::c_int = 26;
599pub const _SC_PAGESIZE : ::c_int = 27;
600pub const _SC_THREAD_ATTR_STACKADDR : ::c_int = 48;
601pub const _SC_THREAD_ATTR_STACKSIZE : ::c_int = 49;
602pub const _SC_THREAD_PRIORITY_SCHEDULING : ::c_int = 50;
603pub const _SC_THREAD_PROCESS_SHARED : ::c_int = 46;
604pub const _SC_THREAD_STACK_MIN : ::c_int = 47;
605pub const _SC_THREADS : ::c_int = 31;
606pub const _SC_ATEXIT_MAX : ::c_int = 37;
607
608pub const PTHREAD_STACK_MIN: ::size_t = 8192;
609
610pub 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};
617pub 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};
624pub 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
634pub const PTHREAD_MUTEX_DEFAULT: ::c_int = 0;
635pub const PTHREAD_MUTEX_NORMAL: ::c_int = 1;
636pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2;
637pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 3;
638
639pub const FIOCLEX: c_ulong = 0; // TODO: does not exist on Haiku!
640
641pub const SA_ONSTACK: c_ulong = 0x20;
642pub const SA_SIGINFO: c_ulong = 0x40;
643pub const SA_NOCLDWAIT: c_ulong = 0x02;
644
645pub const SIGCHLD: ::c_int = 5;
646pub const SIGBUS: ::c_int = 30;
647pub const SIG_SETMASK: ::c_int = 3;
648
649pub const RUSAGE_CHILDREN: ::c_int = -1;
650
651pub const SOCK_STREAM: ::c_int = 1;
652pub const SOCK_DGRAM: ::c_int = 2;
653
654pub const SOL_SOCKET: ::c_int = -1;
655pub const SO_ACCEPTCONN: ::c_int = 0x00000001;
656pub const SO_BROADCAST: ::c_int = 0x00000002;
657pub const SO_DONTROUTE: ::c_int = 0x00000008;
658pub const SO_KEEPALIVE: ::c_int = 0x00000010;
659pub const SO_OOBINLINE: ::c_int = 0x00000020;
660pub const SO_REUSEADDR: ::c_int = 0x00000040;
661pub const SO_REUSEPORT: ::c_int = 0x00000080;
662pub const SO_USELOOPBACK: ::c_int = 0x00000100;
663pub const SO_LINGER: ::c_int = 0x00000200;
664pub const SO_SNDBUF: ::c_int = 0x40000001;
665pub const SO_SNDLOWAT: ::c_int = 0x40000002;
666pub const SO_SNDTIMEO: ::c_int = 0x40000003;
667pub const SO_RCVBUF: ::c_int = 0x40000004;
668pub const SO_RCVLOWAT: ::c_int = 0x40000005;
669pub const SO_RCVTIMEO: ::c_int = 0x40000006;
670pub const SO_ERROR: ::c_int = 0x40000007;
671pub const SO_TYPE: ::c_int = 0x40000008;
672pub const SO_NONBLOCK: ::c_int = 0x40000009;
673pub const SO_BINDTODEVICE: ::c_int = 0x4000000a;
674pub const SO_PEERCRED: ::c_int = 0x4000000b;
675
676pub const NI_MAXHOST: ::size_t = 1025;
677
8bb4bdeb
XL
678pub const WNOHANG: ::c_int = 0x01;
679pub const WUNTRACED: ::c_int = 0x02;
680pub const WCONTINUED: ::c_int = 0x04;
681pub const WEXITED: ::c_int = 0x08;
682pub const WSTOPPED: ::c_int = 0x10;
683pub const WNOWAIT: ::c_int = 0x20;
684
685pub const P_ALL: idtype_t = 0;
686pub const P_PID: idtype_t = 1;
687pub const P_PGID: idtype_t = 2;
688
9e0c209e
SL
689f! {
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
729extern {
730 pub fn clock_gettime(clk_id: ::c_int, tp: *mut ::timespec) -> ::c_int;
32a655c1 731 pub fn clock_settime(clk_id: ::c_int, tp: *const ::timespec) -> ::c_int;
9e0c209e
SL
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;
8bb4bdeb
XL
761 pub fn waitid(idtype: idtype_t, id: id_t, infop: *mut ::siginfo_t,
762 options: ::c_int) -> ::c_int;
cc61c64b
XL
763
764 pub fn fdopendir(fd: ::c_int) -> *mut ::DIR;
765 pub fn glob(pattern: *const ::c_char,
766 flags: ::c_int,
767 errfunc: Option<extern fn(epath: *const ::c_char,
768 errno: ::c_int) -> ::c_int>,
769 pglob: *mut ::glob_t) -> ::c_int;
770 pub fn globfree(pglob: *mut ::glob_t);
771
772 pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int)
773 -> ::c_int;
774
775 pub fn shm_unlink(name: *const ::c_char) -> ::c_int;
776
777 pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long);
778
779 pub fn telldir(dirp: *mut ::DIR) -> ::c_long;
780 pub fn madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int)
781 -> ::c_int;
782
783 pub fn msync(addr: *mut ::c_void, len: ::size_t, flags: ::c_int) -> ::c_int;
784
785 pub fn recvfrom(socket: ::c_int, buf: *mut ::c_void, len: ::size_t,
786 flags: ::c_int, addr: *mut ::sockaddr,
787 addrlen: *mut ::socklen_t) -> ::ssize_t;
788 pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int;
789 pub fn futimes(fd: ::c_int, times: *const ::timeval) -> ::c_int;
790 pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char;
791
792 pub fn bind(socket: ::c_int, address: *const ::sockaddr,
793 address_len: ::socklen_t) -> ::c_int;
794
795 pub fn writev(fd: ::c_int,
796 iov: *const ::iovec,
797 iovcnt: ::c_int) -> ::ssize_t;
798 pub fn readv(fd: ::c_int,
799 iov: *const ::iovec,
800 iovcnt: ::c_int) -> ::ssize_t;
801
802 pub fn sendmsg(fd: ::c_int,
803 msg: *const ::msghdr,
804 flags: ::c_int) -> ::ssize_t;
805 pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int)
806 -> ::ssize_t;
9e0c209e
SL
807}
808
809cfg_if! {
810 if #[cfg(target_pointer_width = "64")] {
811 mod b64;
812 pub use self::b64::*;
813 } else {
814 mod b32;
815 pub use self::b32::*;
816 }
817}