Debian Codegraph @

.cargo/vendor/libc/src/unix/newlib/mod.rs

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