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