1 pub type c_char = i8;
2 pub type clock_t = u64;
3 pub type ino_t = u64;
4 pub type lwpid_t = i32;
5 pub type nlink_t = u32;
6 pub type blksize_t = i64;
7 pub type clockid_t = ::c_ulong;
8 
9 pub type c_long = i64;
10 pub type c_ulong = u64;
11 pub type time_t = i64;
12 pub type suseconds_t = i64;
13 
14 pub type uuid_t = ::uuid;
15 
16 pub type fsblkcnt_t = u64;
17 pub type fsfilcnt_t = u64;
18 
19 pub type sem_t = *mut sem;
20 
21 #[cfg_attr(feature = "extra_traits", derive(Debug))]
22 pub enum sem {}
23 impl ::Copy for sem {}
24 impl ::Clone for sem {
clone(&self) -> sem25     fn clone(&self) -> sem { *self }
26 }
27 
28 s! {
29     pub struct exit_status {
30         pub e_termination: u16,
31         pub e_exit: u16
32     }
33 
34     pub struct aiocb {
35         pub aio_fildes: ::c_int,
36         pub aio_offset: ::off_t,
37         pub aio_buf: *mut ::c_void,
38         pub aio_nbytes: ::size_t,
39         pub aio_sigevent: sigevent,
40         pub aio_lio_opcode: ::c_int,
41         pub aio_reqprio: ::c_int,
42         _aio_val: ::c_int,
43         _aio_err: ::c_int
44     }
45 
46     pub struct uuid {
47         pub time_low: u32,
48         pub time_mid: u16,
49         pub time_hi_and_version: u16,
50         pub clock_seq_hi_and_reserved: u8,
51         pub clock_seq_low: u8,
52         pub node: [u8; 6],
53     }
54 
55     pub struct mq_attr {
56         pub mq_flags: ::c_long,
57         pub mq_maxmsg: ::c_long,
58         pub mq_msgsize: ::c_long,
59         pub mq_curmsgs: ::c_long,
60     }
61 
62     pub struct sigevent {
63         pub sigev_notify: ::c_int,
64         // The union is 8-byte in size, so it is aligned at a 8-byte offset.
65         #[cfg(target_pointer_width = "64")]
66         __unused1: ::c_int,
67         pub sigev_signo: ::c_int,       //actually a union
68         // pad the union
69         #[cfg(target_pointer_width = "64")]
70         __unused2: ::c_int,
71         pub sigev_value: ::sigval,
72         __unused3: *mut ::c_void        //actually a function pointer
73     }
74 
75     pub struct statvfs {
76         pub f_bsize: ::c_ulong,
77         pub f_frsize: ::c_ulong,
78         pub f_blocks: ::fsblkcnt_t,
79         pub f_bfree: ::fsblkcnt_t,
80         pub f_bavail: ::fsblkcnt_t,
81         pub f_files: ::fsfilcnt_t,
82         pub f_ffree: ::fsfilcnt_t,
83         pub f_favail: ::fsfilcnt_t,
84         pub f_fsid: ::c_ulong,
85         pub f_flag: ::c_ulong,
86         pub f_namemax: ::c_ulong,
87         pub f_owner: ::uid_t,
88         pub f_type: ::c_uint,
89         pub f_syncreads: u64,
90         pub f_syncwrites: u64,
91         pub f_asyncreads: u64,
92         pub f_asyncwrites: u64,
93         pub f_fsid_uuid: ::uuid_t,
94         pub f_uid_uuid: ::uuid_t,
95     }
96 
97     pub struct stat {
98         pub st_ino: ::ino_t,
99         pub st_nlink: ::nlink_t,
100         pub st_dev: ::dev_t,
101         pub st_mode: ::mode_t,
102         pub st_padding1: ::uint16_t,
103         pub st_uid: ::uid_t,
104         pub st_gid: ::gid_t,
105         pub st_rdev: ::dev_t,
106         pub st_atime: ::time_t,
107         pub st_atime_nsec: ::c_long,
108         pub st_mtime: ::time_t,
109         pub st_mtime_nsec: ::c_long,
110         pub st_ctime: ::time_t,
111         pub st_ctime_nsec: ::c_long,
112         pub st_size: ::off_t,
113         pub st_blocks: ::int64_t,
114         pub st_blksize: ::uint32_t,
115         pub st_flags: ::uint32_t,
116         pub st_gen: ::uint32_t,
117         pub st_lspare: ::int32_t,
118         pub st_qspare1: ::int64_t,
119         pub st_qspare2: ::int64_t,
120     }
121 
122     pub struct if_data {
123         pub ifi_type: ::c_uchar,
124         pub ifi_physical: ::c_uchar,
125         pub ifi_addrlen: ::c_uchar,
126         pub ifi_hdrlen: ::c_uchar,
127         pub ifi_recvquota: ::c_uchar,
128         pub ifi_xmitquota: ::c_uchar,
129         pub ifi_mtu: ::c_ulong,
130         pub ifi_metric: ::c_ulong,
131         pub ifi_link_state: ::c_ulong,
132         pub ifi_baudrate: u64,
133         pub ifi_ipackets: ::c_ulong,
134         pub ifi_ierrors: ::c_ulong,
135         pub ifi_opackets: ::c_ulong,
136         pub ifi_oerrors: ::c_ulong,
137         pub ifi_collisions: ::c_ulong,
138         pub ifi_ibytes: ::c_ulong,
139         pub ifi_obytes: ::c_ulong,
140         pub ifi_imcasts: ::c_ulong,
141         pub ifi_omcasts: ::c_ulong,
142         pub ifi_iqdrops: ::c_ulong,
143         pub ifi_noproto: ::c_ulong,
144         pub ifi_hwassist: ::c_ulong,
145         pub ifi_oqdrops: ::c_ulong,
146         pub ifi_lastchange: ::timeval,
147     }
148 
149     pub struct if_msghdr {
150         pub ifm_msglen: ::c_ushort,
151         pub ifm_version: ::c_uchar,
152         pub ifm_type: ::c_uchar,
153         pub ifm_addrs: ::c_int,
154         pub ifm_flags: ::c_int,
155         pub ifm_index: ::c_ushort,
156         pub ifm_data: if_data,
157     }
158 
159     pub struct sockaddr_dl {
160         pub sdl_len: ::c_uchar,
161         pub sdl_family: ::c_uchar,
162         pub sdl_index: ::c_ushort,
163         pub sdl_type: ::c_uchar,
164         pub sdl_nlen: ::c_uchar,
165         pub sdl_alen: ::c_uchar,
166         pub sdl_slen: ::c_uchar,
167         pub sdl_data: [::c_char; 12],
168         pub sdl_rcf: ::c_ushort,
169         pub sdl_route: [::c_ushort; 16],
170     }
171 
172     pub struct stack_t {
173         pub ss_sp: *mut ::c_char,
174         pub ss_size: ::size_t,
175         pub ss_flags: ::c_int,
176     }
177 }
178 
179 s_no_extra_traits! {
180     #[allow(missing_debug_implementations)]
181     pub struct utmpx {
182         pub ut_name: [::c_char; 32],
183         pub ut_id: [::c_char; 4],
184 
185         pub ut_line: [::c_char; 32],
186         pub ut_host: [::c_char; 256],
187 
188         pub ut_unused: [u8; 16],
189         pub ut_session: u16,
190         pub ut_type: u16,
191         pub ut_pid: ::pid_t,
192         ut_exit: exit_status,
193         ut_ss: ::sockaddr_storage,
194         pub ut_tv: ::timeval,
195         pub ut_unused2: [u8; 16],
196     }
197 
198     #[allow(missing_debug_implementations)]
199     pub struct dirent {
200         pub d_fileno: ::ino_t,
201         pub d_namlen: u16,
202         pub d_type: u8,
203         __unused1: u8,
204         __unused2: u32,
205         pub d_name: [::c_char; 256],
206     }
207 
208     #[allow(missing_debug_implementations)]
209     pub struct statfs {
210         pub f_bsize: ::c_long,
211         pub f_iosize: ::c_long,
212         pub f_blocks: ::c_long,
213         pub f_bfree: ::c_long,
214         pub f_bavail: ::c_long,
215         pub f_files: ::c_long,
216         pub f_ffree: ::c_long,
217         pub f_fsid: ::fsid_t,
218         pub f_owner: ::uid_t,
219         pub f_type: ::int32_t,
220         pub f_flags: ::int32_t,
221         pub f_syncwrites: ::c_long,
222         pub f_asyncwrites: ::c_long,
223         pub f_fstypename: [::c_char; 16],
224         pub f_mntonname: [::c_char; 90],
225         pub f_syncreads: ::c_long,
226         pub f_asyncreads: ::c_long,
227         pub f_mntfromname: [::c_char; 90],
228     }
229 }
230 
231 pub const RAND_MAX: ::c_int = 0x7fff_ffff;
232 pub const PTHREAD_STACK_MIN: ::size_t = 16384;
233 pub const SIGSTKSZ: ::size_t = 40960;
234 pub const MADV_INVAL: ::c_int = 10;
235 pub const MADV_SETMAP: ::c_int = 11;
236 pub const O_CLOEXEC: ::c_int = 0x00020000;
237 pub const O_DIRECTORY: ::c_int = 0x08000000;
238 pub const F_GETLK: ::c_int = 7;
239 pub const F_SETLK: ::c_int = 8;
240 pub const F_SETLKW: ::c_int = 9;
241 pub const ENOMEDIUM: ::c_int = 93;
242 pub const EASYNC: ::c_int = 99;
243 pub const ELAST: ::c_int = 99;
244 pub const RLIMIT_POSIXLOCKS: ::c_int = 11;
245 pub const RLIM_NLIMITS: ::rlim_t = 12;
246 
247 pub const Q_GETQUOTA: ::c_int = 0x300;
248 pub const Q_SETQUOTA: ::c_int = 0x400;
249 
250 pub const CLOCK_REALTIME: ::clockid_t = 0;
251 pub const CLOCK_VIRTUAL: ::clockid_t = 1;
252 pub const CLOCK_PROF: ::clockid_t = 2;
253 pub const CLOCK_MONOTONIC: ::clockid_t = 4;
254 pub const CLOCK_UPTIME: ::clockid_t = 5;
255 pub const CLOCK_UPTIME_PRECISE: ::clockid_t = 7;
256 pub const CLOCK_UPTIME_FAST: ::clockid_t = 8;
257 pub const CLOCK_REALTIME_PRECISE: ::clockid_t = 9;
258 pub const CLOCK_REALTIME_FAST: ::clockid_t = 10;
259 pub const CLOCK_MONOTONIC_PRECISE: ::clockid_t = 11;
260 pub const CLOCK_MONOTONIC_FAST: ::clockid_t = 12;
261 pub const CLOCK_SECOND: ::clockid_t = 13;
262 pub const CLOCK_THREAD_CPUTIME_ID: ::clockid_t = 14;
263 pub const CLOCK_PROCESS_CPUTIME_ID: ::clockid_t = 15;
264 
265 pub const CTL_UNSPEC: ::c_int = 0;
266 pub const CTL_KERN: ::c_int = 1;
267 pub const CTL_VM: ::c_int = 2;
268 pub const CTL_VFS: ::c_int = 3;
269 pub const CTL_NET: ::c_int = 4;
270 pub const CTL_DEBUG: ::c_int = 5;
271 pub const CTL_HW: ::c_int = 6;
272 pub const CTL_MACHDEP: ::c_int = 7;
273 pub const CTL_USER: ::c_int = 8;
274 pub const CTL_P1003_1B: ::c_int = 9;
275 pub const CTL_LWKT: ::c_int = 10;
276 pub const CTL_MAXID: ::c_int = 11;
277 pub const KERN_OSTYPE: ::c_int = 1;
278 pub const KERN_OSRELEASE: ::c_int = 2;
279 pub const KERN_OSREV: ::c_int = 3;
280 pub const KERN_VERSION: ::c_int = 4;
281 pub const KERN_MAXVNODES: ::c_int = 5;
282 pub const KERN_MAXPROC: ::c_int = 6;
283 pub const KERN_MAXFILES: ::c_int = 7;
284 pub const KERN_ARGMAX: ::c_int = 8;
285 pub const KERN_SECURELVL: ::c_int = 9;
286 pub const KERN_HOSTNAME: ::c_int = 10;
287 pub const KERN_HOSTID: ::c_int = 11;
288 pub const KERN_CLOCKRATE: ::c_int = 12;
289 pub const KERN_VNODE: ::c_int = 13;
290 pub const KERN_PROC: ::c_int = 14;
291 pub const KERN_FILE: ::c_int = 15;
292 pub const KERN_PROF: ::c_int = 16;
293 pub const KERN_POSIX1: ::c_int = 17;
294 pub const KERN_NGROUPS: ::c_int = 18;
295 pub const KERN_JOB_CONTROL: ::c_int = 19;
296 pub const KERN_SAVED_IDS: ::c_int = 20;
297 pub const KERN_BOOTTIME: ::c_int = 21;
298 pub const KERN_NISDOMAINNAME: ::c_int = 22;
299 pub const KERN_UPDATEINTERVAL: ::c_int = 23;
300 pub const KERN_OSRELDATE: ::c_int = 24;
301 pub const KERN_NTP_PLL: ::c_int = 25;
302 pub const KERN_BOOTFILE: ::c_int = 26;
303 pub const KERN_MAXFILESPERPROC: ::c_int = 27;
304 pub const KERN_MAXPROCPERUID: ::c_int = 28;
305 pub const KERN_DUMPDEV: ::c_int = 29;
306 pub const KERN_IPC: ::c_int = 30;
307 pub const KERN_DUMMY: ::c_int = 31;
308 pub const KERN_PS_STRINGS: ::c_int = 32;
309 pub const KERN_USRSTACK: ::c_int = 33;
310 pub const KERN_LOGSIGEXIT: ::c_int = 34;
311 pub const KERN_IOV_MAX: ::c_int = 35;
312 pub const KERN_MAXPOSIXLOCKSPERUID: ::c_int = 36;
313 pub const KERN_MAXID: ::c_int = 37;
314 pub const KERN_PROC_ALL: ::c_int = 0;
315 pub const KERN_PROC_PID: ::c_int = 1;
316 pub const KERN_PROC_PGRP: ::c_int = 2;
317 pub const KERN_PROC_SESSION: ::c_int = 3;
318 pub const KERN_PROC_TTY: ::c_int = 4;
319 pub const KERN_PROC_UID: ::c_int = 5;
320 pub const KERN_PROC_RUID: ::c_int = 6;
321 pub const KERN_PROC_ARGS: ::c_int = 7;
322 pub const KERN_PROC_CWD: ::c_int = 8;
323 pub const KERN_PROC_PATHNAME: ::c_int = 9;
324 pub const KERN_PROC_FLAGMASK: ::c_int = 0x10;
325 pub const KERN_PROC_FLAG_LWP: ::c_int = 0x10;
326 pub const KIPC_MAXSOCKBUF: ::c_int = 1;
327 pub const KIPC_SOCKBUF_WASTE: ::c_int = 2;
328 pub const KIPC_SOMAXCONN: ::c_int = 3;
329 pub const KIPC_MAX_LINKHDR: ::c_int = 4;
330 pub const KIPC_MAX_PROTOHDR: ::c_int = 5;
331 pub const KIPC_MAX_HDR: ::c_int = 6;
332 pub const KIPC_MAX_DATALEN: ::c_int = 7;
333 pub const KIPC_MBSTAT: ::c_int = 8;
334 pub const KIPC_NMBCLUSTERS: ::c_int = 9;
335 pub const HW_MACHINE: ::c_int = 1;
336 pub const HW_MODEL: ::c_int = 2;
337 pub const HW_NCPU: ::c_int = 3;
338 pub const HW_BYTEORDER: ::c_int = 4;
339 pub const HW_PHYSMEM: ::c_int = 5;
340 pub const HW_USERMEM: ::c_int = 6;
341 pub const HW_PAGESIZE: ::c_int = 7;
342 pub const HW_DISKNAMES: ::c_int = 8;
343 pub const HW_DISKSTATS: ::c_int = 9;
344 pub const HW_FLOATINGPT: ::c_int = 10;
345 pub const HW_MACHINE_ARCH: ::c_int = 11;
346 pub const HW_MACHINE_PLATFORM: ::c_int = 12;
347 pub const HW_SENSORS: ::c_int = 13;
348 pub const HW_MAXID: ::c_int = 14;
349 pub const USER_CS_PATH: ::c_int = 1;
350 pub const USER_BC_BASE_MAX: ::c_int = 2;
351 pub const USER_BC_DIM_MAX: ::c_int = 3;
352 pub const USER_BC_SCALE_MAX: ::c_int = 4;
353 pub const USER_BC_STRING_MAX: ::c_int = 5;
354 pub const USER_COLL_WEIGHTS_MAX: ::c_int = 6;
355 pub const USER_EXPR_NEST_MAX: ::c_int = 7;
356 pub const USER_LINE_MAX: ::c_int = 8;
357 pub const USER_RE_DUP_MAX: ::c_int = 9;
358 pub const USER_POSIX2_VERSION: ::c_int = 10;
359 pub const USER_POSIX2_C_BIND: ::c_int = 11;
360 pub const USER_POSIX2_C_DEV: ::c_int = 12;
361 pub const USER_POSIX2_CHAR_TERM: ::c_int = 13;
362 pub const USER_POSIX2_FORT_DEV: ::c_int = 14;
363 pub const USER_POSIX2_FORT_RUN: ::c_int = 15;
364 pub const USER_POSIX2_LOCALEDEF: ::c_int = 16;
365 pub const USER_POSIX2_SW_DEV: ::c_int = 17;
366 pub const USER_POSIX2_UPE: ::c_int = 18;
367 pub const USER_STREAM_MAX: ::c_int = 19;
368 pub const USER_TZNAME_MAX: ::c_int = 20;
369 pub const USER_MAXID: ::c_int = 21;
370 pub const CTL_P1003_1B_ASYNCHRONOUS_IO: ::c_int = 1;
371 pub const CTL_P1003_1B_MAPPED_FILES: ::c_int = 2;
372 pub const CTL_P1003_1B_MEMLOCK: ::c_int = 3;
373 pub const CTL_P1003_1B_MEMLOCK_RANGE: ::c_int = 4;
374 pub const CTL_P1003_1B_MEMORY_PROTECTION: ::c_int = 5;
375 pub const CTL_P1003_1B_MESSAGE_PASSING: ::c_int = 6;
376 pub const CTL_P1003_1B_PRIORITIZED_IO: ::c_int = 7;
377 pub const CTL_P1003_1B_PRIORITY_SCHEDULING: ::c_int = 8;
378 pub const CTL_P1003_1B_REALTIME_SIGNALS: ::c_int = 9;
379 pub const CTL_P1003_1B_SEMAPHORES: ::c_int = 10;
380 pub const CTL_P1003_1B_FSYNC: ::c_int = 11;
381 pub const CTL_P1003_1B_SHARED_MEMORY_OBJECTS: ::c_int = 12;
382 pub const CTL_P1003_1B_SYNCHRONIZED_IO: ::c_int = 13;
383 pub const CTL_P1003_1B_TIMERS: ::c_int = 14;
384 pub const CTL_P1003_1B_AIO_LISTIO_MAX: ::c_int = 15;
385 pub const CTL_P1003_1B_AIO_MAX: ::c_int = 16;
386 pub const CTL_P1003_1B_AIO_PRIO_DELTA_MAX: ::c_int = 17;
387 pub const CTL_P1003_1B_DELAYTIMER_MAX: ::c_int = 18;
388 pub const CTL_P1003_1B_UNUSED1: ::c_int = 19;
389 pub const CTL_P1003_1B_PAGESIZE: ::c_int = 20;
390 pub const CTL_P1003_1B_RTSIG_MAX: ::c_int = 21;
391 pub const CTL_P1003_1B_SEM_NSEMS_MAX: ::c_int = 22;
392 pub const CTL_P1003_1B_SEM_VALUE_MAX: ::c_int = 23;
393 pub const CTL_P1003_1B_SIGQUEUE_MAX: ::c_int = 24;
394 pub const CTL_P1003_1B_TIMER_MAX: ::c_int = 25;
395 pub const CTL_P1003_1B_MAXID: ::c_int = 26;
396 
397 pub const EVFILT_READ: ::int16_t = -1;
398 pub const EVFILT_WRITE: ::int16_t = -2;
399 pub const EVFILT_AIO: ::int16_t = -3;
400 pub const EVFILT_VNODE: ::int16_t = -4;
401 pub const EVFILT_PROC: ::int16_t = -5;
402 pub const EVFILT_SIGNAL: ::int16_t = -6;
403 pub const EVFILT_TIMER: ::int16_t = -7;
404 pub const EVFILT_EXCEPT: ::int16_t = -8;
405 pub const EVFILT_USER: ::int16_t = -9;
406 pub const EVFILT_FS: ::int16_t = -10;
407 
408 pub const EV_ADD: ::uint16_t = 0x1;
409 pub const EV_DELETE: ::uint16_t = 0x2;
410 pub const EV_ENABLE: ::uint16_t = 0x4;
411 pub const EV_DISABLE: ::uint16_t = 0x8;
412 pub const EV_ONESHOT: ::uint16_t = 0x10;
413 pub const EV_CLEAR: ::uint16_t = 0x20;
414 pub const EV_RECEIPT: ::uint16_t = 0x40;
415 pub const EV_DISPATCH: ::uint16_t = 0x80;
416 pub const EV_NODATA: ::uint16_t = 0x1000;
417 pub const EV_FLAG1: ::uint16_t = 0x2000;
418 pub const EV_ERROR: ::uint16_t = 0x4000;
419 pub const EV_EOF: ::uint16_t = 0x8000;
420 pub const EV_SYSFLAGS: ::uint16_t = 0xf000;
421 
422 pub const NOTE_TRIGGER: ::uint32_t = 0x01000000;
423 pub const NOTE_FFNOP: ::uint32_t = 0x00000000;
424 pub const NOTE_FFAND: ::uint32_t = 0x40000000;
425 pub const NOTE_FFOR: ::uint32_t = 0x80000000;
426 pub const NOTE_FFCOPY: ::uint32_t = 0xc0000000;
427 pub const NOTE_FFCTRLMASK: ::uint32_t = 0xc0000000;
428 pub const NOTE_FFLAGSMASK: ::uint32_t = 0x00ffffff;
429 pub const NOTE_LOWAT: ::uint32_t = 0x00000001;
430 pub const NOTE_OOB: ::uint32_t = 0x00000002;
431 pub const NOTE_DELETE: ::uint32_t = 0x00000001;
432 pub const NOTE_WRITE: ::uint32_t = 0x00000002;
433 pub const NOTE_EXTEND: ::uint32_t = 0x00000004;
434 pub const NOTE_ATTRIB: ::uint32_t = 0x00000008;
435 pub const NOTE_LINK: ::uint32_t = 0x00000010;
436 pub const NOTE_RENAME: ::uint32_t = 0x00000020;
437 pub const NOTE_REVOKE: ::uint32_t = 0x00000040;
438 pub const NOTE_EXIT: ::uint32_t = 0x80000000;
439 pub const NOTE_FORK: ::uint32_t = 0x40000000;
440 pub const NOTE_EXEC: ::uint32_t = 0x20000000;
441 pub const NOTE_PDATAMASK: ::uint32_t = 0x000fffff;
442 pub const NOTE_PCTRLMASK: ::uint32_t = 0xf0000000;
443 pub const NOTE_TRACK: ::uint32_t = 0x00000001;
444 pub const NOTE_TRACKERR: ::uint32_t = 0x00000002;
445 pub const NOTE_CHILD: ::uint32_t = 0x00000004;
446 
447 pub const SO_SNDSPACE: ::c_int = 0x100a;
448 pub const SO_CPUHINT: ::c_int = 0x1030;
449 
450 pub const PT_FIRSTMACH: ::c_int = 32;
451 
452 // https://github.com/DragonFlyBSD/DragonFlyBSD/blob/master/sys/net/if.h#L101
453 pub const IFF_UP: ::c_int = 0x1; // interface is up
454 pub const IFF_BROADCAST: ::c_int = 0x2; // broadcast address valid
455 pub const IFF_DEBUG: ::c_int = 0x4; // turn on debugging
456 pub const IFF_LOOPBACK: ::c_int = 0x8; // is a loopback net
457 pub const IFF_POINTOPOINT: ::c_int = 0x10; // interface is point-to-point link
458 pub const IFF_SMART: ::c_int = 0x20; // interface manages own routes
459 pub const IFF_RUNNING: ::c_int = 0x40; // resources allocated
460 pub const IFF_NOARP: ::c_int = 0x80; // no address resolution protocol
461 pub const IFF_PROMISC: ::c_int = 0x100; // receive all packets
462 pub const IFF_ALLMULTI: ::c_int = 0x200; // receive all multicast packets
463 pub const IFF_OACTIVE_COMPAT: ::c_int = 0x400; // was transmission in progress
464 pub const IFF_SIMPLEX: ::c_int = 0x800; // can't hear own transmissions
465 pub const IFF_LINK0: ::c_int = 0x1000; // per link layer defined bit
466 pub const IFF_LINK1: ::c_int = 0x2000; // per link layer defined bit
467 pub const IFF_LINK2: ::c_int = 0x4000; // per link layer defined bit
468 pub const IFF_ALTPHYS: ::c_int = IFF_LINK2; // use alternate physical connection
469 pub const IFF_MULTICAST: ::c_int = 0x8000; // supports multicast
470 // was interface is in polling mode
471 pub const IFF_POLLING_COMPAT: ::c_int = 0x10000;
472 pub const IFF_PPROMISC: ::c_int = 0x20000; // user-requested promisc mode
473 pub const IFF_MONITOR: ::c_int = 0x40000; // user-requested monitor mode
474 pub const IFF_STATICARP: ::c_int = 0x80000; // static ARP
475 pub const IFF_NPOLLING: ::c_int = 0x100000; // interface is in polling mode
476 pub const IFF_IDIRECT: ::c_int = 0x200000; // direct input
477 
478 //
479 // sys/netinet/in.h
480 // Protocols (RFC 1700)
481 // NOTE: These are in addition to the constants defined in src/unix/mod.rs
482 
483 // IPPROTO_IP defined in src/unix/mod.rs
484 /// IP6 hop-by-hop options
485 pub const IPPROTO_HOPOPTS: ::c_int = 0;
486 // IPPROTO_ICMP defined in src/unix/mod.rs
487 /// group mgmt protocol
488 pub const IPPROTO_IGMP: ::c_int = 2;
489 /// gateway^2 (deprecated)
490 pub const IPPROTO_GGP: ::c_int = 3;
491 /// for compatibility
492 pub const IPPROTO_IPIP: ::c_int = 4;
493 // IPPROTO_TCP defined in src/unix/mod.rs
494 /// Stream protocol II.
495 pub const IPPROTO_ST: ::c_int = 7;
496 /// exterior gateway protocol
497 pub const IPPROTO_EGP: ::c_int = 8;
498 /// private interior gateway
499 pub const IPPROTO_PIGP: ::c_int = 9;
500 /// BBN RCC Monitoring
501 pub const IPPROTO_RCCMON: ::c_int = 10;
502 /// network voice protocol
503 pub const IPPROTO_NVPII: ::c_int = 11;
504 /// pup
505 pub const IPPROTO_PUP: ::c_int = 12;
506 /// Argus
507 pub const IPPROTO_ARGUS: ::c_int = 13;
508 /// EMCON
509 pub const IPPROTO_EMCON: ::c_int = 14;
510 /// Cross Net Debugger
511 pub const IPPROTO_XNET: ::c_int = 15;
512 /// Chaos
513 pub const IPPROTO_CHAOS: ::c_int = 16;
514 // IPPROTO_UDP defined in src/unix/mod.rs
515 /// Multiplexing
516 pub const IPPROTO_MUX: ::c_int = 18;
517 /// DCN Measurement Subsystems
518 pub const IPPROTO_MEAS: ::c_int = 19;
519 /// Host Monitoring
520 pub const IPPROTO_HMP: ::c_int = 20;
521 /// Packet Radio Measurement
522 pub const IPPROTO_PRM: ::c_int = 21;
523 /// xns idp
524 pub const IPPROTO_IDP: ::c_int = 22;
525 /// Trunk-1
526 pub const IPPROTO_TRUNK1: ::c_int = 23;
527 /// Trunk-2
528 pub const IPPROTO_TRUNK2: ::c_int = 24;
529 /// Leaf-1
530 pub const IPPROTO_LEAF1: ::c_int = 25;
531 /// Leaf-2
532 pub const IPPROTO_LEAF2: ::c_int = 26;
533 /// Reliable Data
534 pub const IPPROTO_RDP: ::c_int = 27;
535 /// Reliable Transaction
536 pub const IPPROTO_IRTP: ::c_int = 28;
537 /// tp-4 w/ class negotiation
538 pub const IPPROTO_TP: ::c_int = 29;
539 /// Bulk Data Transfer
540 pub const IPPROTO_BLT: ::c_int = 30;
541 /// Network Services
542 pub const IPPROTO_NSP: ::c_int = 31;
543 /// Merit Internodal
544 pub const IPPROTO_INP: ::c_int = 32;
545 /// Sequential Exchange
546 pub const IPPROTO_SEP: ::c_int = 33;
547 /// Third Party Connect
548 pub const IPPROTO_3PC: ::c_int = 34;
549 /// InterDomain Policy Routing
550 pub const IPPROTO_IDPR: ::c_int = 35;
551 /// XTP
552 pub const IPPROTO_XTP: ::c_int = 36;
553 /// Datagram Delivery
554 pub const IPPROTO_DDP: ::c_int = 37;
555 /// Control Message Transport
556 pub const IPPROTO_CMTP: ::c_int = 38;
557 /// TP++ Transport
558 pub const IPPROTO_TPXX: ::c_int = 39;
559 /// IL transport protocol
560 pub const IPPROTO_IL: ::c_int = 40;
561 // IPPROTO_IPV6 defined in src/unix/mod.rs
562 /// Source Demand Routing
563 pub const IPPROTO_SDRP: ::c_int = 42;
564 /// IP6 routing header
565 pub const IPPROTO_ROUTING: ::c_int = 43;
566 /// IP6 fragmentation header
567 pub const IPPROTO_FRAGMENT: ::c_int = 44;
568 /// InterDomain Routing
569 pub const IPPROTO_IDRP: ::c_int = 45;
570 /// resource reservation
571 pub const IPPROTO_RSVP: ::c_int = 46;
572 /// General Routing Encap.
573 pub const IPPROTO_GRE: ::c_int = 47;
574 /// Mobile Host Routing
575 pub const IPPROTO_MHRP: ::c_int = 48;
576 /// BHA
577 pub const IPPROTO_BHA: ::c_int = 49;
578 /// IP6 Encap Sec. Payload
579 pub const IPPROTO_ESP: ::c_int = 50;
580 /// IP6 Auth Header
581 pub const IPPROTO_AH: ::c_int = 51;
582 /// Integ. Net Layer Security
583 pub const IPPROTO_INLSP: ::c_int = 52;
584 /// IP with encryption
585 pub const IPPROTO_SWIPE: ::c_int = 53;
586 /// Next Hop Resolution
587 pub const IPPROTO_NHRP: ::c_int = 54;
588 /// IP Mobility
589 pub const IPPROTO_MOBILE: ::c_int = 55;
590 /// Transport Layer Security
591 pub const IPPROTO_TLSP: ::c_int = 56;
592 /// SKIP
593 pub const IPPROTO_SKIP: ::c_int = 57;
594 // IPPROTO_ICMPV6 defined in src/unix/mod.rs
595 /// IP6 no next header
596 pub const IPPROTO_NONE: ::c_int = 59;
597 /// IP6 destination option
598 pub const IPPROTO_DSTOPTS: ::c_int = 60;
599 /// any host internal protocol
600 pub const IPPROTO_AHIP: ::c_int = 61;
601 /// CFTP
602 pub const IPPROTO_CFTP: ::c_int = 62;
603 /// "hello" routing protocol
604 pub const IPPROTO_HELLO: ::c_int = 63;
605 /// SATNET/Backroom EXPAK
606 pub const IPPROTO_SATEXPAK: ::c_int = 64;
607 /// Kryptolan
608 pub const IPPROTO_KRYPTOLAN: ::c_int = 65;
609 /// Remote Virtual Disk
610 pub const IPPROTO_RVD: ::c_int = 66;
611 /// Pluribus Packet Core
612 pub const IPPROTO_IPPC: ::c_int = 67;
613 /// Any distributed FS
614 pub const IPPROTO_ADFS: ::c_int = 68;
615 /// Satnet Monitoring
616 pub const IPPROTO_SATMON: ::c_int = 69;
617 /// VISA Protocol
618 pub const IPPROTO_VISA: ::c_int = 70;
619 /// Packet Core Utility
620 pub const IPPROTO_IPCV: ::c_int = 71;
621 /// Comp. Prot. Net. Executive
622 pub const IPPROTO_CPNX: ::c_int = 72;
623 /// Comp. Prot. HeartBeat
624 pub const IPPROTO_CPHB: ::c_int = 73;
625 /// Wang Span Network
626 pub const IPPROTO_WSN: ::c_int = 74;
627 /// Packet Video Protocol
628 pub const IPPROTO_PVP: ::c_int = 75;
629 /// BackRoom SATNET Monitoring
630 pub const IPPROTO_BRSATMON: ::c_int = 76;
631 /// Sun net disk proto (temp.)
632 pub const IPPROTO_ND: ::c_int = 77;
633 /// WIDEBAND Monitoring
634 pub const IPPROTO_WBMON: ::c_int = 78;
635 /// WIDEBAND EXPAK
636 pub const IPPROTO_WBEXPAK: ::c_int = 79;
637 /// ISO cnlp
638 pub const IPPROTO_EON: ::c_int = 80;
639 /// VMTP
640 pub const IPPROTO_VMTP: ::c_int = 81;
641 /// Secure VMTP
642 pub const IPPROTO_SVMTP: ::c_int = 82;
643 /// Banyon VINES
644 pub const IPPROTO_VINES: ::c_int = 83;
645 /// TTP
646 pub const IPPROTO_TTP: ::c_int = 84;
647 /// NSFNET-IGP
648 pub const IPPROTO_IGP: ::c_int = 85;
649 /// dissimilar gateway prot.
650 pub const IPPROTO_DGP: ::c_int = 86;
651 /// TCF
652 pub const IPPROTO_TCF: ::c_int = 87;
653 /// Cisco/GXS IGRP
654 pub const IPPROTO_IGRP: ::c_int = 88;
655 /// OSPFIGP
656 pub const IPPROTO_OSPFIGP: ::c_int = 89;
657 /// Strite RPC protocol
658 pub const IPPROTO_SRPC: ::c_int = 90;
659 /// Locus Address Resoloution
660 pub const IPPROTO_LARP: ::c_int = 91;
661 /// Multicast Transport
662 pub const IPPROTO_MTP: ::c_int = 92;
663 /// AX.25 Frames
664 pub const IPPROTO_AX25: ::c_int = 93;
665 /// IP encapsulated in IP
666 pub const IPPROTO_IPEIP: ::c_int = 94;
667 /// Mobile Int.ing control
668 pub const IPPROTO_MICP: ::c_int = 95;
669 /// Semaphore Comm. security
670 pub const IPPROTO_SCCSP: ::c_int = 96;
671 /// Ethernet IP encapsulation
672 pub const IPPROTO_ETHERIP: ::c_int = 97;
673 /// encapsulation header
674 pub const IPPROTO_ENCAP: ::c_int = 98;
675 /// any private encr. scheme
676 pub const IPPROTO_APES: ::c_int = 99;
677 /// GMTP
678 pub const IPPROTO_GMTP: ::c_int = 100;
679 /// payload compression (IPComp)
680 pub const IPPROTO_IPCOMP: ::c_int = 108;
681 
682 /* 101-254: Partly Unassigned */
683 /// Protocol Independent Mcast
684 pub const IPPROTO_PIM: ::c_int = 103;
685 /// CARP
686 pub const IPPROTO_CARP: ::c_int = 112;
687 /// PGM
688 pub const IPPROTO_PGM: ::c_int = 113;
689 /// PFSYNC
690 pub const IPPROTO_PFSYNC: ::c_int = 240;
691 
692 /* 255: Reserved */
693 /* BSD Private, local use, namespace incursion, no longer used */
694 /// divert pseudo-protocol
695 pub const IPPROTO_DIVERT: ::c_int = 254;
696 pub const IPPROTO_MAX: ::c_int = 256;
697 /// last return value of *_input(), meaning "all job for this pkt is done".
698 pub const IPPROTO_DONE: ::c_int = 257;
699 
700 /// Used by RSS: the layer3 protocol is unknown
701 pub const IPPROTO_UNKNOWN: ::c_int = 258;
702 
703 // sys/netinet/tcp.h
704 pub const TCP_SIGNATURE_ENABLE:   ::c_int = 16;
705 pub const TCP_KEEPINIT:   ::c_int = 32;
706 pub const TCP_FASTKEEP:   ::c_int = 128;
707 
708 pub const AF_BLUETOOTH: ::c_int = 33;
709 pub const AF_MPLS: ::c_int = 34;
710 pub const AF_IEEE80211: ::c_int = 35;
711 pub const AF_MAX: ::c_int = 36;
712 
713 pub const PF_BLUETOOTH: ::c_int = AF_BLUETOOTH;
714 pub const PF_MAX: ::c_int = AF_MAX;
715 
716 pub const NET_RT_DUMP: ::c_int = 1;
717 pub const NET_RT_FLAGS: ::c_int = 2;
718 pub const NET_RT_IFLIST: ::c_int = 3;
719 pub const NET_RT_MAXID: ::c_int = 4;
720 
721 pub const SOMAXOPT_SIZE: ::c_int = 65536;
722 
723 #[doc(hidden)]
724 pub const NET_MAXID: ::c_int = AF_MAX;
725 
726 pub const MSG_UNUSED09: ::c_int = 0x00000200;
727 pub const MSG_NOSIGNAL: ::c_int = 0x00000400;
728 pub const MSG_SYNC: ::c_int = 0x00000800;
729 pub const MSG_CMSG_CLOEXEC: ::c_int = 0x00001000;
730 pub const MSG_FBLOCKING: ::c_int = 0x00010000;
731 pub const MSG_FNONBLOCKING: ::c_int = 0x00020000;
732 pub const MSG_FMASK: ::c_int = 0xFFFF0000;
733 
734 pub const EMPTY: ::c_short = 0;
735 pub const RUN_LVL: ::c_short = 1;
736 pub const BOOT_TIME: ::c_short = 2;
737 pub const OLD_TIME: ::c_short = 3;
738 pub const NEW_TIME: ::c_short = 4;
739 pub const INIT_PROCESS: ::c_short = 5;
740 pub const LOGIN_PROCESS: ::c_short = 6;
741 pub const USER_PROCESS: ::c_short = 7;
742 pub const DEAD_PROCESS: ::c_short = 8;
743 
744 pub const LC_COLLATE_MASK: ::c_int = (1 << 0);
745 pub const LC_CTYPE_MASK: ::c_int = (1 << 1);
746 pub const LC_MONETARY_MASK: ::c_int = (1 << 2);
747 pub const LC_NUMERIC_MASK: ::c_int = (1 << 3);
748 pub const LC_TIME_MASK: ::c_int = (1 << 4);
749 pub const LC_MESSAGES_MASK: ::c_int = (1 << 5);
750 pub const LC_ALL_MASK: ::c_int = LC_COLLATE_MASK
751                                | LC_CTYPE_MASK
752                                | LC_MESSAGES_MASK
753                                | LC_MONETARY_MASK
754                                | LC_NUMERIC_MASK
755                                | LC_TIME_MASK;
756 
757 pub const TIOCSIG: ::c_uint = 0x2000745f;
758 pub const BTUARTDISC: ::c_int = 0x7;
759 pub const TIOCDCDTIMESTAMP: ::c_uint = 0x40107458;
760 pub const TIOCISPTMASTER: ::c_uint = 0x20007455;
761 pub const TIOCMODG: ::c_uint = 0x40047403;
762 pub const TIOCMODS: ::c_ulong = 0x80047404;
763 pub const TIOCREMOTE: ::c_ulong = 0x80047469;
764 
765 // Constants used by "at" family of system calls.
766 pub const AT_FDCWD:            ::c_int = 0xFFFAFDCD; // invalid file descriptor
767 pub const AT_SYMLINK_NOFOLLOW: ::c_int = 1;
768 pub const AT_REMOVEDIR:        ::c_int = 2;
769 pub const AT_EACCESS:          ::c_int = 4;
770 pub const AT_SYMLINK_FOLLOW:   ::c_int = 8;
771 
772 pub const VCHECKPT: usize = 19;
773 
774 pub const _PC_2_SYMLINKS: ::c_int = 22;
775 pub const _PC_TIMESTAMP_RESOLUTION: ::c_int = 23;
776 
777 pub const _SC_V7_ILP32_OFF32: ::c_int = 122;
778 pub const _SC_V7_ILP32_OFFBIG: ::c_int = 123;
779 pub const _SC_V7_LP64_OFF64: ::c_int = 124;
780 pub const _SC_V7_LPBIG_OFFBIG: ::c_int = 125;
781 pub const _SC_THREAD_ROBUST_PRIO_INHERIT: ::c_int = 126;
782 pub const _SC_THREAD_ROBUST_PRIO_PROTECT: ::c_int = 127;
783 
784 pub const WCONTINUED: ::c_int = 4;
785 pub const WSTOPPED: ::c_int = 0o177;
786 
787 // Values for struct rtprio (type_ field)
788 pub const RTP_PRIO_REALTIME: ::c_ushort = 0;
789 pub const RTP_PRIO_NORMAL: ::c_ushort = 1;
790 pub const RTP_PRIO_IDLE: ::c_ushort = 2;
791 pub const RTP_PRIO_THREAD: ::c_ushort = 3;
792 
793 // Flags for chflags(2)
794 pub const UF_NOHISTORY: ::c_ulong = 0x00000040;
795 pub const UF_CACHE:     ::c_ulong = 0x00000080;
796 pub const UF_XLINK:     ::c_ulong = 0x00000100;
797 pub const SF_NOHISTORY: ::c_ulong = 0x00400000;
798 pub const SF_CACHE:     ::c_ulong = 0x00800000;
799 pub const SF_XLINK:     ::c_ulong = 0x01000000;
800 
_CMSG_ALIGN(n: usize) -> usize801 fn _CMSG_ALIGN(n: usize) -> usize {
802     (n + 3) & !3
803 }
804 
805 f! {
806     pub fn CMSG_DATA(cmsg: *const ::cmsghdr) -> *mut ::c_uchar {
807         (cmsg as *mut ::c_uchar)
808             .offset(_CMSG_ALIGN(::mem::size_of::<::cmsghdr>()) as isize)
809     }
810 
811     pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint {
812         (_CMSG_ALIGN(::mem::size_of::<::cmsghdr>()) + length as usize)
813             as ::c_uint
814     }
815 
816     pub fn CMSG_NXTHDR(mhdr: *const ::msghdr, cmsg: *const ::cmsghdr)
817         -> *mut ::cmsghdr
818     {
819         let next = cmsg as usize + _CMSG_ALIGN((*cmsg).cmsg_len as usize)
820             + _CMSG_ALIGN(::mem::size_of::<::cmsghdr>());
821         let max = (*mhdr).msg_control as usize
822             + (*mhdr).msg_controllen as usize;
823         if next <= max {
824             (cmsg as usize + _CMSG_ALIGN((*cmsg).cmsg_len as usize))
825                 as *mut ::cmsghdr
826         } else {
827             0 as *mut ::cmsghdr
828         }
829     }
830 
831     pub fn CMSG_SPACE(length: ::c_uint) -> ::c_uint {
832         (_CMSG_ALIGN(::mem::size_of::<::cmsghdr>()) +
833             _CMSG_ALIGN(length as usize)) as ::c_uint
834     }
835 }
836 
837 extern {
mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int838     pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int)
839                     -> ::c_int;
clock_getres(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int840     pub fn clock_getres(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int;
clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int841     pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int;
clock_settime(clk_id: ::clockid_t, tp: *const ::timespec) -> ::c_int842     pub fn clock_settime(clk_id: ::clockid_t, tp: *const ::timespec) -> ::c_int;
843 
setutxdb(_type: ::c_uint, file: *mut ::c_char) -> ::c_int844     pub fn setutxdb(_type: ::c_uint, file: *mut ::c_char) -> ::c_int;
845 
aio_waitcomplete(iocbp: *mut *mut aiocb, timeout: *mut ::timespec) -> ::c_int846     pub fn aio_waitcomplete(iocbp: *mut *mut aiocb,
847                             timeout: *mut ::timespec) -> ::c_int;
848 
freelocale(loc: ::locale_t)849     pub fn freelocale(loc: ::locale_t);
850 
lwp_rtprio(function: ::c_int, pid: ::pid_t, lwpid: lwpid_t, rtp: *mut super::rtprio) -> ::c_int851     pub fn lwp_rtprio(function: ::c_int, pid: ::pid_t, lwpid: lwpid_t,
852                       rtp: *mut super::rtprio) -> ::c_int;
853 
statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int854     pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int;
fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int855     pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int;
uname(buf: *mut ::utsname) -> ::c_int856     pub fn uname(buf: *mut ::utsname) -> ::c_int;
857 }
858