interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / vendor / libc / src / unix / nuttx / mod.rs

699 lines · 20891 bytes Raw Blame History
1///! Definitions for Apache NuttX RTOS.
2///!
3///! Following definitions are based on NuttX 13.0.0.
4///! See https://github.com/apache/nuttx/tree/releases/13.0 for more details.
5use crate::prelude::*;
6use crate::{
7 in6_addr,
8 in_addr_t,
9 timespec,
10 DIR,
11};
12
13pub type pid_t = c_int;
14pub type nlink_t = u16;
15pub type ino_t = u16;
16pub type blkcnt_t = u64;
17pub type blksize_t = i16;
18pub type cc_t = u8;
19pub type clock_t = i64;
20pub type dev_t = i32;
21pub type fsblkcnt_t = u64;
22pub type locale_t = *mut i8;
23pub type mode_t = u32;
24pub type nfds_t = u32;
25pub type off_t = i64;
26pub type pthread_key_t = i32;
27pub type pthread_mutexattr_t = u8;
28pub type pthread_rwlockattr_t = i32;
29pub type pthread_t = i32;
30pub type rlim_t = i64;
31pub type sa_family_t = u16;
32pub type socklen_t = c_uint;
33pub type speed_t = usize;
34pub type suseconds_t = i32;
35pub type tcflag_t = u32;
36pub type clockid_t = c_int;
37pub type time_t = i64;
38
39cfg_if! {
40 if #[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))] {
41 pub type wchar_t = c_int;
42 } else if #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] {
43 pub type wchar_t = c_uint;
44 }
45}
46
47s! {
48 // sys/stat.h
49 pub struct stat {
50 pub st_dev: dev_t,
51 pub st_ino: ino_t,
52 pub st_mode: mode_t,
53 pub st_nlink: nlink_t,
54 pub st_uid: u32,
55 pub st_gid: u32,
56 pub st_rdev: dev_t,
57 pub st_size: off_t,
58 pub st_atim: timespec,
59 pub st_mtim: timespec,
60 pub st_ctim: timespec,
61 pub st_blksize: blksize_t,
62 pub st_blocks: i64,
63 __reserved: Padding<[usize; __DEFAULT_RESERVED_SIZE__]>,
64 }
65
66 // sys/socket.h
67 pub struct sockaddr {
68 pub sa_family: sa_family_t,
69 pub sa_data: [u8; 14],
70 }
71
72 pub struct msghdr {
73 pub msg_name: *mut c_void,
74 pub msg_namelen: socklen_t,
75 pub msg_iov: *mut crate::iovec,
76 pub msg_iovlen: c_ulong,
77 pub msg_control: *mut c_void,
78 pub msg_controllen: c_ulong,
79 pub msg_flags: c_int,
80 }
81
82 // pwd.h
83 pub struct passwd {
84 pub pw_name: *const c_char,
85 pub pw_passwd: *const c_char,
86 pub pw_uid: u32,
87 pub pw_gid: u32,
88 pub pw_gecos: *const c_char,
89 pub pw_dir: *const c_char,
90 pub pw_shell: *const c_char,
91 __reserved: Padding<[usize; __DEFAULT_RESERVED_SIZE__]>,
92 }
93
94 pub struct sem_t {
95 __val: [usize; __SEM_SIZE__],
96 }
97
98 pub struct pthread_attr_t {
99 __val: [usize; __PTHREAD_ATTR_SIZE__],
100 }
101
102 pub struct pthread_mutex_t {
103 __val: [usize; __PTHREAD_MUTEX_SIZE__],
104 }
105
106 pub struct pthread_cond_t {
107 __val: [usize; __PTHREAD_COND_SIZE__],
108 }
109
110 pub struct pthread_condattr_t {
111 __val: [usize; __PTHREAD_CONDATTR_SIZE__],
112 }
113
114 pub struct Dl_info {
115 pub dli_fname: *const c_char,
116 pub dli_fbase: *mut c_void,
117 pub dli_sname: *const c_char,
118 pub dli_saddr: *mut c_void,
119 }
120
121 pub struct lconv {
122 pub decimal_point: *const c_char,
123 pub thousands_sep: *const c_char,
124 pub grouping: *const c_char,
125 pub int_curr_symbol: *const c_char,
126 pub currency_symbol: *const c_char,
127 pub mon_decimal_point: *const c_char,
128 pub mon_thousands_sep: *const c_char,
129 pub mon_grouping: *const c_char,
130 pub positive_sign: *const c_char,
131 pub negative_sign: *const c_char,
132 pub int_frac_digits: i8,
133 pub frac_digits: i8,
134 pub p_cs_precedes: i8,
135 pub p_sep_by_space: i8,
136 pub n_cs_precedes: i8,
137 pub n_sep_by_space: i8,
138 pub p_sign_posn: i8,
139 pub n_sign_posn: i8,
140 pub int_n_cs_precedes: i8,
141 pub int_n_sep_by_space: i8,
142 pub int_n_sign_posn: i8,
143 pub int_p_cs_precedes: i8,
144 pub int_p_sep_by_space: i8,
145 pub int_p_sign_posn: i8,
146 __reserved: Padding<[usize; __DEFAULT_RESERVED_SIZE__]>,
147 }
148
149 pub struct tm {
150 pub tm_sec: i32,
151 pub tm_min: i32,
152 pub tm_hour: i32,
153 pub tm_mday: i32,
154 pub tm_mon: i32,
155 pub tm_year: i32,
156 pub tm_wday: i32,
157 pub tm_yday: i32,
158 pub tm_isdst: i32,
159 pub tm_gmtoff: isize,
160 pub tm_zone: *const c_char,
161 __reserved: Padding<[usize; __DEFAULT_RESERVED_SIZE__]>,
162 }
163
164 pub struct addrinfo {
165 pub ai_flags: i32,
166 pub ai_family: i32,
167 pub ai_socktype: i32,
168 pub ai_protocol: i32,
169 pub ai_addrlen: socklen_t,
170 pub ai_addr: *mut sockaddr,
171 pub ai_canonname: *mut c_char,
172 pub ai_next: *mut addrinfo,
173 __reserved: Padding<[usize; __DEFAULT_RESERVED_SIZE__]>,
174 }
175
176 pub struct pthread_rwlock_t {
177 __val: [usize; __PTHREAD_RWLOCK_SIZE__],
178 }
179
180 pub struct statvfs {
181 pub f_bsize: usize,
182 pub f_frsize: usize,
183 pub f_blocks: fsblkcnt_t,
184 pub f_bfree: fsblkcnt_t,
185 pub f_bavail: fsblkcnt_t,
186 pub f_files: fsblkcnt_t,
187 pub f_ffree: fsblkcnt_t,
188 pub f_favail: fsblkcnt_t,
189 pub f_fsid: usize,
190 pub f_flag: usize,
191 pub f_namemax: usize,
192 __reserved: Padding<[usize; __DEFAULT_RESERVED_SIZE__]>,
193 }
194
195 pub struct dirent {
196 pub d_type: u8,
197 pub d_name: [c_char; __NAME_MAX__ + 1],
198 }
199
200 pub struct fd_set {
201 __val: [u32; __FDSET_SIZE__],
202 }
203
204 pub struct sigset_t {
205 __val: [u32; __SIGSET_SIZE__],
206 }
207
208 pub struct sigaction {
209 pub sa_handler: usize,
210 pub sa_mask: sigset_t,
211 pub sa_flags: i32,
212 pub sa_user: usize,
213 __reserved: Padding<[usize; __DEFAULT_RESERVED_SIZE__]>,
214 }
215
216 pub struct termios {
217 pub c_iflag: tcflag_t,
218 pub c_oflag: tcflag_t,
219 pub c_cflag: tcflag_t,
220 pub c_lflag: tcflag_t,
221 pub c_cc: [cc_t; 12],
222 pub c_speed: speed_t,
223 __reserved: Padding<[usize; __DEFAULT_RESERVED_SIZE__]>,
224 }
225
226 // netinet/in.h
227 pub struct in_addr {
228 pub s_addr: in_addr_t,
229 }
230
231 pub struct sockaddr_in {
232 pub sin_family: sa_family_t,
233 pub sin_port: crate::in_port_t,
234 pub sin_addr: crate::in_addr,
235 pub sin_zero: [u8; 8],
236 }
237
238 pub struct sockaddr_in6 {
239 pub sin6_family: sa_family_t,
240 pub sin6_port: crate::in_port_t,
241 pub sin6_flowinfo: u32,
242 pub sin6_addr: crate::in6_addr,
243 pub sin6_scope_id: u32,
244 }
245
246 pub struct sockaddr_un {
247 pub sun_family: sa_family_t,
248 pub sun_path: [c_char; 108],
249 }
250
251 pub struct sockaddr_storage {
252 pub ss_family: sa_family_t,
253 ss_data: [u32; __SOCKADDR_STORAGE_SIZE__],
254 }
255
256 pub struct ip_mreq {
257 pub imr_multiaddr: in_addr,
258 pub imr_interface: in_addr,
259 }
260
261 pub struct ip_mreqn {
262 pub imr_multiaddr: in_addr,
263 pub imr_address: in_addr,
264 pub imr_ifindex: c_uint,
265 }
266
267 pub struct ipv6_mreq {
268 pub ipv6mr_multiaddr: in6_addr,
269 pub ipv6mr_interface: u32,
270 }
271
272 pub struct ip_mreq_source {
273 pub imr_multiaddr: in_addr,
274 pub imr_interface: in_addr,
275 pub imr_sourceaddr: in_addr,
276 }
277}
278
279// Reserved two pointer size for reserved area for some structures.
280// This ensures that the size of these structures is large enough
281// if more fields are added in the NuttX side.
282//
283// These structures are that defined by POSIX but only necessary fields are included,
284// for example, struct passwd, https://pubs.opengroup.org/onlinepubs/009695399/basedefs/pwd.h.html,
285// POSIX only defines following fields in struct passwd:
286// char *pw_name User's login name.
287// char *pw_passwd Encrypted password.
288// uid_t pw_uid Numerical user ID.
289// gid_t pw_gid Numerical group ID.
290// char *pw_dir Initial working directory.
291// char *pw_shell Program to use as shell.
292// Other fields can be different depending on the implementation.
293
294const __DEFAULT_RESERVED_SIZE__: usize = 2;
295
296const __SOCKADDR_STORAGE_SIZE__: usize = 36;
297const __PTHREAD_ATTR_SIZE__: usize = 5;
298const __PTHREAD_MUTEX_SIZE__: usize = 9;
299const __PTHREAD_COND_SIZE__: usize = 7;
300const __PTHREAD_CONDATTR_SIZE__: usize = 5;
301const __PTHREAD_RWLOCK_SIZE__: usize = 17;
302const __SEM_SIZE__: usize = 6;
303const __NAME_MAX__: usize = 64;
304const __FDSET_SIZE__: usize = 10;
305const __SIGSET_SIZE__: usize = 8;
306
307pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
308 __val: [0; __PTHREAD_COND_SIZE__],
309};
310pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
311 __val: [0; __PTHREAD_MUTEX_SIZE__],
312};
313
314// dlfcn.h
315pub const RTLD_DEFAULT: *mut c_void = ptr::null_mut();
316
317// stdlib.h
318pub const EXIT_SUCCESS: i32 = 0;
319pub const EXIT_FAILURE: i32 = 1;
320
321// time.h
322pub const CLOCK_REALTIME: i32 = 0;
323pub const CLOCK_MONOTONIC: i32 = 1;
324
325// errno.h
326pub const EPERM: i32 = 1;
327pub const ENOENT: i32 = 2;
328pub const ESRCH: i32 = 3;
329pub const EINTR: i32 = 4;
330pub const EIO: i32 = 5;
331pub const ENXIO: i32 = 6;
332pub const E2BIG: i32 = 7;
333pub const ENOEXEC: i32 = 8;
334pub const EBADF: i32 = 9;
335pub const ECHILD: i32 = 10;
336pub const EAGAIN: i32 = 11;
337pub const ENOMEM: i32 = 12;
338pub const EACCES: i32 = 13;
339pub const EFAULT: i32 = 14;
340pub const ENOTBLK: i32 = 15;
341pub const EBUSY: i32 = 16;
342pub const EEXIST: i32 = 17;
343pub const EXDEV: i32 = 18;
344pub const ENODEV: i32 = 19;
345pub const ENOTDIR: i32 = 20;
346pub const EISDIR: i32 = 21;
347pub const EINVAL: i32 = 22;
348pub const ENFILE: i32 = 23;
349pub const EMFILE: i32 = 24;
350pub const ENOTTY: i32 = 25;
351pub const ETXTBSY: i32 = 26;
352pub const EFBIG: i32 = 27;
353pub const ENOSPC: i32 = 28;
354pub const ESPIPE: i32 = 29;
355pub const EROFS: i32 = 30;
356pub const EMLINK: i32 = 31;
357pub const EPIPE: i32 = 32;
358pub const EDOM: i32 = 33;
359pub const ERANGE: i32 = 34;
360pub const EDEADLK: i32 = 35;
361pub const ENAMETOOLONG: i32 = 36;
362pub const ENOLCK: i32 = 37;
363pub const ENOSYS: i32 = 38;
364pub const ENOTEMPTY: i32 = 39;
365pub const ELOOP: i32 = 40;
366pub const EWOULDBLOCK: i32 = EAGAIN;
367pub const ENOMSG: i32 = 42;
368pub const EIDRM: i32 = 43;
369pub const ECHRNG: i32 = 44;
370pub const EL2NSYNC: i32 = 45;
371pub const EL3HLT: i32 = 46;
372pub const EL3RST: i32 = 47;
373pub const ELNRNG: i32 = 48;
374pub const EUNATCH: i32 = 49;
375pub const ENOCSI: i32 = 50;
376pub const EL2HLT: i32 = 51;
377pub const EBADE: i32 = 52;
378pub const EBADR: i32 = 53;
379pub const EXFULL: i32 = 54;
380pub const ENOANO: i32 = 55;
381pub const EBADRQC: i32 = 56;
382pub const EBADSLT: i32 = 57;
383pub const EDEADLOCK: i32 = EDEADLK;
384pub const EBFONT: i32 = 59;
385pub const ENOSTR: i32 = 60;
386pub const ENODATA: i32 = 61;
387pub const ETIME: i32 = 62;
388pub const ENOSR: i32 = 63;
389pub const ENONET: i32 = 64;
390pub const ENOPKG: i32 = 65;
391pub const EREMOTE: i32 = 66;
392pub const ENOLINK: i32 = 67;
393pub const EADV: i32 = 68;
394pub const ESRMNT: i32 = 69;
395pub const ECOMM: i32 = 70;
396pub const EPROTO: i32 = 71;
397pub const EMULTIHOP: i32 = 72;
398pub const EDOTDOT: i32 = 73;
399pub const EBADMSG: i32 = 74;
400pub const EOVERFLOW: i32 = 75;
401pub const ENOTUNIQ: i32 = 76;
402pub const EBADFD: i32 = 77;
403pub const EREMCHG: i32 = 78;
404pub const ELIBACC: i32 = 79;
405pub const ELIBBAD: i32 = 80;
406pub const ELIBSCN: i32 = 81;
407pub const ELIBMAX: i32 = 82;
408pub const ELIBEXEC: i32 = 83;
409pub const EILSEQ: i32 = 84;
410pub const ERESTART: i32 = 85;
411pub const ESTRPIPE: i32 = 86;
412pub const EUSERS: i32 = 87;
413pub const ENOTSOCK: i32 = 88;
414pub const EDESTADDRREQ: i32 = 89;
415pub const EMSGSIZE: i32 = 90;
416pub const EPROTOTYPE: i32 = 91;
417pub const ENOPROTOOPT: i32 = 92;
418pub const EPROTONOSUPPORT: i32 = 93;
419pub const ESOCKTNOSUPPORT: i32 = 94;
420pub const EOPNOTSUPP: i32 = 95;
421pub const EPFNOSUPPORT: i32 = 96;
422pub const EAFNOSUPPORT: i32 = 97;
423pub const EADDRINUSE: i32 = 98;
424pub const EADDRNOTAVAIL: i32 = 99;
425pub const ENETDOWN: i32 = 100;
426pub const ENETUNREACH: i32 = 101;
427pub const ENETRESET: i32 = 102;
428pub const ECONNABORTED: i32 = 103;
429pub const ECONNRESET: i32 = 104;
430pub const ENOBUFS: i32 = 105;
431pub const EISCONN: i32 = 106;
432pub const ENOTCONN: i32 = 107;
433pub const ESHUTDOWN: i32 = 108;
434pub const ETOOMANYREFS: i32 = 109;
435pub const ETIMEDOUT: i32 = 110;
436pub const ECONNREFUSED: i32 = 111;
437pub const EHOSTDOWN: i32 = 112;
438pub const EHOSTUNREACH: i32 = 113;
439pub const EALREADY: i32 = 114;
440pub const EINPROGRESS: i32 = 115;
441pub const ESTALE: i32 = 116;
442pub const EUCLEAN: i32 = 117;
443pub const ENOTNAM: i32 = 118;
444pub const ENAVAIL: i32 = 119;
445pub const EISNAM: i32 = 120;
446pub const EREMOTEIO: i32 = 121;
447pub const EDQUOT: i32 = 122;
448pub const ENOMEDIUM: i32 = 123;
449pub const EMEDIUMTYPE: i32 = 124;
450pub const ECANCELED: i32 = 125;
451pub const ENOKEY: i32 = 126;
452pub const EKEYEXPIRED: i32 = 127;
453pub const EKEYREVOKED: i32 = 128;
454pub const EKEYREJECTED: i32 = 129;
455pub const EOWNERDEAD: i32 = 130;
456pub const ENOTRECOVERABLE: i32 = 131;
457pub const ERFKILL: i32 = 132;
458pub const EHWPOISON: i32 = 133;
459pub const ELBIN: i32 = 134;
460pub const EFTYPE: i32 = 135;
461pub const ENMFILE: i32 = 136;
462pub const EPROCLIM: i32 = 137;
463pub const ENOTSUP: i32 = 138;
464pub const ENOSHARE: i32 = 139;
465pub const ECASECLASH: i32 = 140;
466
467// fcntl.h
468// fcntl() commands
469pub const FIOCLEX: i32 = 0x30b;
470pub const F_DUPFD_CLOEXEC: i32 = 0x12;
471pub const F_GETFD: i32 = 0x1;
472pub const F_GETFL: i32 = 0x2;
473pub const F_SETFD: i32 = 8;
474pub const F_SETFL: i32 = 9;
475// open flag settings for open() (and related APIs)
476pub const O_RDONLY: i32 = 0x1;
477pub const O_WRONLY: i32 = 0x2;
478pub const O_RDWR: i32 = 0x3;
479pub const O_CREAT: i32 = 0x4;
480pub const O_EXCL: i32 = 0x8;
481pub const O_NOCTTY: i32 = 0x0;
482pub const O_TRUNC: i32 = 0x20;
483pub const O_APPEND: i32 = 0x10;
484pub const O_NONBLOCK: i32 = 0x40;
485pub const O_DSYNC: i32 = 0x80;
486pub const O_DIRECT: i32 = 0x200;
487pub const O_LARGEFILE: i32 = 0x2000;
488pub const O_DIRECTORY: i32 = 0x800;
489pub const O_NOFOLLOW: i32 = 0x1000;
490pub const O_NOATIME: i32 = 0x40000;
491pub const O_CLOEXEC: i32 = 0x400;
492pub const O_ACCMODE: i32 = 0x0003;
493pub const AT_FDCWD: i32 = -100;
494pub const AT_REMOVEDIR: i32 = 0x200;
495
496// sys/types.h
497pub const SEEK_SET: i32 = 0;
498pub const SEEK_CUR: i32 = 1;
499pub const SEEK_END: i32 = 2;
500
501// sys/stat.h
502pub const S_IFDIR: u32 = 0x4000;
503pub const S_IFLNK: u32 = 0xA000;
504pub const S_IFREG: u32 = 0x8000;
505pub const S_IFMT: u32 = 0xF000;
506pub const S_IFIFO: u32 = 0x1000;
507pub const S_IFSOCK: u32 = 0xc000;
508pub const S_IFBLK: u32 = 0x6000;
509pub const S_IFCHR: u32 = 0x2000;
510pub const S_IRUSR: u32 = 0x100;
511pub const S_IWUSR: u32 = 0x80;
512pub const S_IXUSR: u32 = 0x40;
513pub const S_IRGRP: u32 = 0x20;
514pub const S_IWGRP: u32 = 0x10;
515pub const S_IXGRP: u32 = 0x8;
516pub const S_IROTH: u32 = 0x004;
517pub const S_IWOTH: u32 = 0x002;
518pub const S_IXOTH: u32 = 0x001;
519
520// sys/poll.h
521pub const POLLIN: i16 = 0x01;
522pub const POLLRDNORM: i16 = 0x01;
523pub const POLLRDBAND: i16 = 0x01;
524pub const POLLPRI: i16 = 0x02;
525pub const POLLOUT: i16 = 0x04;
526pub const POLLWRNORM: i16 = 0x04;
527pub const POLLWRBAND: i16 = 0x04;
528pub const POLLHUP: i16 = 0x10;
529pub const POLLRDHUP: i16 = 0x10;
530pub const POLLERR: i16 = 0x08;
531pub const POLLNVAL: i16 = 0x20;
532
533// sys/socket.h
534// Supported Protocol Families
535pub const AF_UNSPEC: i32 = 0;
536pub const AF_UNIX: i32 = 1;
537pub const AF_INET: i32 = 2;
538pub const AF_INET6: i32 = 10;
539// The socket created by socket() has the indicated type, which specifies
540// the communication semantics.
541pub const SOCK_STREAM: i32 = 1;
542pub const SOCK_DGRAM: i32 = 2;
543pub const SOCK_RAW: i32 = 3;
544pub const SOCK_RDM: i32 = 4;
545pub const SOCK_SEQPACKET: i32 = 5;
546pub const SOCK_CLOEXEC: i32 = 0o02000000;
547pub const SOCK_NONBLOCK: i32 = 0o00004000;
548// Bits in the FLAGS argument to `send', `recv', et al. These are the bits
549// recognized by Linux, not all are supported by NuttX.
550pub const MSG_OOB: i32 = 0x000001;
551pub const MSG_PEEK: i32 = 0x000002;
552pub const MSG_TRUNC: i32 = 0x000020;
553pub const MSG_EOR: i32 = 0x000080;
554// Protocol levels supported by get/setsockopt():
555pub const SOL_SOCKET: i32 = 1;
556// Socket-level options
557pub const SO_BROADCAST: i32 = 1;
558pub const SO_ERROR: i32 = 4;
559pub const SO_KEEPALIVE: i32 = 5;
560pub const SO_LINGER: i32 = 6;
561pub const SO_OOBINLINE: i32 = 7;
562pub const SO_RCVBUF: i32 = 8;
563pub const SO_RCVTIMEO: i32 = 10;
564pub const SO_REUSEADDR: i32 = 11;
565pub const SO_SNDBUF: i32 = 12;
566pub const SO_SNDTIMEO: i32 = 14;
567pub const SO_TYPE: i32 = 15;
568// Protocol-level socket options may begin with this value
569pub const __SO_PROTOCOL: i32 = 16;
570// Values for the 'how' argument of shutdown()
571pub const SHUT_RD: i32 = 1;
572pub const SHUT_WR: i32 = 2;
573pub const SHUT_RDWR: i32 = 3;
574// The maximum backlog queue length
575pub const SOMAXCONN: i32 = 8;
576
577// netinet/tcp.h
578pub const TCP_NODELAY: i32 = __SO_PROTOCOL + 0;
579pub const TCP_KEEPIDLE: i32 = __SO_PROTOCOL + 1;
580pub const TCP_KEEPINTVL: i32 = __SO_PROTOCOL + 2;
581pub const TCP_KEEPCNT: i32 = __SO_PROTOCOL + 3;
582pub const TCP_MAXSEG: i32 = __SO_PROTOCOL + 4;
583
584// nuttx/fs/ioctl.h
585pub const FIONBIO: i32 = 0x30a;
586
587// unistd.h
588pub const _SC_PAGESIZE: i32 = 0x36;
589pub const _SC_THREAD_STACK_MIN: i32 = 0x58;
590pub const _SC_GETPW_R_SIZE_MAX: i32 = 0x25;
591pub const _SC_HOST_NAME_MAX: i32 = 0x26;
592
593// sys/eventfd.h
594pub const EFD_NONBLOCK: i32 = O_NONBLOCK;
595pub const EFD_CLOEXEC: i32 = O_CLOEXEC;
596
597// signal.h
598pub const SIGHUP: c_int = 1;
599pub const SIGINT: c_int = 2;
600pub const SIGQUIT: c_int = 3;
601pub const SIGILL: c_int = 4;
602pub const SIGTRAP: c_int = 5;
603pub const SIGABRT: c_int = 6;
604pub const SIGBUS: c_int = 7;
605pub const SIGFPE: c_int = 8;
606pub const SIGKILL: c_int = 9;
607pub const SIGUSR1: c_int = 10;
608pub const SIGSEGV: c_int = 11;
609pub const SIGUSR2: c_int = 12;
610pub const SIGPIPE: c_int = 13;
611pub const SIGALRM: c_int = 14;
612pub const SIGTERM: c_int = 15;
613pub const SIGSTKFLT: c_int = 16;
614pub const SIGCHLD: c_int = 17;
615pub const SIGCONT: c_int = 18;
616pub const SIGSTOP: c_int = 19;
617pub const SIGTSTP: c_int = 20;
618pub const SIGTTIN: c_int = 21;
619pub const SIGTTOU: c_int = 22;
620pub const SIGURG: c_int = 23;
621pub const SIGXCPU: c_int = 24;
622pub const SIGXFSZ: c_int = 25;
623pub const SIGVTALRM: c_int = 26;
624pub const SIGPROF: c_int = 27;
625pub const SIGWINCH: c_int = 28;
626pub const SIGIO: c_int = 29;
627pub const SIGPOLL: c_int = SIGIO;
628pub const SIGPWR: c_int = 30;
629pub const SIGSYS: c_int = 31;
630
631// pthread.h
632pub const PTHREAD_MUTEX_NORMAL: i32 = 0;
633
634// netinet/in.h
635// SOL_IP protocol-level socket options.
636pub const IP_MULTICAST_IF: i32 = __SO_PROTOCOL + 1;
637pub const IP_MULTICAST_TTL: i32 = __SO_PROTOCOL + 2;
638pub const IP_MULTICAST_LOOP: i32 = __SO_PROTOCOL + 3;
639pub const IP_ADD_MEMBERSHIP: i32 = __SO_PROTOCOL + 4;
640pub const IP_DROP_MEMBERSHIP: i32 = __SO_PROTOCOL + 5;
641pub const IP_ADD_SOURCE_MEMBERSHIP: i32 = __SO_PROTOCOL + 8;
642pub const IP_DROP_SOURCE_MEMBERSHIP: i32 = __SO_PROTOCOL + 9;
643pub const IP_TOS: i32 = __SO_PROTOCOL + 13;
644pub const IP_TTL: i32 = __SO_PROTOCOL + 14;
645// SOL_IPV6 protocol-level socket options.
646pub const IPV6_JOIN_GROUP: i32 = __SO_PROTOCOL + 1;
647pub const IPV6_LEAVE_GROUP: i32 = __SO_PROTOCOL + 2;
648pub const IPV6_MULTICAST_HOPS: i32 = __SO_PROTOCOL + 3;
649pub const IPV6_MULTICAST_IF: i32 = __SO_PROTOCOL + 4;
650pub const IPV6_MULTICAST_LOOP: i32 = __SO_PROTOCOL + 5;
651pub const IPV6_UNICAST_HOPS: i32 = __SO_PROTOCOL + 6;
652pub const IPV6_V6ONLY: i32 = __SO_PROTOCOL + 7;
653pub const IPV6_RECVHOPLIMIT: i32 = __SO_PROTOCOL + 11;
654
655extern "C" {
656 pub fn __errno() -> *mut c_int;
657 pub fn bind(sockfd: i32, addr: *const sockaddr, addrlen: socklen_t) -> i32;
658 pub fn ioctl(fd: i32, request: i32, ...) -> i32;
659 pub fn dirfd(dirp: *mut DIR) -> i32;
660 pub fn recvfrom(
661 sockfd: i32,
662 buf: *mut c_void,
663 len: usize,
664 flags: i32,
665 src_addr: *mut sockaddr,
666 addrlen: *mut socklen_t,
667 ) -> i32;
668
669 pub fn pthread_create(
670 thread: *mut pthread_t,
671 attr: *const pthread_attr_t,
672 start_routine: extern "C" fn(*mut c_void) -> *mut c_void,
673 arg: *mut c_void,
674 ) -> i32;
675
676 pub fn clock_gettime(clockid: clockid_t, tp: *mut timespec) -> i32;
677 pub fn futimens(fd: i32, times: *const timespec) -> i32;
678 pub fn pthread_condattr_setclock(attr: *mut pthread_condattr_t, clock_id: clockid_t) -> i32;
679 pub fn pthread_setname_np(thread: pthread_t, name: *const c_char) -> i32;
680 pub fn pthread_getname_np(thread: pthread_t, name: *mut c_char, len: usize) -> i32;
681 pub fn getrandom(buf: *mut c_void, buflen: usize, flags: u32) -> isize;
682 pub fn arc4random() -> u32;
683 pub fn arc4random_buf(bytes: *mut c_void, nbytes: usize);
684 // string.h
685 pub fn strerror_r(errnum: c_int, buf: *mut c_char, buflen: size_t) -> c_int;
686 // sys/socket.h
687 pub fn accept4(
688 sockfd: c_int,
689 addr: *mut sockaddr,
690 addrlen: *mut socklen_t,
691 flags: c_int,
692 ) -> c_int;
693 pub fn recvmsg(sockfd: c_int, msg: *mut msghdr, flags: c_int) -> ssize_t;
694 pub fn sendmsg(sockfd: c_int, msg: *const msghdr, flags: c_int) -> ssize_t;
695 // sys/eventfd.h
696 pub fn eventfd(count: c_uint, flags: c_int) -> c_int;
697 // unistd.h
698 pub fn pipe2(fds: *mut c_int, flags: c_int) -> c_int;
699}