]>
Commit | Line | Data |
---|---|---|
8bb4bdeb | 1 | use dox::{mem, Option}; |
476ff2be SL |
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; | |
476ff2be SL |
12 | pub type suseconds_t = i32; |
13 | pub type wchar_t = i32; | |
14 | pub type off_t = i64; | |
15 | pub type ino_t = i64; | |
16 | pub type blkcnt_t = i64; | |
17 | pub type blksize_t = i32; | |
18 | pub type dev_t = i32; | |
19 | pub type mode_t = u32; | |
20 | pub type nlink_t = i32; | |
21 | pub type useconds_t = u32; | |
22 | pub type socklen_t = u32; | |
23 | pub type pthread_t = ::uintptr_t; | |
24 | pub type pthread_mutexattr_t = ::uintptr_t; | |
041b39d2 | 25 | pub type pthread_rwlockattr_t = ::uintptr_t; |
476ff2be SL |
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; | |
8bb4bdeb XL |
31 | pub type id_t = i32; |
32 | pub type idtype_t = ::c_uint; | |
476ff2be SL |
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 | ||
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 | |
323 | cfg_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 | ||
333 | pub const EXIT_FAILURE: ::c_int = 1; | |
334 | pub const EXIT_SUCCESS: ::c_int = 0; | |
335 | pub const RAND_MAX: ::c_int = 2147483647; | |
336 | pub const EOF: ::c_int = -1; | |
337 | pub const SEEK_SET: ::c_int = 0; | |
338 | pub const SEEK_CUR: ::c_int = 1; | |
339 | pub const SEEK_END: ::c_int = 2; | |
340 | pub const _IOFBF: ::c_int = 0; | |
341 | pub const _IONBF: ::c_int = 2; | |
342 | pub const _IOLBF: ::c_int = 1; | |
343 | ||
344 | pub const F_DUPFD: ::c_int = 0x0001; | |
345 | pub const F_GETFD: ::c_int = 0x0002; | |
346 | pub const F_SETFD: ::c_int = 0x0004; | |
347 | pub const F_GETFL: ::c_int = 0x0008; | |
348 | pub const F_SETFL: ::c_int = 0x0010; | |
abe05a73 XL |
349 | pub const F_GETLK: ::c_int = 0x0020; |
350 | pub const F_SETLK: ::c_int = 0x0080; | |
351 | pub const F_SETLKW: ::c_int = 0x0100; | |
352 | pub const F_DUPFD_CLOEXEC: ::c_int = 0x0200; | |
353 | ||
354 | pub const AT_FDCWD: ::c_int = -1; | |
355 | pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x01; | |
356 | pub const AT_SYMLINK_FOLLOW: ::c_int = 0x02; | |
357 | pub const AT_REMOVEDIR: ::c_int = 0x04; | |
358 | pub const AT_EACCESS: ::c_int = 0x08; | |
359 | ||
360 | pub const POLLIN: ::c_short = 0x0001; | |
361 | pub const POLLOUT: ::c_short = 0x0002; | |
362 | pub const POLLRDNORM: ::c_short = POLLIN; | |
363 | pub const POLLWRNORM: ::c_short = POLLOUT; | |
364 | pub const POLLRDBAND: ::c_short = 0x0008; | |
365 | pub const POLLWRBAND: ::c_short = 0x0010; | |
366 | pub const POLLPRI: ::c_short = 0x0020; | |
367 | pub const POLLERR: ::c_short = 0x0004; | |
368 | pub const POLLHUP: ::c_short = 0x0080; | |
369 | pub const POLLNVAL: ::c_short = 0x1000; | |
476ff2be | 370 | |
476ff2be SL |
371 | pub const PTHREAD_CREATE_JOINABLE: ::c_int = 0; |
372 | pub const PTHREAD_CREATE_DETACHED: ::c_int = 1; | |
373 | ||
374 | pub const CLOCK_REALTIME: ::c_int = -1; | |
375 | pub const CLOCK_MONOTONIC: ::c_int = 0; | |
376 | ||
377 | pub const RLIMIT_CORE: ::c_int = 0; | |
378 | pub const RLIMIT_CPU: ::c_int = 1; | |
379 | pub const RLIMIT_DATA: ::c_int = 2; | |
380 | pub const RLIMIT_FSIZE: ::c_int = 3; | |
381 | pub const RLIMIT_NOFILE: ::c_int = 4; | |
382 | pub const RLIMIT_AS: ::c_int = 6; | |
383 | // Haiku specific | |
384 | pub const RLIMIT_NOVMON: ::c_int = 7; | |
385 | pub const RLIMIT_NLIMITS: ::c_int = 8; | |
386 | ||
387 | pub const RUSAGE_SELF: ::c_int = 0; | |
388 | ||
abe05a73 XL |
389 | pub const RTLD_LAXY: ::c_int = 0; |
390 | ||
476ff2be SL |
391 | pub const NCCS: usize = 11; |
392 | ||
393 | pub const O_RDONLY: ::c_int = 0x0000; | |
394 | pub const O_WRONLY: ::c_int = 0x0001; | |
395 | pub const O_RDWR: ::c_int = 0x0002; | |
396 | pub const O_ACCMODE: ::c_int = 0x0003; | |
397 | ||
398 | pub const O_EXCL: ::c_int = 0x0100; | |
399 | pub const O_CREAT: ::c_int = 0x0200; | |
400 | pub const O_TRUNC: ::c_int = 0x0400; | |
401 | pub const O_NOCTTY: ::c_int = 0x1000; | |
402 | pub const O_NOTRAVERSE: ::c_int = 0x2000; | |
403 | ||
404 | pub const O_CLOEXEC: ::c_int = 0x00000040; | |
405 | pub const O_NONBLOCK: ::c_int = 0x00000080; | |
406 | pub const O_APPEND: ::c_int = 0x00000800; | |
407 | pub const O_SYNC: ::c_int = 0x00010000; | |
408 | pub const O_RSYNC: ::c_int = 0x00020000; | |
409 | pub const O_DSYNC: ::c_int = 0x00040000; | |
410 | pub const O_NOFOLLOW: ::c_int = 0x00080000; | |
411 | pub const O_NOCACHE: ::c_int = 0x00100000; | |
412 | pub const O_DIRECTORY: ::c_int = 0x00200000; | |
413 | ||
414 | pub const S_IFIFO: ::mode_t = 61440; | |
415 | pub const S_IFCHR: ::mode_t = 49152; | |
416 | pub const S_IFBLK: ::mode_t = 24576; | |
417 | pub const S_IFDIR: ::mode_t = 16384; | |
418 | pub const S_IFREG: ::mode_t = 32768; | |
419 | pub const S_IFLNK: ::mode_t = 40960; | |
420 | pub const S_IFSOCK: ::mode_t = 49152; | |
421 | pub const S_IFMT: ::mode_t = 61440; | |
422 | pub const S_IRWXU: ::mode_t = 448; | |
423 | pub const S_IXUSR: ::mode_t = 64; | |
424 | pub const S_IWUSR: ::mode_t = 128; | |
425 | pub const S_IRUSR: ::mode_t = 256; | |
426 | pub const S_IRWXG: ::mode_t = 70; | |
427 | pub const S_IXGRP: ::mode_t = 10; | |
428 | pub const S_IWGRP: ::mode_t = 20; | |
429 | pub const S_IRGRP: ::mode_t = 40; | |
430 | pub const S_IRWXO: ::mode_t = 7; | |
431 | pub const S_IXOTH: ::mode_t = 1; | |
432 | pub const S_IWOTH: ::mode_t = 2; | |
433 | pub const S_IROTH: ::mode_t = 4; | |
434 | pub const F_OK: ::c_int = 0; | |
435 | pub const R_OK: ::c_int = 4; | |
436 | pub const W_OK: ::c_int = 2; | |
437 | pub const X_OK: ::c_int = 1; | |
438 | pub const STDIN_FILENO: ::c_int = 0; | |
439 | pub const STDOUT_FILENO: ::c_int = 1; | |
440 | pub const STDERR_FILENO: ::c_int = 2; | |
ea8adc8c | 441 | |
476ff2be SL |
442 | pub const SIGHUP: ::c_int = 1; |
443 | pub const SIGINT: ::c_int = 2; | |
444 | pub const SIGQUIT: ::c_int = 3; | |
445 | pub const SIGILL: ::c_int = 4; | |
ea8adc8c | 446 | pub const SIGCHLD: ::c_int = 5; |
476ff2be | 447 | pub const SIGABRT: ::c_int = 6; |
ea8adc8c | 448 | pub const SIGPIPE: ::c_int = 7; |
476ff2be SL |
449 | pub const SIGFPE: ::c_int = 8; |
450 | pub const SIGKILL: ::c_int = 9; | |
ea8adc8c | 451 | pub const SIGSTOP: ::c_int = 10; |
476ff2be | 452 | pub const SIGSEGV: ::c_int = 11; |
ea8adc8c XL |
453 | pub const SIGCONT: ::c_int = 12; |
454 | pub const SIGTSTP: ::c_int = 13; | |
476ff2be SL |
455 | pub const SIGALRM: ::c_int = 14; |
456 | pub const SIGTERM: ::c_int = 15; | |
ea8adc8c XL |
457 | pub const SIGTTIN: ::c_int = 16; |
458 | pub const SIGTTOU: ::c_int = 17; | |
459 | pub const SIGUSR1: ::c_int = 18; | |
460 | pub const SIGUSR2: ::c_int = 19; | |
461 | pub const SIGWINCH: ::c_int = 20; | |
462 | pub const SIGKILLTHR: ::c_int = 21; | |
463 | pub const SIGTRAP: ::c_int = 22; | |
464 | pub const SIGPOLL: ::c_int = 23; | |
465 | pub const SIGPROF: ::c_int = 24; | |
466 | pub const SIGSYS: ::c_int = 25; | |
467 | pub const SIGURG: ::c_int = 26; | |
468 | pub const SIGVTALRM: ::c_int = 27; | |
469 | pub const SIGXCPU: ::c_int = 28; | |
470 | pub const SIGXFSZ: ::c_int = 29; | |
471 | pub const SIGBUS: ::c_int = 30; | |
476ff2be | 472 | |
abe05a73 XL |
473 | pub const SIG_BLOCK: ::c_int = 1; |
474 | pub const SIG_UNBLOCK: ::c_int = 2; | |
475 | pub const SIG_SETMASK: ::c_int = 3; | |
476 | ||
477 | pub const SIGEV_NONE: ::c_int = 0; | |
478 | pub const SIGEV_SIGNAL: ::c_int = 1; | |
479 | pub const SIGEV_THREAD: ::c_int = 2; | |
480 | ||
476ff2be SL |
481 | pub const EAI_SYSTEM: ::c_int = 11; |
482 | ||
483 | pub const PROT_NONE: ::c_int = 0; | |
484 | pub const PROT_READ: ::c_int = 1; | |
485 | pub const PROT_WRITE: ::c_int = 2; | |
486 | pub const PROT_EXEC: ::c_int = 4; | |
487 | ||
488 | pub const LC_ALL: ::c_int = 0; | |
489 | pub const LC_COLLATE: ::c_int = 1; | |
490 | pub const LC_CTYPE: ::c_int = 2; | |
491 | pub const LC_MONETARY: ::c_int = 3; | |
492 | pub const LC_NUMERIC: ::c_int = 4; | |
493 | pub const LC_TIME: ::c_int = 5; | |
494 | pub const LC_MESSAGES: ::c_int = 6; | |
495 | ||
496 | // TODO: Haiku does not have MAP_FILE, but libstd/os.rs requires it | |
497 | pub const MAP_FILE: ::c_int = 0x00; | |
498 | pub const MAP_SHARED: ::c_int = 0x01; | |
499 | pub const MAP_PRIVATE: ::c_int = 0x02; | |
abe05a73 XL |
500 | pub const MAP_FIXED: ::c_int = 0x04; |
501 | pub const MAP_ANONYMOUS: ::c_int = 0x08; | |
502 | pub const MAP_ANON: ::c_int = MAP_ANONYMOUS; | |
476ff2be SL |
503 | |
504 | pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void; | |
505 | ||
506 | pub const MS_ASYNC: ::c_int = 0x01; | |
507 | pub const MS_INVALIDATE: ::c_int = 0x04; | |
508 | pub const MS_SYNC: ::c_int = 0x02; | |
509 | ||
476ff2be | 510 | pub const E2BIG : ::c_int = -2147454975; |
476ff2be SL |
511 | pub const ECHILD : ::c_int = -2147454974; |
512 | pub const EDEADLK : ::c_int = -2147454973; | |
ea8adc8c XL |
513 | pub const EFBIG : ::c_int = -2147454972; |
514 | pub const EMLINK : ::c_int = -2147454971; | |
476ff2be | 515 | pub const ENFILE : ::c_int = -2147454970; |
ea8adc8c XL |
516 | pub const ENODEV : ::c_int = -2147454969; |
517 | pub const ENOLCK : ::c_int = -2147454968; | |
518 | pub const ENOSYS : ::c_int = -2147454967; | |
476ff2be | 519 | pub const ENOTTY : ::c_int = -2147454966; |
ea8adc8c | 520 | pub const ENXIO : ::c_int = -2147454965; |
476ff2be | 521 | pub const ESPIPE : ::c_int = -2147454964; |
ea8adc8c XL |
522 | pub const ESRCH : ::c_int = -2147454963; |
523 | pub const EFPOS : ::c_int = -2147457962; | |
524 | pub const ESIGPARM : ::c_int = -2147457961; | |
476ff2be SL |
525 | pub const EDOM : ::c_int = -2147454960; |
526 | pub const ERANGE : ::c_int = -2147454959; | |
476ff2be | 527 | pub const EPROTOTYPE : ::c_int = -2147454958; |
476ff2be | 528 | pub const EPROTONOSUPPORT : ::c_int = -2147454957; |
476ff2be SL |
529 | pub const EPFNOSUPPORT : ::c_int = -2147454956; |
530 | pub const EAFNOSUPPORT : ::c_int = -2147454955; | |
531 | pub const EADDRINUSE : ::c_int = -2147454954; | |
532 | pub const EADDRNOTAVAIL : ::c_int = -2147454953; | |
ea8adc8c | 533 | pub const ENETDOWN : ::c_int = -2147454952; |
476ff2be SL |
534 | pub const ENETUNREACH : ::c_int = -2147454951; |
535 | pub const ENETRESET : ::c_int = -2147454950; | |
536 | pub const ECONNABORTED : ::c_int = -2147454949; | |
537 | pub const ECONNRESET : ::c_int = -2147454948; | |
476ff2be SL |
538 | pub const EISCONN : ::c_int = -2147454947; |
539 | pub const ENOTCONN : ::c_int = -2147454946; | |
540 | pub const ESHUTDOWN : ::c_int = -2147454945; | |
476ff2be | 541 | pub const ECONNREFUSED : ::c_int = -2147454944; |
476ff2be | 542 | pub const EHOSTUNREACH : ::c_int = -2147454943; |
ea8adc8c XL |
543 | pub const ENOPROTOOPT : ::c_int = -2147454942; |
544 | pub const ENOBUFS : ::c_int = -2147454941; | |
545 | pub const EINPROGRESS : ::c_int = -2147454940; | |
546 | pub const EALREADY : ::c_int = -2147454939; | |
547 | pub const EILSEQ : ::c_int = -2147454938; | |
476ff2be | 548 | pub const ENOMSG : ::c_int = -2147454937; |
ea8adc8c | 549 | pub const ESTALE : ::c_int = -2147454936; |
476ff2be | 550 | pub const EOVERFLOW : ::c_int = -2147454935; |
ea8adc8c XL |
551 | pub const EMSGSIZE : ::c_int = -2147454934; |
552 | pub const EOPNOTSUPP : ::c_int = -2147454933; | |
553 | pub const ENOTSOCK : ::c_int = -2147454932; | |
554 | pub const EHOSTDOWN : ::c_int = -2147454931; | |
476ff2be | 555 | pub const EBADMSG : ::c_int = -2147454930; |
ea8adc8c XL |
556 | pub const ECANCELED : ::c_int = -2147454929; |
557 | pub const EDESTADDRREQ : ::c_int = -2147454928; | |
558 | pub const EDQUOT : ::c_int = -2147454927; | |
559 | pub const EIDRM : ::c_int = -2147454926; | |
476ff2be | 560 | pub const EMULTIHOP : ::c_int = -2147454925; |
ea8adc8c | 561 | pub const ENODATA : ::c_int = -2147454924; |
476ff2be | 562 | pub const ENOLINK : ::c_int = -2147454923; |
ea8adc8c XL |
563 | pub const ENOSR : ::c_int = -2147454922; |
564 | pub const ENOSTR : ::c_int = -2147454921; | |
565 | pub const ENOTSUP : ::c_int = -2147454920; | |
476ff2be | 566 | pub const EPROTO : ::c_int = -2147454919; |
ea8adc8c XL |
567 | pub const ETIME : ::c_int = -2147454918; |
568 | pub const ETXTBSY : ::c_int = -2147454917; | |
569 | pub const ENOATTR : ::c_int = -2147454916; | |
570 | ||
571 | // INT_MIN | |
572 | pub const ENOMEM : ::c_int = -2147454976; | |
573 | ||
574 | // POSIX errors that can be mapped to BeOS error codes | |
575 | pub const EACCES : ::c_int = -2147483646; | |
576 | pub const EINTR : ::c_int = -2147483638; | |
577 | pub const EIO : ::c_int = -2147483647; | |
578 | pub const EBUSY : ::c_int = -2147483634; | |
579 | pub const EFAULT : ::c_int = -2147478783; | |
580 | pub const ETIMEDOUT : ::c_int = -2147483639; | |
581 | pub const EAGAIN : ::c_int = -2147483637; | |
582 | pub const EWOULDBLOCK : ::c_int = -2147483637; | |
583 | pub const EBADF : ::c_int = -2147459072; | |
584 | pub const EEXIST : ::c_int = -2147459070; | |
585 | pub const EINVAL : ::c_int = -2147483643; | |
586 | pub const ENAMETOOLONG : ::c_int = -2147459068; | |
587 | pub const ENOENT : ::c_int = -2147459069; | |
588 | pub const EPERM : ::c_int = -2147483633; | |
589 | pub const ENOTDIR : ::c_int = -2147459067; | |
590 | pub const EISDIR : ::c_int = -2147459063; | |
591 | pub const ENOTEMPTY : ::c_int = -2147459066; | |
592 | pub const ENOSPC : ::c_int = -2147459065; | |
593 | pub const EROFS : ::c_int = -2147459064; | |
abe05a73 | 594 | pub const EMFILE : ::c_int = -2147459062; |
ea8adc8c XL |
595 | pub const EXDEV : ::c_int = -2147459061; |
596 | pub const ELOOP : ::c_int = -2147459060; | |
597 | pub const ENOEXEC : ::c_int = -2147478782; | |
598 | pub const EPIPE : ::c_int = -2147459059; | |
476ff2be SL |
599 | |
600 | pub const IPPROTO_RAW: ::c_int = 255; | |
601 | ||
602 | // These are prefixed with POSIX_ on Haiku | |
603 | pub const MADV_NORMAL: ::c_int = 1; | |
604 | pub const MADV_SEQUENTIAL: ::c_int = 2; | |
605 | pub const MADV_RANDOM: ::c_int = 3; | |
606 | pub const MADV_WILLNEED: ::c_int = 4; | |
607 | pub const MADV_DONTNEED: ::c_int = 5; | |
608 | ||
609 | pub const IFF_LOOPBACK: ::c_int = 0x0008; | |
610 | ||
abe05a73 | 611 | pub const AF_UNSEC: ::c_int = 0; |
476ff2be | 612 | pub const AF_INET: ::c_int = 1; |
abe05a73 XL |
613 | pub const AF_APPLETALK: ::c_int = 2; |
614 | pub const AF_ROUTE: ::c_int = 3; | |
615 | pub const AF_LINK: ::c_int = 4; | |
616 | pub const AF_INET6: ::c_int = 5; | |
617 | pub const AF_DLI: ::c_int = 6; | |
618 | pub const AF_IPX: ::c_int = 7; | |
619 | pub const AF_NOTIFY: ::c_int = 8; | |
620 | pub const AF_LOCAL: ::c_int = 9; | |
621 | pub const AF_UNIX: ::c_int = AF_LOCAL; | |
622 | pub const AF_BLUETOOTH: ::c_int = 10; | |
623 | pub const AF_MAX: ::c_int = 11; | |
624 | ||
476ff2be SL |
625 | pub const IP_MULTICAST_TTL: ::c_int = 10; |
626 | pub const IP_MULTICAST_LOOP: ::c_int = 11; | |
627 | pub const IP_TTL: ::c_int = 4; | |
628 | pub const IP_HDRINCL: ::c_int = 2; | |
629 | pub const IP_ADD_MEMBERSHIP: ::c_int = 12; | |
630 | pub const IP_DROP_MEMBERSHIP: ::c_int = 13; | |
631 | ||
632 | pub const TCP_NODELAY: ::c_int = 0x01; | |
633 | pub const TCP_MAXSEG: ::c_int = 0x02; | |
634 | pub const TCP_NOPUSH: ::c_int = 0x04; | |
635 | pub const TCP_NOOPT: ::c_int = 0x08; | |
636 | ||
637 | pub const IPV6_MULTICAST_LOOP: ::c_int = 26; | |
638 | pub const IPV6_JOIN_GROUP: ::c_int = 28; | |
639 | pub const IPV6_LEAVE_GROUP: ::c_int = 29; | |
640 | pub const IPV6_V6ONLY: ::c_int = 30; | |
641 | ||
abe05a73 XL |
642 | pub const MSG_OOB: ::c_int = 0x0001; |
643 | pub const MSG_PEEK: ::c_int = 0x0002; | |
644 | pub const MSG_DONTROUTE: ::c_int = 0x0004; | |
645 | pub const MSG_EOR: ::c_int = 0x0008; | |
646 | pub const MSG_TRUNC: ::c_int = 0x0010; | |
647 | pub const MSG_CTRUNC: ::c_int = 0x0020; | |
648 | pub const MSG_WAITALL: ::c_int = 0x0040; | |
649 | pub const MSG_DONTWAIT: ::c_int = 0x0080; | |
650 | pub const MSG_BCAST: ::c_int = 0x0100; | |
651 | pub const MSG_MCAST: ::c_int = 0x0200; | |
652 | pub const MSG_EOF: ::c_int = 0x0400; | |
476ff2be SL |
653 | pub const MSG_NOSIGNAL: ::c_int = 0x0800; |
654 | ||
655 | pub const SHUT_RD: ::c_int = 0; | |
656 | pub const SHUT_WR: ::c_int = 1; | |
657 | pub const SHUT_RDWR: ::c_int = 2; | |
658 | ||
659 | pub const LOCK_SH: ::c_int = 0x01; | |
660 | pub const LOCK_EX: ::c_int = 0x02; | |
661 | pub const LOCK_NB: ::c_int = 0x04; | |
662 | pub const LOCK_UN: ::c_int = 0x08; | |
663 | ||
664 | pub const SIGSTKSZ: ::size_t = 16384; | |
665 | ||
abe05a73 XL |
666 | pub const PATH_MAX: ::c_int = 1024; |
667 | ||
668 | pub const SA_NOCLDSTOP: ::c_int = 0x01; | |
669 | pub const SA_NOCLDWAIT: ::c_int = 0x02; | |
476ff2be | 670 | pub const SA_RESETHAND: ::c_int = 0x04; |
abe05a73 | 671 | pub const SA_NODEFER: ::c_int = 0x08; |
476ff2be | 672 | pub const SA_RESTART: ::c_int = 0x10; |
abe05a73 XL |
673 | pub const SA_ONSTACK: ::c_int = 0x20; |
674 | pub const SA_SIGINFO: ::c_int = 0x40; | |
675 | pub const SA_NOMASK: ::c_int = SA_NODEFER; | |
676 | pub const SA_STACK: ::c_int = SA_ONSTACK; | |
677 | pub const SA_ONESHOT: ::c_int = SA_RESETHAND; | |
476ff2be SL |
678 | |
679 | pub const FD_SETSIZE: usize = 1024; | |
680 | ||
681 | pub const RTLD_NOW: ::c_int = 0x1; | |
682 | pub const RTLD_DEFAULT: *mut ::c_void = 0isize as *mut ::c_void; | |
683 | ||
684 | pub const BUFSIZ: ::c_uint = 8192; | |
685 | pub const FILENAME_MAX: ::c_uint = 256; | |
686 | pub const FOPEN_MAX: ::c_uint = 128; | |
687 | pub const L_tmpnam: ::c_uint = 512; | |
688 | pub const TMP_MAX: ::c_uint = 32768; | |
abe05a73 XL |
689 | |
690 | pub const _PC_CHOWN_RESTRICTED: ::c_int = 1; | |
691 | pub const _PC_MAX_CANON: ::c_int = 2; | |
692 | pub const _PC_MAX_INPUT: ::c_int = 3; | |
476ff2be | 693 | pub const _PC_NAME_MAX: ::c_int = 4; |
abe05a73 XL |
694 | pub const _PC_NO_TRUNC: ::c_int = 5; |
695 | pub const _PC_PATH_MAX: ::c_int = 6; | |
696 | pub const _PC_PIPE_BUF: ::c_int = 7; | |
697 | pub const _PC_VDISABLE: ::c_int = 8; | |
698 | pub const _PC_LINK_MAX: ::c_int = 25; | |
699 | pub const _PC_SYNC_IO: ::c_int = 26; | |
700 | pub const _PC_ASYNC_IO: ::c_int = 27; | |
701 | pub const _PC_PRIO_IO: ::c_int = 28; | |
702 | pub const _PC_SOCK_MAXBUF: ::c_int = 29; | |
703 | pub const _PC_FILESIZEBITS: ::c_int = 30; | |
704 | pub const _PC_REC_INCR_XFER_SIZE: ::c_int = 31; | |
705 | pub const _PC_REC_MAX_XFER_SIZE: ::c_int = 32; | |
706 | pub const _PC_REC_MIN_XFER_SIZE: ::c_int = 33; | |
707 | pub const _PC_REC_XFER_ALIGN: ::c_int = 34; | |
708 | pub const _PC_ALLOC_SIZE_MIN: ::c_int = 35; | |
709 | pub const _PC_SYMLINK_MAX: ::c_int = 36; | |
710 | pub const _PC_2_SYMLINKS: ::c_int = 37; | |
711 | pub const _PC_XATTR_EXISTS: ::c_int = 38; | |
712 | pub const _PC_XATTR_ENABLED: ::c_int = 39; | |
476ff2be SL |
713 | |
714 | pub const FIONBIO: ::c_int = 0xbe000000; | |
715 | ||
abe05a73 XL |
716 | pub const _SC_ARG_MAX : ::c_int = 15; |
717 | pub const _SC_CHILD_MAX : ::c_int = 16; | |
718 | pub const _SC_CLK_TCK : ::c_int = 17; | |
719 | pub const _SC_JOB_CONTROL : ::c_int = 18; | |
720 | pub const _SC_NGROUPS_MAX : ::c_int = 19; | |
721 | pub const _SC_OPEN_MAX : ::c_int = 20; | |
722 | pub const _SC_SAVED_IDS : ::c_int = 21; | |
723 | pub const _SC_STREAM_MAX : ::c_int = 22; | |
724 | pub const _SC_TZNAME_MAX : ::c_int = 23; | |
725 | pub const _SC_VERSION : ::c_int = 24; | |
476ff2be SL |
726 | pub const _SC_GETGR_R_SIZE_MAX : ::c_int = 25; |
727 | pub const _SC_GETPW_R_SIZE_MAX : ::c_int = 26; | |
728 | pub const _SC_PAGESIZE : ::c_int = 27; | |
abe05a73 XL |
729 | pub const _SC_PAGE_SIZE : ::c_int = 27; |
730 | pub const _SC_SEM_NSEMS_MAX : ::c_int = 28; | |
731 | pub const _SC_SEM_VALUE_MAX : ::c_int = 29; | |
732 | pub const _SC_SEMAPHORES : ::c_int = 30; | |
733 | pub const _SC_THREADS : ::c_int = 31; | |
734 | pub const _SC_IOV_MAX : ::c_int = 32; | |
735 | pub const _SC_UIO_MAXIOV : ::c_int = 32; | |
736 | pub const _SC_NPROCESSORS_CONF : ::c_int = 34; | |
737 | pub const _SC_NPROCESSORS_ONLN : ::c_int = 35; | |
738 | pub const _SC_ATEXIT_MAX : ::c_int = 37; | |
739 | pub const _SC_PASS_MAX : ::c_int = 39; | |
740 | pub const _SC_PHYS_PAGES : ::c_int = 40; | |
741 | pub const _SC_AVPHYS_PAGES : ::c_int = 41; | |
742 | pub const _SC_PIPE : ::c_int = 42; | |
743 | pub const _SC_SELECT : ::c_int = 43; | |
744 | pub const _SC_POLL : ::c_int = 44; | |
745 | pub const _SC_MAPPED_FILES : ::c_int = 45; | |
746 | pub const _SC_THREAD_PROCESS_SHARED : ::c_int = 46; | |
747 | pub const _SC_THREAD_STACK_MIN : ::c_int = 47; | |
476ff2be SL |
748 | pub const _SC_THREAD_ATTR_STACKADDR : ::c_int = 48; |
749 | pub const _SC_THREAD_ATTR_STACKSIZE : ::c_int = 49; | |
750 | pub const _SC_THREAD_PRIORITY_SCHEDULING : ::c_int = 50; | |
abe05a73 XL |
751 | pub const _SC_REALTIME_SIGNALS : ::c_int = 51; |
752 | pub const _SC_MEMORY_PROTECTION : ::c_int = 52; | |
753 | pub const _SC_SIGQUEUE_MAX : ::c_int = 53; | |
754 | pub const _SC_RTSIG_MAX : ::c_int = 54; | |
755 | pub const _SC_MONOTONIC_CLOCK : ::c_int = 55; | |
756 | pub const _SC_DELAYTIMER_MAX : ::c_int = 56; | |
757 | pub const _SC_TIMER_MAX : ::c_int = 57; | |
758 | pub const _SC_TIMERS : ::c_int = 58; | |
759 | pub const _SC_CPUTIME : ::c_int = 59; | |
760 | pub const _SC_THREAD_CPUTIME : ::c_int = 60; | |
476ff2be SL |
761 | |
762 | pub const PTHREAD_STACK_MIN: ::size_t = 8192; | |
763 | ||
764 | pub 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 | }; | |
771 | pub 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 | }; | |
778 | pub 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 | ||
788 | pub const PTHREAD_MUTEX_DEFAULT: ::c_int = 0; | |
789 | pub const PTHREAD_MUTEX_NORMAL: ::c_int = 1; | |
790 | pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2; | |
791 | pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 3; | |
792 | ||
793 | pub const FIOCLEX: c_ulong = 0; // TODO: does not exist on Haiku! | |
794 | ||
476ff2be SL |
795 | pub const RUSAGE_CHILDREN: ::c_int = -1; |
796 | ||
797 | pub const SOCK_STREAM: ::c_int = 1; | |
798 | pub const SOCK_DGRAM: ::c_int = 2; | |
ea8adc8c XL |
799 | pub const SOCK_RAW: ::c_int = 3; |
800 | pub const SOCK_SEQPACKET: ::c_int = 5; | |
476ff2be SL |
801 | |
802 | pub const SOL_SOCKET: ::c_int = -1; | |
803 | pub const SO_ACCEPTCONN: ::c_int = 0x00000001; | |
804 | pub const SO_BROADCAST: ::c_int = 0x00000002; | |
abe05a73 | 805 | pub const SO_DEBUG: ::c_int = 0x00000004; |
476ff2be SL |
806 | pub const SO_DONTROUTE: ::c_int = 0x00000008; |
807 | pub const SO_KEEPALIVE: ::c_int = 0x00000010; | |
808 | pub const SO_OOBINLINE: ::c_int = 0x00000020; | |
809 | pub const SO_REUSEADDR: ::c_int = 0x00000040; | |
810 | pub const SO_REUSEPORT: ::c_int = 0x00000080; | |
811 | pub const SO_USELOOPBACK: ::c_int = 0x00000100; | |
812 | pub const SO_LINGER: ::c_int = 0x00000200; | |
813 | pub const SO_SNDBUF: ::c_int = 0x40000001; | |
814 | pub const SO_SNDLOWAT: ::c_int = 0x40000002; | |
815 | pub const SO_SNDTIMEO: ::c_int = 0x40000003; | |
816 | pub const SO_RCVBUF: ::c_int = 0x40000004; | |
817 | pub const SO_RCVLOWAT: ::c_int = 0x40000005; | |
818 | pub const SO_RCVTIMEO: ::c_int = 0x40000006; | |
819 | pub const SO_ERROR: ::c_int = 0x40000007; | |
820 | pub const SO_TYPE: ::c_int = 0x40000008; | |
821 | pub const SO_NONBLOCK: ::c_int = 0x40000009; | |
822 | pub const SO_BINDTODEVICE: ::c_int = 0x4000000a; | |
823 | pub const SO_PEERCRED: ::c_int = 0x4000000b; | |
824 | ||
abe05a73 XL |
825 | pub const SCM_RIGHTS: ::c_int = 0x01; |
826 | ||
476ff2be SL |
827 | pub const NI_MAXHOST: ::size_t = 1025; |
828 | ||
8bb4bdeb XL |
829 | pub const WNOHANG: ::c_int = 0x01; |
830 | pub const WUNTRACED: ::c_int = 0x02; | |
831 | pub const WCONTINUED: ::c_int = 0x04; | |
832 | pub const WEXITED: ::c_int = 0x08; | |
833 | pub const WSTOPPED: ::c_int = 0x10; | |
834 | pub const WNOWAIT: ::c_int = 0x20; | |
835 | ||
836 | pub const P_ALL: idtype_t = 0; | |
837 | pub const P_PID: idtype_t = 1; | |
838 | pub const P_PGID: idtype_t = 2; | |
839 | ||
041b39d2 XL |
840 | pub const VINTR: usize = 0; |
841 | pub const VQUIT: usize = 1; | |
842 | pub const VERASE: usize = 2; | |
843 | pub const VKILL: usize = 3; | |
844 | pub const VEOF: usize = 4; | |
845 | pub const VEOL: usize = 5; | |
846 | pub const VMIN: usize = 4; | |
847 | pub const VTIME: usize = 5; | |
848 | pub const VEOL2: usize = 6; | |
849 | pub const VSWTCH: usize = 7; | |
850 | pub const VSTART: usize = 8; | |
851 | pub const VSTOP: usize = 9; | |
852 | pub const VSUSP: usize = 10; | |
abe05a73 XL |
853 | |
854 | pub const IGNBRK: ::tcflag_t = 0x01; | |
855 | pub const BRKINT: ::tcflag_t = 0x02; | |
856 | pub const IGNPAR: ::tcflag_t = 0x04; | |
857 | pub const PARMRK: ::tcflag_t = 0x08; | |
858 | pub const INPCK: ::tcflag_t = 0x10; | |
859 | pub const ISTRIP: ::tcflag_t = 0x20; | |
860 | pub const INLCR: ::tcflag_t = 0x40; | |
861 | pub const IGNCR: ::tcflag_t = 0x80; | |
862 | pub const ICRNL: ::tcflag_t = 0x100; | |
863 | pub const IUCLC: ::tcflag_t = 0x200; | |
864 | pub const IXON: ::tcflag_t = 0x400; | |
865 | pub const IXANY: ::tcflag_t = 0x800; | |
866 | pub const IXOFF: ::tcflag_t = 0x1000; | |
867 | ||
868 | pub const OPOST: ::tcflag_t = 0x00000001; | |
869 | pub const OLCUC: ::tcflag_t = 0x00000002; | |
870 | pub const ONLCR: ::tcflag_t = 0x00000004; | |
871 | pub const OCRNL: ::tcflag_t = 0x00000008; | |
872 | pub const ONOCR: ::tcflag_t = 0x00000010; | |
873 | pub const ONLRET: ::tcflag_t = 0x00000020; | |
874 | pub const OFILL: ::tcflag_t = 0x00000040; | |
875 | pub const OFDEL: ::tcflag_t = 0x00000080; | |
876 | pub const NLDLY: ::tcflag_t = 0x00000100; | |
877 | pub const NL0: ::tcflag_t = 0x00000000; | |
878 | pub const NL1: ::tcflag_t = 0x00000100; | |
879 | pub const CRDLY: ::tcflag_t = 0x00000600; | |
880 | pub const CR0: ::tcflag_t = 0x00000000; | |
881 | pub const CR1: ::tcflag_t = 0x00000200; | |
882 | pub const CR2: ::tcflag_t = 0x00000400; | |
883 | pub const CR3: ::tcflag_t = 0x00000600; | |
884 | pub const TABDLY: ::tcflag_t = 0x00001800; | |
885 | pub const TAB0: ::tcflag_t = 0x00000000; | |
886 | pub const TAB1: ::tcflag_t = 0x00000800; | |
887 | pub const TAB2: ::tcflag_t = 0x00001000; | |
888 | pub const TAB3: ::tcflag_t = 0x00001800; | |
889 | pub const BSDLY: ::tcflag_t = 0x00002000; | |
890 | pub const BS0: ::tcflag_t = 0x00000000; | |
891 | pub const BS1: ::tcflag_t = 0x00002000; | |
892 | pub const VTDLY: ::tcflag_t = 0x00004000; | |
893 | pub const VT0: ::tcflag_t = 0x00000000; | |
894 | pub const VT1: ::tcflag_t = 0x00004000; | |
895 | pub const FFDLY: ::tcflag_t = 0x00008000; | |
896 | pub const FF0: ::tcflag_t = 0x00000000; | |
897 | pub const FF1: ::tcflag_t = 0x00008000; | |
898 | ||
899 | pub const CSIZE: ::tcflag_t = 0x00000020; | |
900 | pub const CS5: ::tcflag_t = 0x00000000; | |
901 | pub const CS6: ::tcflag_t = 0x00000000; | |
902 | pub const CS7: ::tcflag_t = 0x00000000; | |
903 | pub const CS8: ::tcflag_t = 0x00000020; | |
904 | pub const CSTOPB: ::tcflag_t = 0x00000040; | |
905 | pub const CREAD: ::tcflag_t = 0x00000080; | |
906 | pub const PARENB: ::tcflag_t = 0x00000100; | |
907 | pub const PARODD: ::tcflag_t = 0x00000200; | |
908 | pub const HUPCL: ::tcflag_t = 0x00000400; | |
909 | pub const CLOCAL: ::tcflag_t = 0x00000800; | |
910 | pub const XLOBLK: ::tcflag_t = 0x00001000; | |
911 | pub const CTSFLOW: ::tcflag_t = 0x00002000; | |
912 | pub const RTSFLOW: ::tcflag_t = 0x00004000; | |
913 | pub const CRTSCTS: ::tcflag_t = RTSFLOW | CTSFLOW; | |
914 | ||
915 | pub const ISIG: ::tcflag_t = 0x00000001; | |
916 | pub const ICANON: ::tcflag_t = 0x00000002; | |
917 | pub const XCASE: ::tcflag_t = 0x00000004; | |
918 | pub const ECHO: ::tcflag_t = 0x00000008; | |
919 | pub const ECHOE: ::tcflag_t = 0x00000010; | |
920 | pub const ECHOK: ::tcflag_t = 0x00000020; | |
921 | pub const ECHONL: ::tcflag_t = 0x00000040; | |
922 | pub const NOFLSH: ::tcflag_t = 0x00000080; | |
923 | pub const TOSTOP: ::tcflag_t = 0x00000100; | |
924 | pub const IEXTEN: ::tcflag_t = 0x00000200; | |
925 | pub const ECHOCTL: ::tcflag_t = 0x00000400; | |
926 | pub const ECHOPRT: ::tcflag_t = 0x00000800; | |
927 | pub const ECHOKE: ::tcflag_t = 0x00001000; | |
928 | pub const FLUSHO: ::tcflag_t = 0x00002000; | |
929 | pub const PENDIN: ::tcflag_t = 0x00004000; | |
041b39d2 XL |
930 | |
931 | pub const TCGB_CTS: ::c_int = 0x01; | |
932 | pub const TCGB_DSR: ::c_int = 0x02; | |
933 | pub const TCGB_RI: ::c_int = 0x04; | |
934 | pub const TCGB_DCD: ::c_int = 0x08; | |
935 | pub const TIOCM_CTS: ::c_int = TCGB_CTS; | |
936 | pub const TIOCM_CD: ::c_int = TCGB_DCD; | |
937 | pub const TIOCM_CAR: ::c_int = TIOCM_CD; | |
938 | pub const TIOCM_RI: ::c_int = TCGB_RI; | |
ea8adc8c | 939 | pub const TIOCM_DSR: ::c_int = TCGB_DSR; |
041b39d2 XL |
940 | pub const TIOCM_DTR: ::c_int = 0x10; |
941 | pub const TIOCM_RTS: ::c_int = 0x20; | |
942 | ||
abe05a73 XL |
943 | pub const B0: speed_t = 0x00; |
944 | pub const B50: speed_t = 0x01; | |
945 | pub const B75: speed_t = 0x02; | |
946 | pub const B110: speed_t = 0x03; | |
947 | pub const B134: speed_t = 0x04; | |
948 | pub const B150: speed_t = 0x05; | |
949 | pub const B200: speed_t = 0x06; | |
950 | pub const B300: speed_t = 0x07; | |
951 | pub const B600: speed_t = 0x08; | |
952 | pub const B1200: speed_t = 0x09; | |
953 | pub const B1800: speed_t = 0x0A; | |
954 | pub const B2400: speed_t = 0x0B; | |
955 | pub const B4800: speed_t = 0x0C; | |
956 | pub const B9600: speed_t = 0x0D; | |
957 | pub const B19200: speed_t = 0x0E; | |
958 | pub const B38400: speed_t = 0x0F; | |
959 | pub const B57600: speed_t = 0x10; | |
960 | pub const B115200: speed_t = 0x11; | |
961 | pub const B230400: speed_t = 0x12; | |
962 | pub const B31250: speed_t = 0x13; | |
963 | ||
964 | pub const TCSANOW: ::c_int = 0x01; | |
965 | pub const TCSADRAIN: ::c_int = 0x02; | |
966 | pub const TCSAFLUSH: ::c_int = 0x04; | |
967 | ||
968 | pub const TCOOFF: ::c_int = 0x01; | |
969 | pub const TCOON: ::c_int = 0x02; | |
970 | pub const TCIOFF: ::c_int = 0x04; | |
971 | pub const TCION: ::c_int = 0x08; | |
972 | ||
973 | pub const TCIFLUSH: ::c_int = 0x01; | |
974 | pub const TCOFLUSH: ::c_int = 0x02; | |
975 | pub const TCIOFLUSH: ::c_int = 0x03; | |
976 | ||
476ff2be SL |
977 | f! { |
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 |
1039 | extern { |
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 | ||
1188 | cfg_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 | } |