]>
Commit | Line | Data |
---|---|---|
7453a54e SL |
1 | pub type c_char = i8; |
2 | pub type c_long = i64; | |
3 | pub type c_ulong = u64; | |
54a0048b | 4 | pub type clockid_t = ::c_int; |
7453a54e SL |
5 | |
6 | pub type blkcnt_t = i64; | |
7 | pub type clock_t = i64; | |
8 | pub type daddr_t = i64; | |
9 | pub type dev_t = u64; | |
10 | pub type fsblkcnt_t = u64; | |
11 | pub type fsfilcnt_t = u64; | |
12 | pub type ino_t = i64; | |
13 | pub type key_t = i32; | |
14 | pub type major_t = u32; | |
15 | pub type minor_t = u32; | |
16 | pub type mode_t = u32; | |
17 | pub type nlink_t = u32; | |
18 | pub type rlim_t = u64; | |
19 | pub type speed_t = u32; | |
20 | pub type tcflag_t = u32; | |
21 | pub type time_t = i64; | |
22 | pub type wchar_t = i32; | |
23 | pub type nfds_t = ::c_ulong; | |
24 | ||
25 | pub type suseconds_t = ::c_long; | |
26 | pub type off_t = i64; | |
27 | pub type useconds_t = ::c_uint; | |
28 | pub type socklen_t = u32; | |
29 | pub type sa_family_t = u8; | |
30 | pub type pthread_t = ::uintptr_t; | |
31 | pub type pthread_key_t = ::c_uint; | |
32 | pub type blksize_t = u32; | |
33 | pub type fflags_t = u32; | |
34 | ||
35 | pub enum timezone {} | |
36 | ||
37 | s! { | |
38 | pub struct sockaddr { | |
39 | pub sa_family: sa_family_t, | |
40 | pub sa_data: [::c_char; 14], | |
41 | } | |
42 | ||
43 | pub struct sockaddr_in { | |
44 | pub sin_family: sa_family_t, | |
45 | pub sin_port: ::in_port_t, | |
46 | pub sin_addr: ::in_addr, | |
47 | pub sin_zero: [::c_char; 8] | |
48 | } | |
49 | ||
50 | pub struct sockaddr_in6 { | |
51 | pub sin6_family: sa_family_t, | |
52 | pub sin6_port: ::in_port_t, | |
53 | pub sin6_flowinfo: u32, | |
54 | pub sin6_addr: ::in6_addr, | |
55 | pub sin6_scope_id: u32, | |
56 | pub __sin6_src_id: u32 | |
57 | } | |
58 | ||
59 | pub struct sockaddr_un { | |
60 | pub sun_family: sa_family_t, | |
61 | pub sun_path: [c_char; 108] | |
62 | } | |
63 | ||
64 | pub struct passwd { | |
65 | pub pw_name: *mut ::c_char, | |
66 | pub pw_passwd: *mut ::c_char, | |
67 | pub pw_uid: ::uid_t, | |
68 | pub pw_gid: ::gid_t, | |
69 | pub pw_age: *mut ::c_char, | |
70 | pub pw_comment: *mut ::c_char, | |
71 | pub pw_gecos: *mut ::c_char, | |
72 | pub pw_dir: *mut ::c_char, | |
73 | pub pw_shell: *mut ::c_char | |
74 | } | |
75 | ||
76 | pub struct ifaddrs { | |
77 | pub ifa_next: *mut ifaddrs, | |
78 | pub ifa_name: *mut ::c_char, | |
79 | pub ifa_flags: ::c_ulong, | |
80 | pub ifa_addr: *mut ::sockaddr, | |
81 | pub ifa_netmask: *mut ::sockaddr, | |
82 | pub ifa_dstaddr: *mut ::sockaddr, | |
83 | pub ifa_data: *mut ::c_void | |
84 | } | |
85 | ||
86 | pub struct tm { | |
87 | pub tm_sec: ::c_int, | |
88 | pub tm_min: ::c_int, | |
89 | pub tm_hour: ::c_int, | |
90 | pub tm_mday: ::c_int, | |
91 | pub tm_mon: ::c_int, | |
92 | pub tm_year: ::c_int, | |
93 | pub tm_wday: ::c_int, | |
94 | pub tm_yday: ::c_int, | |
95 | pub tm_isdst: ::c_int | |
96 | } | |
97 | ||
98 | pub struct utsname { | |
99 | pub sysname: [::c_char; 257], | |
100 | pub nodename: [::c_char; 257], | |
101 | pub release: [::c_char; 257], | |
102 | pub version: [::c_char; 257], | |
103 | pub machine: [::c_char; 257], | |
104 | } | |
105 | ||
106 | pub struct msghdr { | |
107 | pub msg_name: *mut ::c_void, | |
108 | pub msg_namelen: ::socklen_t, | |
109 | pub msg_iov: *mut ::iovec, | |
110 | pub msg_iovlen: ::c_int, | |
111 | pub msg_control: *mut ::c_void, | |
112 | pub msg_controllen: ::socklen_t, | |
113 | pub msg_flags: ::c_int, | |
114 | } | |
115 | ||
116 | pub struct fd_set { | |
117 | fds_bits: [i32; FD_SETSIZE / 32], | |
118 | } | |
119 | ||
120 | pub struct pthread_attr_t { | |
121 | __pthread_attrp: *mut ::c_void | |
122 | } | |
123 | ||
124 | pub struct pthread_mutex_t { | |
125 | __pthread_mutex_flag1: u16, | |
126 | __pthread_mutex_flag2: u8, | |
127 | __pthread_mutex_ceiling: u8, | |
128 | __pthread_mutex_type: u16, | |
129 | __pthread_mutex_magic: u16, | |
130 | __pthread_mutex_lock: u64, | |
131 | __pthread_mutex_data: u64 | |
132 | } | |
133 | ||
134 | pub struct pthread_mutexattr_t { | |
135 | __pthread_mutexattrp: *mut ::c_void | |
136 | } | |
137 | ||
138 | pub struct pthread_cond_t { | |
139 | __pthread_cond_flag: [u8; 4], | |
140 | __pthread_cond_type: u16, | |
141 | __pthread_cond_magic: u16, | |
142 | __pthread_cond_data: u64 | |
143 | } | |
144 | ||
145 | pub struct pthread_rwlock_t { | |
146 | __pthread_rwlock_readers: i32, | |
147 | __pthread_rwlock_type: u16, | |
148 | __pthread_rwlock_magic: u16, | |
149 | __pthread_rwlock_mutex: ::pthread_mutex_t, | |
150 | __pthread_rwlock_readercv: ::pthread_cond_t, | |
151 | __pthread_rwlock_writercv: ::pthread_cond_t | |
152 | } | |
153 | ||
154 | pub struct dirent { | |
155 | pub d_ino: ::ino_t, | |
156 | pub d_off: ::off_t, | |
157 | pub d_reclen: u16, | |
158 | pub d_name: [::c_char; 1] | |
159 | } | |
160 | ||
161 | pub struct glob_t { | |
162 | pub gl_pathc: ::size_t, | |
163 | pub gl_pathv: *mut *mut ::c_char, | |
164 | pub gl_offs: ::size_t, | |
165 | __unused1: *mut ::c_void, | |
166 | __unused2: ::c_int, | |
167 | __unused3: ::c_int, | |
168 | __unused4: ::c_int, | |
169 | __unused5: *mut ::c_void, | |
170 | __unused6: *mut ::c_void, | |
171 | __unused7: *mut ::c_void, | |
172 | __unused8: *mut ::c_void, | |
173 | __unused9: *mut ::c_void, | |
174 | __unused10: *mut ::c_void, | |
175 | } | |
176 | ||
177 | pub struct sockaddr_storage { | |
178 | pub ss_family: ::sa_family_t, | |
179 | __ss_pad1: [u8; 6], | |
180 | __ss_align: i64, | |
181 | __ss_pad2: [u8; 240], | |
182 | } | |
183 | ||
184 | pub struct addrinfo { | |
185 | pub ai_flags: ::c_int, | |
186 | pub ai_family: ::c_int, | |
187 | pub ai_socktype: ::c_int, | |
188 | pub ai_protocol: ::c_int, | |
189 | pub ai_addrlen: ::socklen_t, | |
190 | pub ai_canonname: *mut ::c_char, | |
191 | pub ai_addr: *mut ::sockaddr, | |
192 | pub ai_next: *mut addrinfo, | |
193 | } | |
194 | ||
195 | pub struct sigset_t { | |
196 | bits: [u32; 4], | |
197 | } | |
198 | ||
199 | pub struct siginfo_t { | |
200 | pub si_signo: ::c_int, | |
201 | pub si_code: ::c_int, | |
202 | pub si_errno: ::c_int, | |
203 | pub si_pad: ::c_int, | |
204 | pub si_addr: *mut ::c_void, | |
205 | __pad: [u8; 232], | |
206 | } | |
207 | ||
208 | pub struct sigaction { | |
209 | pub sa_flags: ::c_int, | |
210 | pub sa_sigaction: ::sighandler_t, | |
211 | pub sa_mask: sigset_t, | |
212 | } | |
213 | ||
214 | pub struct stack_t { | |
215 | pub ss_sp: *mut ::c_void, | |
216 | pub ss_size: ::size_t, | |
217 | pub ss_flags: ::c_int, | |
218 | } | |
219 | ||
220 | pub struct statvfs { | |
221 | pub f_bsize: ::c_ulong, | |
222 | pub f_frsize: ::c_ulong, | |
223 | pub f_blocks: ::fsblkcnt_t, | |
224 | pub f_bfree: ::fsblkcnt_t, | |
225 | pub f_bavail: ::fsblkcnt_t, | |
226 | pub f_files: ::fsfilcnt_t, | |
227 | pub f_ffree: ::fsfilcnt_t, | |
228 | pub f_favail: ::fsfilcnt_t, | |
229 | pub f_fsid: ::c_ulong, | |
230 | pub f_basetype: [::c_char; 16], | |
231 | pub f_flag: ::c_ulong, | |
232 | pub f_namemax: ::c_ulong, | |
233 | pub f_fstr: [::c_char; 32] | |
234 | } | |
235 | ||
236 | pub struct sched_param { | |
237 | pub sched_priority: ::c_int, | |
238 | sched_pad: [::c_int; 8] | |
239 | } | |
240 | ||
241 | pub struct Dl_info { | |
242 | pub dli_fname: *const ::c_char, | |
243 | pub dli_fbase: *mut ::c_void, | |
244 | pub dli_sname: *const ::c_char, | |
245 | pub dli_saddr: *mut ::c_void, | |
246 | } | |
247 | ||
248 | pub struct stat { | |
249 | pub st_dev: ::dev_t, | |
250 | pub st_ino: ::ino_t, | |
251 | pub st_mode: ::mode_t, | |
252 | pub st_nlink: ::nlink_t, | |
253 | pub st_uid: ::uid_t, | |
254 | pub st_gid: ::gid_t, | |
255 | pub st_rdev: ::dev_t, | |
256 | pub st_size: ::off_t, | |
257 | pub st_atime: ::time_t, | |
258 | pub st_atime_nsec: ::c_long, | |
259 | pub st_mtime: ::time_t, | |
260 | pub st_mtime_nsec: ::c_long, | |
261 | pub st_ctime: ::time_t, | |
262 | pub st_ctime_nsec: ::c_long, | |
263 | pub st_blksize: ::blksize_t, | |
264 | pub st_blocks: ::blkcnt_t, | |
265 | __unused: [::c_char; 16] | |
266 | } | |
267 | ||
268 | pub struct termios { | |
269 | pub c_iflag: ::tcflag_t, | |
270 | pub c_oflag: ::tcflag_t, | |
271 | pub c_cflag: ::tcflag_t, | |
272 | pub c_lflag: ::tcflag_t, | |
273 | pub c_cc: [::cc_t; ::NCCS] | |
274 | } | |
275 | } | |
276 | ||
277 | pub const SA_ONSTACK: ::c_int = 0x00000001; | |
278 | pub const SA_RESETHAND: ::c_int = 0x00000002; | |
279 | pub const SA_RESTART: ::c_int = 0x00000004; | |
280 | pub const SA_SIGINFO: ::c_int = 0x00000008; | |
281 | pub const SA_NODEFER: ::c_int = 0x00000010; | |
282 | pub const SA_NOCLDWAIT: ::c_int = 0x00010000; | |
283 | pub const SA_NOCLDSTOP: ::c_int = 0x00020000; | |
284 | ||
285 | pub const SS_ONSTACK: ::c_int = 1; | |
286 | pub const SS_DISABLE: ::c_int = 2; | |
287 | ||
288 | pub const FIONBIO: ::c_int = 0x8004667e; | |
289 | ||
290 | pub const SIGCHLD: ::c_int = 18; | |
291 | pub const SIGBUS: ::c_int = 10; | |
292 | pub const SIG_SETMASK: ::c_int = 3; | |
293 | ||
294 | pub const IPV6_MULTICAST_LOOP: ::c_int = 0x8; | |
295 | pub const IPV6_V6ONLY: ::c_int = 0x27; | |
296 | ||
297 | pub const FD_SETSIZE: usize = 1024; | |
298 | ||
299 | pub const ST_RDONLY: ::c_ulong = 1; | |
300 | pub const ST_NOSUID: ::c_ulong = 2; | |
301 | ||
302 | pub const NI_MAXHOST: ::socklen_t = 1025; | |
303 | ||
304 | pub const EXIT_FAILURE: ::c_int = 1; | |
305 | pub const EXIT_SUCCESS: ::c_int = 0; | |
306 | pub const RAND_MAX: ::c_int = 32767; | |
307 | pub const EOF: ::c_int = -1; | |
308 | pub const SEEK_SET: ::c_int = 0; | |
309 | pub const SEEK_CUR: ::c_int = 1; | |
310 | pub const SEEK_END: ::c_int = 2; | |
311 | pub const _IOFBF: ::c_int = 0; | |
312 | pub const _IONBF: ::c_int = 4; | |
313 | pub const _IOLBF: ::c_int = 64; | |
314 | pub const BUFSIZ: ::c_uint = 1024; | |
315 | pub const FOPEN_MAX: ::c_uint = 20; | |
316 | pub const FILENAME_MAX: ::c_uint = 1024; | |
317 | pub const L_tmpnam: ::c_uint = 25; | |
318 | pub const TMP_MAX: ::c_uint = 17576; | |
319 | ||
320 | pub const O_RDONLY: ::c_int = 0; | |
321 | pub const O_WRONLY: ::c_int = 1; | |
322 | pub const O_RDWR: ::c_int = 2; | |
323 | pub const O_APPEND: ::c_int = 8; | |
324 | pub const O_CREAT: ::c_int = 256; | |
325 | pub const O_EXCL: ::c_int = 1024; | |
326 | pub const O_NOCTTY: ::c_int = 2048; | |
327 | pub const O_TRUNC: ::c_int = 512; | |
328 | pub const O_CLOEXEC: ::c_int = 0x800000; | |
329 | pub const O_ACCMODE: ::c_int = 0x600003; | |
330 | pub const S_IFIFO: mode_t = 4096; | |
331 | pub const S_IFCHR: mode_t = 8192; | |
332 | pub const S_IFBLK: mode_t = 24576; | |
333 | pub const S_IFDIR: mode_t = 16384; | |
334 | pub const S_IFREG: mode_t = 32768; | |
335 | pub const S_IFLNK: mode_t = 40960; | |
336 | pub const S_IFSOCK: mode_t = 49152; | |
337 | pub const S_IFMT: mode_t = 61440; | |
338 | pub const S_IEXEC: mode_t = 64; | |
339 | pub const S_IWRITE: mode_t = 128; | |
340 | pub const S_IREAD: mode_t = 256; | |
341 | pub const S_IRWXU: mode_t = 448; | |
342 | pub const S_IXUSR: mode_t = 64; | |
343 | pub const S_IWUSR: mode_t = 128; | |
344 | pub const S_IRUSR: mode_t = 256; | |
345 | pub const S_IRWXG: mode_t = 56; | |
346 | pub const S_IXGRP: mode_t = 8; | |
347 | pub const S_IWGRP: mode_t = 16; | |
348 | pub const S_IRGRP: mode_t = 32; | |
349 | pub const S_IRWXO: mode_t = 7; | |
350 | pub const S_IXOTH: mode_t = 1; | |
351 | pub const S_IWOTH: mode_t = 2; | |
352 | pub const S_IROTH: mode_t = 4; | |
353 | pub const F_OK: ::c_int = 0; | |
354 | pub const R_OK: ::c_int = 4; | |
355 | pub const W_OK: ::c_int = 2; | |
356 | pub const X_OK: ::c_int = 1; | |
357 | pub const STDIN_FILENO: ::c_int = 0; | |
358 | pub const STDOUT_FILENO: ::c_int = 1; | |
359 | pub const STDERR_FILENO: ::c_int = 2; | |
360 | pub const F_LOCK: ::c_int = 1; | |
361 | pub const F_TEST: ::c_int = 3; | |
362 | pub const F_TLOCK: ::c_int = 2; | |
363 | pub const F_ULOCK: ::c_int = 0; | |
364 | pub const F_DUPFD_CLOEXEC: ::c_int = 37; | |
365 | pub const SIGHUP: ::c_int = 1; | |
366 | pub const SIGINT: ::c_int = 2; | |
367 | pub const SIGQUIT: ::c_int = 3; | |
368 | pub const SIGILL: ::c_int = 4; | |
369 | pub const SIGABRT: ::c_int = 6; | |
370 | pub const SIGFPE: ::c_int = 8; | |
371 | pub const SIGKILL: ::c_int = 9; | |
372 | pub const SIGSEGV: ::c_int = 11; | |
373 | pub const SIGPIPE: ::c_int = 13; | |
374 | pub const SIGALRM: ::c_int = 14; | |
375 | pub const SIGTERM: ::c_int = 15; | |
376 | ||
377 | pub const WNOHANG: ::c_int = 0x40; | |
378 | ||
379 | pub const PROT_NONE: ::c_int = 0; | |
380 | pub const PROT_READ: ::c_int = 1; | |
381 | pub const PROT_WRITE: ::c_int = 2; | |
382 | pub const PROT_EXEC: ::c_int = 4; | |
383 | ||
384 | pub const MAP_SHARED: ::c_int = 0x0001; | |
385 | pub const MAP_PRIVATE: ::c_int = 0x0002; | |
386 | pub const MAP_FIXED: ::c_int = 0x0010; | |
387 | pub const MAP_ANON: ::c_int = 0x0100; | |
388 | ||
389 | pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void; | |
390 | ||
391 | pub const MCL_CURRENT: ::c_int = 0x0001; | |
392 | pub const MCL_FUTURE: ::c_int = 0x0002; | |
393 | ||
394 | pub const MS_SYNC: ::c_int = 0x0004; | |
395 | pub const MS_ASYNC: ::c_int = 0x0001; | |
396 | pub const MS_INVALIDATE: ::c_int = 0x0002; | |
397 | ||
398 | pub const EPERM: ::c_int = 1; | |
399 | pub const ENOENT: ::c_int = 2; | |
400 | pub const ESRCH: ::c_int = 3; | |
401 | pub const EINTR: ::c_int = 4; | |
402 | pub const EIO: ::c_int = 5; | |
403 | pub const ENXIO: ::c_int = 6; | |
404 | pub const E2BIG: ::c_int = 7; | |
405 | pub const ENOEXEC: ::c_int = 8; | |
406 | pub const EBADF: ::c_int = 9; | |
407 | pub const ECHILD: ::c_int = 10; | |
408 | pub const EDEADLK: ::c_int = 45; | |
409 | pub const ENOMEM: ::c_int = 12; | |
410 | pub const EACCES: ::c_int = 13; | |
411 | pub const EFAULT: ::c_int = 14; | |
412 | pub const ENOTBLK: ::c_int = 15; | |
413 | pub const EBUSY: ::c_int = 16; | |
414 | pub const EEXIST: ::c_int = 17; | |
415 | pub const EXDEV: ::c_int = 18; | |
416 | pub const ENODEV: ::c_int = 19; | |
417 | pub const ENOTDIR: ::c_int = 20; | |
418 | pub const EISDIR: ::c_int = 21; | |
419 | pub const EINVAL: ::c_int = 22; | |
420 | pub const ENFILE: ::c_int = 23; | |
421 | pub const EMFILE: ::c_int = 24; | |
422 | pub const ENOTTY: ::c_int = 25; | |
423 | pub const ETXTBSY: ::c_int = 26; | |
424 | pub const EFBIG: ::c_int = 27; | |
425 | pub const ENOSPC: ::c_int = 28; | |
426 | pub const ESPIPE: ::c_int = 29; | |
427 | pub const EROFS: ::c_int = 30; | |
428 | pub const EMLINK: ::c_int = 31; | |
429 | pub const EPIPE: ::c_int = 32; | |
430 | pub const EDOM: ::c_int = 33; | |
431 | pub const ERANGE: ::c_int = 34; | |
432 | pub const EAGAIN: ::c_int = 11; | |
433 | pub const EWOULDBLOCK: ::c_int = 11; | |
434 | pub const EINPROGRESS: ::c_int = 150; | |
435 | pub const EALREADY: ::c_int = 149; | |
436 | pub const ENOTSOCK: ::c_int = 95; | |
437 | pub const EDESTADDRREQ: ::c_int = 96; | |
438 | pub const EMSGSIZE: ::c_int = 97; | |
439 | pub const EPROTOTYPE: ::c_int = 98; | |
440 | pub const ENOPROTOOPT: ::c_int = 99; | |
441 | pub const EPROTONOSUPPORT: ::c_int = 120; | |
442 | pub const ESOCKTNOSUPPORT: ::c_int = 121; | |
443 | pub const EOPNOTSUPP: ::c_int = 122; | |
444 | pub const EPFNOSUPPORT: ::c_int = 123; | |
445 | pub const EAFNOSUPPORT: ::c_int = 124; | |
446 | pub const EADDRINUSE: ::c_int = 125; | |
447 | pub const EADDRNOTAVAIL: ::c_int = 126; | |
448 | pub const ENETDOWN: ::c_int = 127; | |
449 | pub const ENETUNREACH: ::c_int = 128; | |
450 | pub const ENETRESET: ::c_int = 129; | |
451 | pub const ECONNABORTED: ::c_int = 130; | |
452 | pub const ECONNRESET: ::c_int = 131; | |
453 | pub const ENOBUFS: ::c_int = 132; | |
454 | pub const EISCONN: ::c_int = 133; | |
455 | pub const ENOTCONN: ::c_int = 134; | |
456 | pub const ESHUTDOWN: ::c_int = 143; | |
457 | pub const ETOOMANYREFS: ::c_int = 144; | |
458 | pub const ETIMEDOUT: ::c_int = 145; | |
459 | pub const ECONNREFUSED: ::c_int = 146; | |
460 | pub const ELOOP: ::c_int = 90; | |
461 | pub const ENAMETOOLONG: ::c_int = 78; | |
462 | pub const EHOSTDOWN: ::c_int = 147; | |
463 | pub const EHOSTUNREACH: ::c_int = 148; | |
464 | pub const ENOTEMPTY: ::c_int = 93; | |
465 | pub const EUSERS: ::c_int = 94; | |
466 | pub const EDQUOT: ::c_int = 49; | |
467 | pub const ESTALE: ::c_int = 151; | |
468 | pub const EREMOTE: ::c_int = 66; | |
469 | pub const ENOLCK: ::c_int = 46; | |
470 | pub const ENOSYS: ::c_int = 89; | |
471 | pub const EIDRM: ::c_int = 36; | |
472 | pub const ENOMSG: ::c_int = 35; | |
473 | pub const EOVERFLOW: ::c_int = 79; | |
474 | pub const ECANCELED: ::c_int = 47; | |
475 | pub const EILSEQ: ::c_int = 88; | |
476 | pub const EBADMSG: ::c_int = 77; | |
477 | pub const EMULTIHOP: ::c_int = 74; | |
478 | pub const ENOLINK: ::c_int = 67; | |
479 | pub const EPROTO: ::c_int = 71; | |
480 | ||
481 | pub const F_DUPFD: ::c_int = 0; | |
482 | pub const F_GETFD: ::c_int = 1; | |
483 | pub const F_SETFD: ::c_int = 2; | |
484 | pub const F_GETFL: ::c_int = 3; | |
485 | pub const F_SETFL: ::c_int = 4; | |
486 | ||
487 | pub const SIGTRAP: ::c_int = 5; | |
488 | ||
489 | pub const GLOB_APPEND : ::c_int = 32; | |
490 | pub const GLOB_DOOFFS : ::c_int = 16; | |
491 | pub const GLOB_ERR : ::c_int = 1; | |
492 | pub const GLOB_MARK : ::c_int = 2; | |
493 | pub const GLOB_NOCHECK : ::c_int = 8; | |
494 | pub const GLOB_NOSORT : ::c_int = 4; | |
495 | pub const GLOB_NOESCAPE: ::c_int = 64; | |
496 | ||
497 | pub const GLOB_NOSPACE : ::c_int = -2; | |
498 | pub const GLOB_ABORTED : ::c_int = -1; | |
499 | pub const GLOB_NOMATCH : ::c_int = -3; | |
500 | ||
501 | pub const POSIX_MADV_NORMAL: ::c_int = 0; | |
502 | pub const POSIX_MADV_RANDOM: ::c_int = 1; | |
503 | pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2; | |
504 | pub const POSIX_MADV_WILLNEED: ::c_int = 3; | |
505 | pub const POSIX_MADV_DONTNEED: ::c_int = 4; | |
506 | ||
507 | pub const _SC_IOV_MAX: ::c_int = 77; | |
508 | pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 569; | |
509 | pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 570; | |
510 | pub const _SC_LOGIN_NAME_MAX: ::c_int = 571; | |
511 | pub const _SC_MQ_PRIO_MAX: ::c_int = 30; | |
512 | pub const _SC_THREAD_ATTR_STACKADDR: ::c_int = 577; | |
513 | pub const _SC_THREAD_ATTR_STACKSIZE: ::c_int = 578; | |
514 | pub const _SC_THREAD_DESTRUCTOR_ITERATIONS: ::c_int = 568; | |
515 | pub const _SC_THREAD_KEYS_MAX: ::c_int = 572; | |
516 | pub const _SC_THREAD_PRIO_INHERIT: ::c_int = 580; | |
517 | pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 581; | |
518 | pub const _SC_THREAD_PRIORITY_SCHEDULING: ::c_int = 579; | |
519 | pub const _SC_THREAD_PROCESS_SHARED: ::c_int = 582; | |
520 | pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 583; | |
521 | pub const _SC_THREAD_STACK_MIN: ::c_int = 573; | |
522 | pub const _SC_THREAD_THREADS_MAX: ::c_int = 574; | |
523 | pub const _SC_THREADS: ::c_int = 576; | |
524 | pub const _SC_TTY_NAME_MAX: ::c_int = 575; | |
525 | pub const _SC_ATEXIT_MAX: ::c_int = 76; | |
526 | pub const _SC_XOPEN_CRYPT: ::c_int = 62; | |
527 | pub const _SC_XOPEN_ENH_I18N: ::c_int = 63; | |
528 | pub const _SC_XOPEN_LEGACY: ::c_int = 717; | |
529 | pub const _SC_XOPEN_REALTIME: ::c_int = 718; | |
530 | pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 719; | |
531 | pub const _SC_XOPEN_SHM: ::c_int = 64; | |
532 | pub const _SC_XOPEN_UNIX: ::c_int = 78; | |
533 | pub const _SC_XOPEN_VERSION: ::c_int = 12; | |
534 | pub const _SC_XOPEN_XCU_VERSION: ::c_int = 67; | |
535 | ||
536 | pub const PTHREAD_CREATE_JOINABLE: ::c_int = 0; | |
537 | pub const PTHREAD_CREATE_DETACHED: ::c_int = 0x40; | |
538 | pub const PTHREAD_PROCESS_SHARED: ::c_int = 1; | |
539 | pub const PTHREAD_PROCESS_PRIVATE: u16 = 0; | |
540 | pub const PTHREAD_STACK_MIN: ::size_t = 4096; | |
541 | ||
542 | pub const SIGSTKSZ: ::size_t = 8192; | |
543 | ||
54a0048b SL |
544 | // https://illumos.org/man/3c/clock_gettime |
545 | // https://github.com/illumos/illumos-gate/ | |
546 | // blob/HEAD/usr/src/lib/libc/amd64/sys/__clock_gettime.s | |
547 | // clock_gettime(3c) doesn't seem to accept anything other than CLOCK_REALTIME | |
548 | // or __CLOCK_REALTIME0 | |
549 | // | |
550 | // https://github.com/illumos/illumos-gate/ | |
551 | // blob/HEAD/usr/src/uts/common/sys/time_impl.h | |
552 | // Confusing! CLOCK_HIGHRES==CLOCK_MONOTONIC==4 | |
553 | // __CLOCK_REALTIME0==0 is an obsoleted version of CLOCK_REALTIME==3 | |
554 | pub const CLOCK_REALTIME: clockid_t = 3; | |
555 | pub const CLOCK_MONOTONIC: clockid_t = 4; | |
7453a54e SL |
556 | |
557 | pub const RLIMIT_CPU: ::c_int = 0; | |
558 | pub const RLIMIT_FSIZE: ::c_int = 1; | |
559 | pub const RLIMIT_DATA: ::c_int = 2; | |
560 | pub const RLIMIT_STACK: ::c_int = 3; | |
561 | pub const RLIMIT_CORE: ::c_int = 4; | |
562 | pub const RLIMIT_NOFILE: ::c_int = 5; | |
563 | pub const RLIMIT_VMEM: ::c_int = 6; | |
564 | pub const RLIMIT_AS: ::c_int = RLIMIT_VMEM; | |
565 | ||
566 | pub const RLIM_NLIMITS: rlim_t = 7; | |
567 | pub const RLIM_INFINITY: rlim_t = 0x7fffffff; | |
568 | ||
569 | pub const RUSAGE_SELF: ::c_int = 0; | |
570 | pub const RUSAGE_CHILDREN: ::c_int = -1; | |
571 | ||
572 | pub const MADV_NORMAL: ::c_int = 0; | |
573 | pub const MADV_RANDOM: ::c_int = 1; | |
574 | pub const MADV_SEQUENTIAL: ::c_int = 2; | |
575 | pub const MADV_WILLNEED: ::c_int = 3; | |
576 | pub const MADV_DONTNEED: ::c_int = 4; | |
577 | pub const MADV_FREE: ::c_int = 5; | |
578 | ||
579 | pub const AF_INET: ::c_int = 2; | |
580 | pub const AF_INET6: ::c_int = 26; | |
581 | pub const AF_UNIX: ::c_int = 1; | |
582 | pub const SOCK_DGRAM: ::c_int = 1; | |
583 | pub const SOCK_STREAM: ::c_int = 2; | |
584 | pub const SOCK_RAW: ::c_int = 4; | |
585 | pub const IPPROTO_TCP: ::c_int = 6; | |
586 | pub const IPPROTO_IP: ::c_int = 0; | |
587 | pub const IPPROTO_IPV6: ::c_int = 41; | |
588 | pub const IP_MULTICAST_TTL: ::c_int = 17; | |
589 | pub const IP_MULTICAST_LOOP: ::c_int = 18; | |
590 | pub const IP_TTL: ::c_int = 4; | |
591 | pub const IP_HDRINCL: ::c_int = 2; | |
592 | pub const IP_ADD_MEMBERSHIP: ::c_int = 19; | |
593 | pub const IP_DROP_MEMBERSHIP: ::c_int = 20; | |
594 | pub const IPV6_JOIN_GROUP: ::c_int = 9; | |
595 | pub const IPV6_LEAVE_GROUP: ::c_int = 10; | |
596 | ||
597 | pub const TCP_NODELAY: ::c_int = 1; | |
598 | pub const TCP_KEEPIDLE: ::c_int = 34; | |
599 | pub const SOL_SOCKET: ::c_int = 0xffff; | |
600 | pub const SO_DEBUG: ::c_int = 0x01; | |
601 | pub const SO_ACCEPTCONN: ::c_int = 0x0002; | |
602 | pub const SO_REUSEADDR: ::c_int = 0x0004; | |
603 | pub const SO_KEEPALIVE: ::c_int = 0x0008; | |
604 | pub const SO_DONTROUTE: ::c_int = 0x0010; | |
605 | pub const SO_BROADCAST: ::c_int = 0x0020; | |
606 | pub const SO_USELOOPBACK: ::c_int = 0x0040; | |
607 | pub const SO_LINGER: ::c_int = 0x0080; | |
608 | pub const SO_OOBINLINE: ::c_int = 0x0100; | |
609 | pub const SO_SNDBUF: ::c_int = 0x1001; | |
610 | pub const SO_RCVBUF: ::c_int = 0x1002; | |
611 | pub const SO_SNDLOWAT: ::c_int = 0x1003; | |
612 | pub const SO_RCVLOWAT: ::c_int = 0x1004; | |
613 | pub const SO_SNDTIMEO: ::c_int = 0x1005; | |
614 | pub const SO_RCVTIMEO: ::c_int = 0x1006; | |
615 | pub const SO_ERROR: ::c_int = 0x1007; | |
616 | pub const SO_TYPE: ::c_int = 0x1008; | |
617 | ||
618 | pub const IFF_LOOPBACK: ::c_int = 0x8; | |
619 | ||
620 | pub const SHUT_RD: ::c_int = 0; | |
621 | pub const SHUT_WR: ::c_int = 1; | |
622 | pub const SHUT_RDWR: ::c_int = 2; | |
623 | ||
624 | pub const LOCK_SH: ::c_int = 1; | |
625 | pub const LOCK_EX: ::c_int = 2; | |
626 | pub const LOCK_NB: ::c_int = 4; | |
627 | pub const LOCK_UN: ::c_int = 8; | |
628 | ||
629 | pub const O_SYNC: ::c_int = 16; | |
630 | pub const O_NONBLOCK: ::c_int = 128; | |
631 | ||
632 | pub const IPPROTO_RAW: ::c_int = 255; | |
633 | ||
634 | pub const _SC_ARG_MAX: ::c_int = 1; | |
635 | pub const _SC_CHILD_MAX: ::c_int = 2; | |
636 | pub const _SC_CLK_TCK: ::c_int = 3; | |
637 | pub const _SC_NGROUPS_MAX: ::c_int = 4; | |
638 | pub const _SC_OPEN_MAX: ::c_int = 5; | |
639 | pub const _SC_JOB_CONTROL: ::c_int = 6; | |
640 | pub const _SC_SAVED_IDS: ::c_int = 7; | |
641 | pub const _SC_VERSION: ::c_int = 8; | |
642 | pub const _SC_PAGESIZE: ::c_int = 11; | |
643 | pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE; | |
644 | pub const _SC_NPROCESSORS_ONLN: ::c_int = 15; | |
645 | pub const _SC_STREAM_MAX: ::c_int = 16; | |
646 | pub const _SC_TZNAME_MAX: ::c_int = 17; | |
647 | pub const _SC_AIO_LISTIO_MAX: ::c_int = 18; | |
648 | pub const _SC_AIO_MAX: ::c_int = 19; | |
649 | pub const _SC_BC_BASE_MAX: ::c_int = 54; | |
650 | pub const _SC_BC_DIM_MAX: ::c_int = 55; | |
651 | pub const _SC_BC_SCALE_MAX: ::c_int = 56; | |
652 | pub const _SC_BC_STRING_MAX: ::c_int = 57; | |
653 | pub const _SC_COLL_WEIGHTS_MAX: ::c_int = 58; | |
654 | pub const _SC_EXPR_NEST_MAX: ::c_int = 59; | |
655 | pub const _SC_LINE_MAX: ::c_int = 60; | |
656 | pub const _SC_RE_DUP_MAX: ::c_int = 61; | |
657 | pub const _SC_2_VERSION: ::c_int = 53; | |
658 | pub const _SC_2_C_BIND: ::c_int = 45; | |
659 | pub const _SC_2_C_DEV: ::c_int = 46; | |
660 | pub const _SC_2_CHAR_TERM: ::c_int = 66; | |
661 | pub const _SC_2_FORT_DEV: ::c_int = 48; | |
662 | pub const _SC_2_FORT_RUN: ::c_int = 49; | |
663 | pub const _SC_2_LOCALEDEF: ::c_int = 50; | |
664 | pub const _SC_2_SW_DEV: ::c_int = 51; | |
665 | pub const _SC_2_UPE: ::c_int = 52; | |
666 | pub const _SC_ASYNCHRONOUS_IO: ::c_int = 21; | |
667 | pub const _SC_MAPPED_FILES: ::c_int = 24; | |
668 | pub const _SC_MEMLOCK: ::c_int = 25; | |
669 | pub const _SC_MEMLOCK_RANGE: ::c_int = 26; | |
670 | pub const _SC_MEMORY_PROTECTION: ::c_int = 27; | |
671 | pub const _SC_MESSAGE_PASSING: ::c_int = 28; | |
672 | pub const _SC_PRIORITIZED_IO: ::c_int = 31; | |
673 | pub const _SC_PRIORITY_SCHEDULING: ::c_int = 32; | |
674 | pub const _SC_REALTIME_SIGNALS: ::c_int = 33; | |
675 | pub const _SC_SEMAPHORES: ::c_int = 35; | |
676 | pub const _SC_FSYNC: ::c_int = 23; | |
677 | pub const _SC_SHARED_MEMORY_OBJECTS: ::c_int = 38; | |
678 | pub const _SC_SYNCHRONIZED_IO: ::c_int = 42; | |
679 | pub const _SC_TIMERS: ::c_int = 43; | |
680 | pub const _SC_AIO_PRIO_DELTA_MAX: ::c_int = 20; | |
681 | pub const _SC_DELAYTIMER_MAX: ::c_int = 22; | |
682 | pub const _SC_MQ_OPEN_MAX: ::c_int = 29; | |
683 | pub const _SC_RTSIG_MAX: ::c_int = 34; | |
684 | pub const _SC_SEM_NSEMS_MAX: ::c_int = 36; | |
685 | pub const _SC_SEM_VALUE_MAX: ::c_int = 37; | |
686 | pub const _SC_SIGQUEUE_MAX: ::c_int = 39; | |
687 | pub const _SC_TIMER_MAX: ::c_int = 44; | |
688 | ||
689 | pub const _MUTEX_MAGIC: u16 = 0x4d58; // MX | |
690 | pub const _COND_MAGIC: u16 = 0x4356; // CV | |
691 | pub const _RWL_MAGIC: u16 = 0x5257; // RW | |
692 | ||
693 | pub const NCCS: usize = 19; | |
694 | ||
695 | pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { | |
696 | __pthread_mutex_flag1: 0, | |
697 | __pthread_mutex_flag2: 0, | |
698 | __pthread_mutex_ceiling: 0, | |
699 | __pthread_mutex_type: PTHREAD_PROCESS_PRIVATE, | |
700 | __pthread_mutex_magic: _MUTEX_MAGIC, | |
701 | __pthread_mutex_lock: 0, | |
702 | __pthread_mutex_data: 0 | |
703 | }; | |
704 | pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { | |
705 | __pthread_cond_flag: [0; 4], | |
706 | __pthread_cond_type: PTHREAD_PROCESS_PRIVATE, | |
707 | __pthread_cond_magic: _COND_MAGIC, | |
708 | __pthread_cond_data: 0 | |
709 | }; | |
710 | pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { | |
711 | __pthread_rwlock_readers: 0, | |
712 | __pthread_rwlock_type: PTHREAD_PROCESS_PRIVATE, | |
713 | __pthread_rwlock_magic: _RWL_MAGIC, | |
714 | __pthread_rwlock_mutex: PTHREAD_MUTEX_INITIALIZER, | |
715 | __pthread_rwlock_readercv: PTHREAD_COND_INITIALIZER, | |
716 | __pthread_rwlock_writercv: PTHREAD_COND_INITIALIZER | |
717 | }; | |
718 | pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 4; | |
719 | ||
720 | f! { | |
721 | pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () { | |
722 | let fd = fd as usize; | |
723 | (*set).fds_bits[fd / 32] &= !(1 << (fd % 32)); | |
724 | return | |
725 | } | |
726 | ||
727 | pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool { | |
728 | let fd = fd as usize; | |
729 | return ((*set).fds_bits[fd / 32] & (1 << (fd % 32))) != 0 | |
730 | } | |
731 | ||
732 | pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () { | |
733 | let fd = fd as usize; | |
734 | (*set).fds_bits[fd / 32] |= 1 << (fd % 32); | |
735 | return | |
736 | } | |
737 | ||
738 | pub fn FD_ZERO(set: *mut fd_set) -> () { | |
739 | for slot in (*set).fds_bits.iter_mut() { | |
740 | *slot = 0; | |
741 | } | |
742 | } | |
743 | ||
744 | pub fn WIFEXITED(status: ::c_int) -> bool { | |
745 | (status & 0xFF) == 0 | |
746 | } | |
747 | ||
748 | pub fn WEXITSTATUS(status: ::c_int) -> ::c_int { | |
749 | (status >> 8) & 0xFF | |
750 | } | |
751 | ||
752 | pub fn WTERMSIG(status: ::c_int) -> ::c_int { | |
753 | status & 0x7F | |
754 | } | |
755 | } | |
756 | ||
757 | extern { | |
758 | pub fn stack_getbounds(sp: *mut ::stack_t) -> ::c_int; | |
759 | pub fn mincore(addr: *const ::c_void, len: ::size_t, | |
760 | vec: *mut c_char) -> ::c_int; | |
761 | pub fn setgroups(ngroups: ::c_int, | |
762 | ptr: *const ::gid_t) -> ::c_int; | |
763 | pub fn ioctl(fildes: ::c_int, request: ::c_int, ...) -> ::c_int; | |
764 | pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int) | |
765 | -> ::c_int; | |
54a0048b SL |
766 | pub fn clock_getres(clk_id: clockid_t, tp: *mut ::timespec) -> ::c_int; |
767 | pub fn clock_gettime(clk_id: clockid_t, tp: *mut ::timespec) -> ::c_int; | |
7453a54e SL |
768 | pub fn getnameinfo(sa: *const ::sockaddr, |
769 | salen: ::socklen_t, | |
770 | host: *mut ::c_char, | |
771 | hostlen: ::socklen_t, | |
772 | serv: *mut ::c_char, | |
773 | sevlen: ::socklen_t, | |
774 | flags: ::c_int) -> ::c_int; | |
775 | pub fn getpwuid_r(uid: ::uid_t, | |
776 | pwd: *mut passwd, | |
777 | buf: *mut ::c_char, | |
778 | buflen: ::size_t) -> *const passwd; | |
779 | pub fn readdir(dirp: *mut ::DIR) -> *const ::dirent; | |
54a0048b | 780 | pub fn fdatasync(fd: ::c_int) -> ::c_int; |
7453a54e SL |
781 | } |
782 |