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