]> git.proxmox.com Git - rustc.git/blame - vendor/libc/src/unix/newlib/mod.rs
New upstream version 1.56.0~beta.4+dfsg1
[rustc.git] / vendor / libc / src / unix / newlib / mod.rs
CommitLineData
041b39d2
XL
1pub type blkcnt_t = i32;
2pub type blksize_t = i32;
041b39d2
XL
3pub type clockid_t = ::c_ulong;
4pub type dev_t = u32;
5pub type fsblkcnt_t = u64;
6pub type fsfilcnt_t = u32;
7pub type id_t = u32;
8pub type ino_t = u32;
9pub type key_t = ::c_int;
10pub type loff_t = ::c_longlong;
11pub type mode_t = ::c_uint;
12pub type nfds_t = u32;
13pub type nlink_t = ::c_ushort;
14pub type off_t = i64;
15pub type pthread_t = ::c_ulong;
16pub type pthread_key_t = ::c_uint;
17pub type rlim_t = u32;
18pub type sa_family_t = u8;
19pub type socklen_t = u32;
20pub type speed_t = u32;
21pub type suseconds_t = i32;
22pub type tcflag_t = ::c_uint;
23pub type time_t = i32;
24pub type useconds_t = u32;
25
26s! {
f035d41b
XL
27 // The order of the `ai_addr` field in this struct is crucial
28 // for converting between the Rust and C types.
041b39d2
XL
29 pub struct addrinfo {
30 pub ai_flags: ::c_int,
31 pub ai_family: ::c_int,
32 pub ai_socktype: ::c_int,
33 pub ai_protocol: ::c_int,
34 pub ai_addrlen: socklen_t,
f035d41b 35
94222f64 36 #[cfg(target_os = "espidf")]
f035d41b
XL
37 pub ai_addr: *mut sockaddr,
38
041b39d2 39 pub ai_canonname: *mut ::c_char,
f035d41b 40
94222f64
XL
41 #[cfg(not(any(
42 target_os = "espidf",
43 all(libc_cfg_target_vendor, target_arch = "powerpc", target_vendor = "nintendo"))))]
041b39d2 44 pub ai_addr: *mut sockaddr,
f035d41b 45
041b39d2
XL
46 pub ai_next: *mut addrinfo,
47 }
48
49 pub struct ip_mreq {
50 pub imr_multiaddr: in_addr,
51 pub imr_interface: in_addr,
52 }
53
54 pub struct linger {
55 pub l_onoff: ::c_int,
56 pub l_linger: ::c_int,
57 }
58
59 pub struct in_addr {
60 pub s_addr: ::in_addr_t,
61 }
62
63 pub struct hostent {
64 pub h_name: *mut ::c_char,
65 pub h_aliases: *mut *mut ::c_char,
66 pub h_addrtype: ::c_int,
67 pub h_length: ::c_int,
68 pub h_addr_list: *mut *mut ::c_char,
69 pub h_addr: *mut ::c_char,
70 }
71
72 pub struct pollfd {
73 pub fd: ::c_int,
74 pub events: ::c_int,
75 pub revents: ::c_int,
76 }
77
78 pub struct lconv {
79 pub decimal_point: *mut ::c_char,
80 pub thousands_sep: *mut ::c_char,
81 pub grouping: *mut ::c_char,
82 pub int_curr_symbol: *mut ::c_char,
83 pub currency_symbol: *mut ::c_char,
84 pub mon_decimal_point: *mut ::c_char,
85 pub mon_thousands_sep: *mut ::c_char,
86 pub mon_grouping: *mut ::c_char,
87 pub positive_sign: *mut ::c_char,
88 pub negative_sign: *mut ::c_char,
89 pub int_frac_digits: ::c_char,
90 pub frac_digits: ::c_char,
91 pub p_cs_precedes: ::c_char,
92 pub p_sep_by_space: ::c_char,
93 pub n_cs_precedes: ::c_char,
94 pub n_sep_by_space: ::c_char,
95 pub p_sign_posn: ::c_char,
96 pub n_sign_posn: ::c_char,
97 pub int_n_cs_precedes: ::c_char,
98 pub int_n_sep_by_space: ::c_char,
99 pub int_n_sign_posn: ::c_char,
100 pub int_p_cs_precedes: ::c_char,
101 pub int_p_sep_by_space: ::c_char,
102 pub int_p_sign_posn: ::c_char,
103 }
104
105 pub struct tm {
106 pub tm_sec: ::c_int,
107 pub tm_min: ::c_int,
108 pub tm_hour: ::c_int,
109 pub tm_mday: ::c_int,
110 pub tm_mon: ::c_int,
111 pub tm_year: ::c_int,
112 pub tm_wday: ::c_int,
113 pub tm_yday: ::c_int,
114 pub tm_isdst: ::c_int,
115 }
116
117 pub struct stat {
118 pub st_dev: ::dev_t,
119 pub st_ino: ::ino_t,
120 pub st_mode: ::mode_t,
121 pub st_nlink: ::nlink_t,
122 pub st_uid: ::uid_t,
123 pub st_gid: ::gid_t,
124 pub st_rdev: dev_t,
125 pub st_size: off_t,
126 pub st_atime: time_t,
127 pub st_spare1: ::c_long,
128 pub st_mtime: time_t,
129 pub st_spare2: ::c_long,
130 pub st_ctime: time_t,
131 pub st_spare3: ::c_long,
132 pub st_blksize: blksize_t,
133 pub st_blocks: blkcnt_t,
134 pub st_spare4: [::c_long; 2usize],
135 }
136
137 pub struct statvfs {
138 pub f_bsize: ::c_ulong,
139 pub f_frsize: ::c_ulong,
140 pub f_blocks: fsblkcnt_t,
141 pub f_bfree: fsblkcnt_t,
142 pub f_bavail: fsblkcnt_t,
143 pub f_files: fsfilcnt_t,
144 pub f_ffree: fsfilcnt_t,
145 pub f_favail: fsfilcnt_t,
146 pub f_fsid: ::c_ulong,
147 pub f_flag: ::c_ulong,
148 pub f_namemax: ::c_ulong,
149 }
150
151 pub struct sigset_t {
152 __val: [::c_ulong; 16],
153 }
154
155 pub struct sigaction {
156 pub sa_handler: extern fn(arg1: ::c_int),
157 pub sa_mask: sigset_t,
158 pub sa_flags: ::c_int,
159 }
160
161 pub struct dirent {
162 pub d_ino: ino_t,
163 pub d_type: ::c_uchar,
164 pub d_name: [::c_char; 256usize],
165 }
166
167 pub struct stack_t {
168 pub ss_sp: *mut ::c_void,
169 pub ss_flags: ::c_int,
170 pub ss_size: usize,
171 }
172
173 pub struct fd_set { // Unverified
174 fds_bits: [::c_ulong; FD_SETSIZE / ULONG_SIZE],
175 }
176
177 pub struct passwd { // Unverified
178 pub pw_name: *mut ::c_char,
179 pub pw_passwd: *mut ::c_char,
180 pub pw_uid: ::uid_t,
181 pub pw_gid: ::gid_t,
182 pub pw_gecos: *mut ::c_char,
183 pub pw_dir: *mut ::c_char,
184 pub pw_shell: *mut ::c_char,
185 }
186
187 pub struct termios { // Unverified
188 pub c_iflag: ::tcflag_t,
189 pub c_oflag: ::tcflag_t,
190 pub c_cflag: ::tcflag_t,
191 pub c_lflag: ::tcflag_t,
192 pub c_line: ::cc_t,
193 pub c_cc: [::cc_t; ::NCCS],
194 }
195
196 pub struct sem_t { // Unverified
197 __size: [::c_char; 16],
198 }
199
200 pub struct Dl_info { // Unverified
201 pub dli_fname: *const ::c_char,
202 pub dli_fbase: *mut ::c_void,
203 pub dli_sname: *const ::c_char,
204 pub dli_saddr: *mut ::c_void,
205 }
206
207 pub struct utsname { // Unverified
208 pub sysname: [::c_char; 65],
209 pub nodename: [::c_char; 65],
210 pub release: [::c_char; 65],
211 pub version: [::c_char; 65],
212 pub machine: [::c_char; 65],
213 pub domainname: [::c_char; 65]
214 }
215
216 pub struct cpu_set_t { // Unverified
217 bits: [u32; 32],
218 }
219
220 pub struct pthread_attr_t { // Unverified
221 __size: [u64; 7]
222 }
223
041b39d2
XL
224 pub struct pthread_rwlockattr_t { // Unverified
225 __lockkind: ::c_int,
226 __pshared: ::c_int,
227 }
041b39d2
XL
228}
229
230// unverified constants
b7449926
XL
231align_const! {
232 pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
94222f64 233 size: [__PTHREAD_INITIALIZER_BYTE; __SIZEOF_PTHREAD_MUTEX_T],
b7449926
XL
234 };
235 pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
94222f64 236 size: [__PTHREAD_INITIALIZER_BYTE; __SIZEOF_PTHREAD_COND_T],
b7449926
XL
237 };
238 pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
94222f64 239 size: [__PTHREAD_INITIALIZER_BYTE; __SIZEOF_PTHREAD_RWLOCK_T],
b7449926
XL
240 };
241}
041b39d2 242pub const NCCS: usize = 32;
94222f64
XL
243cfg_if! {
244 if #[cfg(target_os = "espidf")] {
245 const __PTHREAD_INITIALIZER_BYTE: u8 = 0xff;
246 pub const __SIZEOF_PTHREAD_ATTR_T: usize = 32;
247 pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 4;
248 pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 12;
249 pub const __SIZEOF_PTHREAD_COND_T: usize = 4;
250 pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 8;
251 pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 4;
252 pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 12;
253 } else {
254 const __PTHREAD_INITIALIZER_BYTE: u8 = 0;
255 pub const __SIZEOF_PTHREAD_ATTR_T: usize = 56;
256 pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40;
257 pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
258 pub const __SIZEOF_PTHREAD_COND_T: usize = 48;
259 pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
260 pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;
261 pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8;
262 }
263}
041b39d2
XL
264pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32;
265pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4;
266pub const __PTHREAD_MUTEX_HAVE_PREV: usize = 1;
267pub const __PTHREAD_RWLOCK_INT_FLAGS_SHARED: usize = 1;
268pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0;
269pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1;
270pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2;
271pub const FD_SETSIZE: usize = 1024;
272// intentionally not public, only used for fd_set
273const ULONG_SIZE: usize = 32;
274
275// Other constants
276pub const EPERM: ::c_int = 1;
277pub const ENOENT: ::c_int = 2;
278pub const ESRCH: ::c_int = 3;
279pub const EINTR: ::c_int = 4;
280pub const EIO: ::c_int = 5;
281pub const ENXIO: ::c_int = 6;
282pub const E2BIG: ::c_int = 7;
283pub const ENOEXEC: ::c_int = 8;
284pub const EBADF: ::c_int = 9;
285pub const ECHILD: ::c_int = 10;
286pub const EAGAIN: ::c_int = 11;
287pub const ENOMEM: ::c_int = 12;
288pub const EACCES: ::c_int = 13;
289pub const EFAULT: ::c_int = 14;
290pub const EBUSY: ::c_int = 16;
291pub const EEXIST: ::c_int = 17;
292pub const EXDEV: ::c_int = 18;
293pub const ENODEV: ::c_int = 19;
294pub const ENOTDIR: ::c_int = 20;
295pub const EISDIR: ::c_int = 21;
296pub const EINVAL: ::c_int = 22;
297pub const ENFILE: ::c_int = 23;
298pub const EMFILE: ::c_int = 24;
299pub const ENOTTY: ::c_int = 25;
300pub const ETXTBSY: ::c_int = 26;
301pub const EFBIG: ::c_int = 27;
302pub const ENOSPC: ::c_int = 28;
303pub const ESPIPE: ::c_int = 29;
304pub const EROFS: ::c_int = 30;
305pub const EMLINK: ::c_int = 31;
306pub const EPIPE: ::c_int = 32;
307pub const EDOM: ::c_int = 33;
308pub const ERANGE: ::c_int = 34;
309pub const ENOMSG: ::c_int = 35;
310pub const EIDRM: ::c_int = 36;
311pub const EDEADLK: ::c_int = 45;
312pub const ENOLCK: ::c_int = 46;
313pub const ENOSTR: ::c_int = 60;
314pub const ENODATA: ::c_int = 61;
315pub const ETIME: ::c_int = 62;
316pub const ENOSR: ::c_int = 63;
317pub const ENOLINK: ::c_int = 67;
318pub const EPROTO: ::c_int = 71;
319pub const EMULTIHOP: ::c_int = 74;
320pub const EBADMSG: ::c_int = 77;
321pub const EFTYPE: ::c_int = 79;
322pub const ENOSYS: ::c_int = 88;
323pub const ENOTEMPTY: ::c_int = 90;
324pub const ENAMETOOLONG: ::c_int = 91;
325pub const ELOOP: ::c_int = 92;
326pub const EOPNOTSUPP: ::c_int = 95;
327pub const EPFNOSUPPORT: ::c_int = 96;
328pub const ECONNRESET: ::c_int = 104;
329pub const ENOBUFS: ::c_int = 105;
330pub const EAFNOSUPPORT: ::c_int = 106;
331pub const EPROTOTYPE: ::c_int = 107;
332pub const ENOTSOCK: ::c_int = 108;
333pub const ENOPROTOOPT: ::c_int = 109;
334pub const ECONNREFUSED: ::c_int = 111;
335pub const EADDRINUSE: ::c_int = 112;
336pub const ECONNABORTED: ::c_int = 113;
337pub const ENETUNREACH: ::c_int = 114;
338pub const ENETDOWN: ::c_int = 115;
339pub const ETIMEDOUT: ::c_int = 116;
340pub const EHOSTDOWN: ::c_int = 117;
341pub const EHOSTUNREACH: ::c_int = 118;
342pub const EINPROGRESS: ::c_int = 119;
343pub const EALREADY: ::c_int = 120;
344pub const EDESTADDRREQ: ::c_int = 121;
345pub const EMSGSIZE: ::c_int = 122;
346pub const EPROTONOSUPPORT: ::c_int = 123;
347pub const EADDRNOTAVAIL: ::c_int = 125;
348pub const ENETRESET: ::c_int = 126;
349pub const EISCONN: ::c_int = 127;
350pub const ENOTCONN: ::c_int = 128;
351pub const ETOOMANYREFS: ::c_int = 129;
352pub const EDQUOT: ::c_int = 132;
353pub const ESTALE: ::c_int = 133;
354pub const ENOTSUP: ::c_int = 134;
355pub const EILSEQ: ::c_int = 138;
356pub const EOVERFLOW: ::c_int = 139;
357pub const ECANCELED: ::c_int = 140;
358pub const ENOTRECOVERABLE: ::c_int = 141;
359pub const EOWNERDEAD: ::c_int = 142;
360pub const EWOULDBLOCK: ::c_int = 11;
361
362pub const F_DUPFD: ::c_int = 0;
363pub const F_GETFD: ::c_int = 1;
364pub const F_SETFD: ::c_int = 2;
365pub const F_GETFL: ::c_int = 3;
366pub const F_SETFL: ::c_int = 4;
367pub const F_GETOWN: ::c_int = 5;
368pub const F_SETOWN: ::c_int = 6;
369pub const F_GETLK: ::c_int = 7;
370pub const F_SETLK: ::c_int = 8;
371pub const F_SETLKW: ::c_int = 9;
372pub const F_RGETLK: ::c_int = 10;
373pub const F_RSETLK: ::c_int = 11;
374pub const F_CNVT: ::c_int = 12;
375pub const F_RSETLKW: ::c_int = 13;
376pub const F_DUPFD_CLOEXEC: ::c_int = 14;
377
378pub const O_RDONLY: ::c_int = 0;
379pub const O_WRONLY: ::c_int = 1;
380pub const O_RDWR: ::c_int = 2;
381pub const O_APPEND: ::c_int = 8;
382pub const O_CREAT: ::c_int = 512;
383pub const O_TRUNC: ::c_int = 1024;
384pub const O_EXCL: ::c_int = 2048;
385pub const O_SYNC: ::c_int = 8192;
386pub const O_NONBLOCK: ::c_int = 16384;
387
388pub const O_ACCMODE: ::c_int = 3;
389pub const O_CLOEXEC: ::c_int = 0x80000;
390
abe05a73
XL
391pub const RTLD_LAZY: ::c_int = 0x1;
392
041b39d2
XL
393pub const STDIN_FILENO: ::c_int = 0;
394pub const STDOUT_FILENO: ::c_int = 1;
395pub const STDERR_FILENO: ::c_int = 2;
396
397pub const SEEK_SET: ::c_int = 0;
398pub const SEEK_CUR: ::c_int = 1;
399pub const SEEK_END: ::c_int = 2;
400
416331ca
XL
401pub const FIOCLEX: ::c_ulong = 0x20006601;
402pub const FIONCLEX: ::c_ulong = 0x20006602;
041b39d2
XL
403
404pub const S_BLKSIZE: ::mode_t = 1024;
405pub const S_IREAD: ::mode_t = 256;
406pub const S_IWRITE: ::mode_t = 128;
407pub const S_IEXEC: ::mode_t = 64;
408pub const S_ENFMT: ::mode_t = 1024;
409pub const S_IFMT: ::mode_t = 61440;
410pub const S_IFDIR: ::mode_t = 16384;
411pub const S_IFCHR: ::mode_t = 8192;
412pub const S_IFBLK: ::mode_t = 24576;
413pub const S_IFREG: ::mode_t = 32768;
414pub const S_IFLNK: ::mode_t = 40960;
415pub const S_IFSOCK: ::mode_t = 49152;
416pub const S_IFIFO: ::mode_t = 4096;
417pub const S_IRUSR: ::mode_t = 256;
418pub const S_IWUSR: ::mode_t = 128;
419pub const S_IXUSR: ::mode_t = 64;
420pub const S_IRGRP: ::mode_t = 32;
421pub const S_IWGRP: ::mode_t = 16;
422pub const S_IXGRP: ::mode_t = 8;
423pub const S_IROTH: ::mode_t = 4;
424pub const S_IWOTH: ::mode_t = 2;
425pub const S_IXOTH: ::mode_t = 1;
426
041b39d2
XL
427pub const SOL_TCP: ::c_int = 6;
428
429pub const PF_UNSPEC: ::c_int = 0;
430pub const PF_INET: ::c_int = 2;
431pub const PF_INET6: ::c_int = 23;
432
433pub const AF_UNSPEC: ::c_int = 0;
434pub const AF_INET: ::c_int = 2;
041b39d2 435
ba9703b0
XL
436pub const CLOCK_REALTIME: ::clockid_t = 1;
437pub const CLOCK_MONOTONIC: ::clockid_t = 4;
438pub const CLOCK_BOOTTIME: ::clockid_t = 4;
439
041b39d2
XL
440pub const SOCK_STREAM: ::c_int = 1;
441pub const SOCK_DGRAM: ::c_int = 2;
442
041b39d2
XL
443pub const SHUT_RD: ::c_int = 0;
444pub const SHUT_WR: ::c_int = 1;
445pub const SHUT_RDWR: ::c_int = 2;
446
416331ca
XL
447pub const SO_BINTIME: ::c_int = 0x2000;
448pub const SO_NO_OFFLOAD: ::c_int = 0x4000;
449pub const SO_NO_DDP: ::c_int = 0x8000;
450pub const SO_REUSEPORT_LB: ::c_int = 0x10000;
451pub const SO_LABEL: ::c_int = 0x1009;
452pub const SO_PEERLABEL: ::c_int = 0x1010;
453pub const SO_LISTENQLIMIT: ::c_int = 0x1011;
454pub const SO_LISTENQLEN: ::c_int = 0x1012;
455pub const SO_LISTENINCQLEN: ::c_int = 0x1013;
456pub const SO_SETFIB: ::c_int = 0x1014;
457pub const SO_USER_COOKIE: ::c_int = 0x1015;
458pub const SO_PROTOCOL: ::c_int = 0x1016;
459pub const SO_PROTOTYPE: ::c_int = SO_PROTOCOL;
460pub const SO_VENDOR: ::c_int = 0x80000000;
461pub const SO_DEBUG: ::c_int = 0x01;
462pub const SO_ACCEPTCONN: ::c_int = 0x0002;
463pub const SO_REUSEADDR: ::c_int = 0x0004;
464pub const SO_KEEPALIVE: ::c_int = 0x0008;
465pub const SO_DONTROUTE: ::c_int = 0x0010;
466pub const SO_BROADCAST: ::c_int = 0x0020;
467pub const SO_USELOOPBACK: ::c_int = 0x0040;
468pub const SO_LINGER: ::c_int = 0x0080;
469pub const SO_OOBINLINE: ::c_int = 0x0100;
470pub const SO_REUSEPORT: ::c_int = 0x0200;
471pub const SO_TIMESTAMP: ::c_int = 0x0400;
472pub const SO_NOSIGPIPE: ::c_int = 0x0800;
473pub const SO_ACCEPTFILTER: ::c_int = 0x1000;
474pub const SO_SNDBUF: ::c_int = 0x1001;
475pub const SO_RCVBUF: ::c_int = 0x1002;
476pub const SO_SNDLOWAT: ::c_int = 0x1003;
477pub const SO_RCVLOWAT: ::c_int = 0x1004;
478pub const SO_SNDTIMEO: ::c_int = 0x1005;
479pub const SO_RCVTIMEO: ::c_int = 0x1006;
480pub const SO_ERROR: ::c_int = 0x1007;
481pub const SO_TYPE: ::c_int = 0x1008;
041b39d2
XL
482
483pub const SOCK_CLOEXEC: ::c_int = O_CLOEXEC;
484
041b39d2
XL
485pub const INET_ADDRSTRLEN: ::c_int = 16;
486
ff7c6d11
XL
487// https://github.
488// com/bminor/newlib/blob/master/newlib/libc/sys/linux/include/net/if.h#L121
489pub const IFF_UP: ::c_int = 0x1; // interface is up
490pub const IFF_BROADCAST: ::c_int = 0x2; // broadcast address valid
491pub const IFF_DEBUG: ::c_int = 0x4; // turn on debugging
492pub const IFF_LOOPBACK: ::c_int = 0x8; // is a loopback net
493pub const IFF_POINTOPOINT: ::c_int = 0x10; // interface is point-to-point link
494pub const IFF_NOTRAILERS: ::c_int = 0x20; // avoid use of trailers
495pub const IFF_RUNNING: ::c_int = 0x40; // resources allocated
496pub const IFF_NOARP: ::c_int = 0x80; // no address resolution protocol
497pub const IFF_PROMISC: ::c_int = 0x100; // receive all packets
498pub const IFF_ALLMULTI: ::c_int = 0x200; // receive all multicast packets
499pub const IFF_OACTIVE: ::c_int = 0x400; // transmission in progress
500pub const IFF_SIMPLEX: ::c_int = 0x800; // can't hear own transmissions
501pub const IFF_LINK0: ::c_int = 0x1000; // per link layer defined bit
502pub const IFF_LINK1: ::c_int = 0x2000; // per link layer defined bit
503pub const IFF_LINK2: ::c_int = 0x4000; // per link layer defined bit
504pub const IFF_ALTPHYS: ::c_int = IFF_LINK2; // use alternate physical connection
505pub const IFF_MULTICAST: ::c_int = 0x8000; // supports multicast
506
041b39d2
XL
507pub const TCP_NODELAY: ::c_int = 8193;
508pub const TCP_MAXSEG: ::c_int = 8194;
416331ca
XL
509pub const TCP_NOPUSH: ::c_int = 4;
510pub const TCP_NOOPT: ::c_int = 8;
511pub const TCP_KEEPIDLE: ::c_int = 256;
512pub const TCP_KEEPINTVL: ::c_int = 512;
513pub const TCP_KEEPCNT: ::c_int = 1024;
041b39d2 514
416331ca 515pub const IP_TOS: ::c_int = 3;
041b39d2 516pub const IP_TTL: ::c_int = 8;
416331ca 517pub const IP_MULTICAST_IF: ::c_int = 9;
041b39d2 518pub const IP_MULTICAST_TTL: ::c_int = 10;
416331ca 519pub const IP_MULTICAST_LOOP: ::c_int = 11;
041b39d2
XL
520pub const IP_ADD_MEMBERSHIP: ::c_int = 11;
521pub const IP_DROP_MEMBERSHIP: ::c_int = 12;
522
416331ca
XL
523pub const IPV6_UNICAST_HOPS: ::c_int = 4;
524pub const IPV6_MULTICAST_IF: ::c_int = 9;
525pub const IPV6_MULTICAST_HOPS: ::c_int = 10;
526pub const IPV6_MULTICAST_LOOP: ::c_int = 11;
527pub const IPV6_V6ONLY: ::c_int = 27;
528pub const IPV6_JOIN_GROUP: ::c_int = 12;
529pub const IPV6_LEAVE_GROUP: ::c_int = 13;
530pub const IPV6_ADD_MEMBERSHIP: ::c_int = 12;
531pub const IPV6_DROP_MEMBERSHIP: ::c_int = 13;
532
041b39d2
XL
533pub const HOST_NOT_FOUND: ::c_int = 1;
534pub const NO_DATA: ::c_int = 2;
535pub const NO_ADDRESS: ::c_int = 2;
536pub const NO_RECOVERY: ::c_int = 3;
537pub const TRY_AGAIN: ::c_int = 4;
538
539pub const AI_PASSIVE: ::c_int = 1;
540pub const AI_CANONNAME: ::c_int = 2;
541pub const AI_NUMERICHOST: ::c_int = 4;
542pub const AI_NUMERICSERV: ::c_int = 0;
543pub const AI_ADDRCONFIG: ::c_int = 0;
544
545pub const NI_MAXHOST: ::c_int = 1025;
546pub const NI_MAXSERV: ::c_int = 32;
547pub const NI_NOFQDN: ::c_int = 1;
548pub const NI_NUMERICHOST: ::c_int = 2;
549pub const NI_NAMEREQD: ::c_int = 4;
550pub const NI_NUMERICSERV: ::c_int = 0;
551pub const NI_DGRAM: ::c_int = 0;
552
553pub const EAI_FAMILY: ::c_int = -303;
554pub const EAI_MEMORY: ::c_int = -304;
555pub const EAI_NONAME: ::c_int = -305;
556pub const EAI_SOCKTYPE: ::c_int = -307;
557
f035d41b
XL
558pub const EXIT_SUCCESS: ::c_int = 0;
559pub const EXIT_FAILURE: ::c_int = 1;
560
561pub const PRIO_PROCESS: ::c_int = 0;
562pub const PRIO_PGRP: ::c_int = 1;
563pub const PRIO_USER: ::c_int = 2;
564
041b39d2
XL
565f! {
566 pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () {
532ac7d7 567 let bits = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
041b39d2
XL
568 let fd = fd as usize;
569 (*set).fds_bits[fd / bits] &= !(1 << (fd % bits));
570 return
571 }
572
94222f64 573 pub fn FD_ISSET(fd: ::c_int, set: *const fd_set) -> bool {
532ac7d7 574 let bits = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
041b39d2
XL
575 let fd = fd as usize;
576 return ((*set).fds_bits[fd / bits] & (1 << (fd % bits))) != 0
577 }
578
579 pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () {
532ac7d7 580 let bits = ::mem::size_of_val(&(*set).fds_bits[0]) * 8;
041b39d2
XL
581 let fd = fd as usize;
582 (*set).fds_bits[fd / bits] |= 1 << (fd % bits);
583 return
584 }
585
586 pub fn FD_ZERO(set: *mut fd_set) -> () {
587 for slot in (*set).fds_bits.iter_mut() {
588 *slot = 0;
589 }
590 }
591}
592
e74abb32 593extern "C" {
416331ca
XL
594 pub fn getrlimit(resource: ::c_int, rlim: *mut ::rlimit) -> ::c_int;
595 pub fn setrlimit(resource: ::c_int, rlim: *const ::rlimit) -> ::c_int;
596
e74abb32 597 #[cfg_attr(target_os = "linux", link_name = "__xpg_strerror_r")]
cdc7bbd5 598 pub fn strerror_r(errnum: ::c_int, buf: *mut c_char, buflen: ::size_t) -> ::c_int;
416331ca 599
532ac7d7 600 pub fn sem_destroy(sem: *mut sem_t) -> ::c_int;
cdc7bbd5 601 pub fn sem_init(sem: *mut sem_t, pshared: ::c_int, value: ::c_uint) -> ::c_int;
532ac7d7 602
69743fb6
XL
603 pub fn abs(i: ::c_int) -> ::c_int;
604 pub fn atof(s: *const ::c_char) -> ::c_double;
605 pub fn labs(i: ::c_long) -> ::c_long;
606 pub fn rand() -> ::c_int;
607 pub fn srand(seed: ::c_uint);
608
5869c6ff
XL
609 #[cfg(not(all(
610 libc_cfg_target_vendor,
611 target_arch = "powerpc",
612 target_vendor = "nintendo"
613 )))]
cdc7bbd5
XL
614 pub fn bind(fd: ::c_int, addr: *const sockaddr, len: socklen_t) -> ::c_int;
615 pub fn clock_settime(clock_id: ::clockid_t, tp: *const ::timespec) -> ::c_int;
616 pub fn clock_gettime(clock_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int;
617 pub fn clock_getres(clock_id: ::clockid_t, res: *mut ::timespec) -> ::c_int;
041b39d2
XL
618 pub fn closesocket(sockfd: ::c_int) -> ::c_int;
619 pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
5869c6ff
XL
620 #[cfg(not(all(
621 libc_cfg_target_vendor,
622 target_arch = "powerpc",
623 target_vendor = "nintendo"
624 )))]
e74abb32
XL
625 pub fn recvfrom(
626 fd: ::c_int,
627 buf: *mut ::c_void,
628 n: usize,
629 flags: ::c_int,
630 addr: *mut sockaddr,
631 addr_len: *mut socklen_t,
632 ) -> isize;
5869c6ff
XL
633 #[cfg(not(all(
634 libc_cfg_target_vendor,
635 target_arch = "powerpc",
636 target_vendor = "nintendo"
637 )))]
e74abb32
XL
638 pub fn getnameinfo(
639 sa: *const sockaddr,
640 salen: socklen_t,
641 host: *mut ::c_char,
642 hostlen: socklen_t,
643 serv: *mut ::c_char,
644 servlen: socklen_t,
645 flags: ::c_int,
646 ) -> ::c_int;
3b2f2976 647 pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void;
e74abb32
XL
648 pub fn fexecve(
649 fd: ::c_int,
650 argv: *const *const ::c_char,
651 envp: *const *const ::c_char,
652 ) -> ::c_int;
653 pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::c_void) -> ::c_int;
e74abb32
XL
654 pub fn getgrgid_r(
655 gid: ::gid_t,
656 grp: *mut ::group,
657 buf: *mut ::c_char,
658 buflen: ::size_t,
659 result: *mut *mut ::group,
660 ) -> ::c_int;
e74abb32 661 pub fn sigaltstack(ss: *const stack_t, oss: *mut stack_t) -> ::c_int;
ea8adc8c
XL
662 pub fn sem_close(sem: *mut sem_t) -> ::c_int;
663 pub fn getdtablesize() -> ::c_int;
e74abb32
XL
664 pub fn getgrnam_r(
665 name: *const ::c_char,
666 grp: *mut ::group,
667 buf: *mut ::c_char,
668 buflen: ::size_t,
669 result: *mut *mut ::group,
670 ) -> ::c_int;
cdc7bbd5 671 pub fn pthread_sigmask(how: ::c_int, set: *const sigset_t, oldset: *mut sigset_t) -> ::c_int;
ea8adc8c
XL
672 pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t;
673 pub fn getgrnam(name: *const ::c_char) -> *mut ::group;
674 pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int;
675 pub fn sem_unlink(name: *const ::c_char) -> ::c_int;
676 pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int;
e74abb32
XL
677 pub fn getpwnam_r(
678 name: *const ::c_char,
679 pwd: *mut passwd,
680 buf: *mut ::c_char,
681 buflen: ::size_t,
682 result: *mut *mut passwd,
683 ) -> ::c_int;
e74abb32
XL
684 pub fn getpwuid_r(
685 uid: ::uid_t,
686 pwd: *mut passwd,
687 buf: *mut ::c_char,
688 buflen: ::size_t,
689 result: *mut *mut passwd,
690 ) -> ::c_int;
e74abb32
XL
691 pub fn sigwait(set: *const sigset_t, sig: *mut ::c_int) -> ::c_int;
692 pub fn pthread_atfork(
693 prepare: ::Option<unsafe extern "C" fn()>,
694 parent: ::Option<unsafe extern "C" fn()>,
695 child: ::Option<unsafe extern "C" fn()>,
696 ) -> ::c_int;
ea8adc8c 697 pub fn getgrgid(gid: ::gid_t) -> *mut ::group;
e74abb32 698 pub fn popen(command: *const c_char, mode: *const c_char) -> *mut ::FILE;
532ac7d7 699 pub fn uname(buf: *mut ::utsname) -> ::c_int;
041b39d2
XL
700}
701
702cfg_if! {
94222f64
XL
703 if #[cfg(target_os = "espidf")] {
704 mod espidf;
705 pub use self::espidf::*;
706 } else if #[cfg(target_arch = "arm")] {
041b39d2
XL
707 mod arm;
708 pub use self::arm::*;
ff7c6d11
XL
709 } else if #[cfg(target_arch = "aarch64")] {
710 mod aarch64;
711 pub use self::aarch64::*;
3dfed10e
XL
712 } else if #[cfg(target_arch = "powerpc")] {
713 mod powerpc;
714 pub use self::powerpc::*;
041b39d2
XL
715 } else {
716 // Only tested on ARM so far. Other platforms might have different
717 // definitions for types and constants.
718 pub use target_arch_not_implemented;
719 }
720}
532ac7d7
XL
721
722cfg_if! {
723 if #[cfg(libc_align)] {
724 #[macro_use]
725 mod align;
726 } else {
727 #[macro_use]
728 mod no_align;
729 }
730}
731expand_align!();