]>
Commit | Line | Data |
---|---|---|
041b39d2 XL |
1 | pub type blkcnt_t = i32; |
2 | pub type blksize_t = i32; | |
041b39d2 XL |
3 | pub type clockid_t = ::c_ulong; |
4 | pub type dev_t = u32; | |
5 | pub type fsblkcnt_t = u64; | |
6 | pub type fsfilcnt_t = u32; | |
7 | pub type id_t = u32; | |
8 | pub type ino_t = u32; | |
9 | pub type key_t = ::c_int; | |
10 | pub type loff_t = ::c_longlong; | |
11 | pub type mode_t = ::c_uint; | |
12 | pub type nfds_t = u32; | |
13 | pub type nlink_t = ::c_ushort; | |
14 | pub type off_t = i64; | |
15 | pub type pthread_t = ::c_ulong; | |
16 | pub type pthread_key_t = ::c_uint; | |
17 | pub type rlim_t = u32; | |
18 | pub type sa_family_t = u8; | |
19 | pub type socklen_t = u32; | |
20 | pub type speed_t = u32; | |
21 | pub type suseconds_t = i32; | |
22 | pub type tcflag_t = ::c_uint; | |
23 | pub type time_t = i32; | |
24 | pub type useconds_t = u32; | |
25 | ||
26 | s! { | |
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 |
231 | align_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 | 242 | pub const NCCS: usize = 32; |
94222f64 XL |
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 | } 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 |
264 | pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; |
265 | pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4; | |
266 | pub const __PTHREAD_MUTEX_HAVE_PREV: usize = 1; | |
267 | pub const __PTHREAD_RWLOCK_INT_FLAGS_SHARED: usize = 1; | |
268 | pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0; | |
269 | pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1; | |
270 | pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2; | |
271 | pub const FD_SETSIZE: usize = 1024; | |
272 | // intentionally not public, only used for fd_set | |
273 | const ULONG_SIZE: usize = 32; | |
274 | ||
275 | // Other constants | |
276 | pub const EPERM: ::c_int = 1; | |
277 | pub const ENOENT: ::c_int = 2; | |
278 | pub const ESRCH: ::c_int = 3; | |
279 | pub const EINTR: ::c_int = 4; | |
280 | pub const EIO: ::c_int = 5; | |
281 | pub const ENXIO: ::c_int = 6; | |
282 | pub const E2BIG: ::c_int = 7; | |
283 | pub const ENOEXEC: ::c_int = 8; | |
284 | pub const EBADF: ::c_int = 9; | |
285 | pub const ECHILD: ::c_int = 10; | |
286 | pub const EAGAIN: ::c_int = 11; | |
287 | pub const ENOMEM: ::c_int = 12; | |
288 | pub const EACCES: ::c_int = 13; | |
289 | pub const EFAULT: ::c_int = 14; | |
290 | pub const EBUSY: ::c_int = 16; | |
291 | pub const EEXIST: ::c_int = 17; | |
292 | pub const EXDEV: ::c_int = 18; | |
293 | pub const ENODEV: ::c_int = 19; | |
294 | pub const ENOTDIR: ::c_int = 20; | |
295 | pub const EISDIR: ::c_int = 21; | |
296 | pub const EINVAL: ::c_int = 22; | |
297 | pub const ENFILE: ::c_int = 23; | |
298 | pub const EMFILE: ::c_int = 24; | |
299 | pub const ENOTTY: ::c_int = 25; | |
300 | pub const ETXTBSY: ::c_int = 26; | |
301 | pub const EFBIG: ::c_int = 27; | |
302 | pub const ENOSPC: ::c_int = 28; | |
303 | pub const ESPIPE: ::c_int = 29; | |
304 | pub const EROFS: ::c_int = 30; | |
305 | pub const EMLINK: ::c_int = 31; | |
306 | pub const EPIPE: ::c_int = 32; | |
307 | pub const EDOM: ::c_int = 33; | |
308 | pub const ERANGE: ::c_int = 34; | |
309 | pub const ENOMSG: ::c_int = 35; | |
310 | pub const EIDRM: ::c_int = 36; | |
311 | pub const EDEADLK: ::c_int = 45; | |
312 | pub const ENOLCK: ::c_int = 46; | |
313 | pub const ENOSTR: ::c_int = 60; | |
314 | pub const ENODATA: ::c_int = 61; | |
315 | pub const ETIME: ::c_int = 62; | |
316 | pub const ENOSR: ::c_int = 63; | |
317 | pub const ENOLINK: ::c_int = 67; | |
318 | pub const EPROTO: ::c_int = 71; | |
319 | pub const EMULTIHOP: ::c_int = 74; | |
320 | pub const EBADMSG: ::c_int = 77; | |
321 | pub const EFTYPE: ::c_int = 79; | |
322 | pub const ENOSYS: ::c_int = 88; | |
323 | pub const ENOTEMPTY: ::c_int = 90; | |
324 | pub const ENAMETOOLONG: ::c_int = 91; | |
325 | pub const ELOOP: ::c_int = 92; | |
326 | pub const EOPNOTSUPP: ::c_int = 95; | |
327 | pub const EPFNOSUPPORT: ::c_int = 96; | |
328 | pub const ECONNRESET: ::c_int = 104; | |
329 | pub const ENOBUFS: ::c_int = 105; | |
330 | pub const EAFNOSUPPORT: ::c_int = 106; | |
331 | pub const EPROTOTYPE: ::c_int = 107; | |
332 | pub const ENOTSOCK: ::c_int = 108; | |
333 | pub const ENOPROTOOPT: ::c_int = 109; | |
334 | pub const ECONNREFUSED: ::c_int = 111; | |
335 | pub const EADDRINUSE: ::c_int = 112; | |
336 | pub const ECONNABORTED: ::c_int = 113; | |
337 | pub const ENETUNREACH: ::c_int = 114; | |
338 | pub const ENETDOWN: ::c_int = 115; | |
339 | pub const ETIMEDOUT: ::c_int = 116; | |
340 | pub const EHOSTDOWN: ::c_int = 117; | |
341 | pub const EHOSTUNREACH: ::c_int = 118; | |
342 | pub const EINPROGRESS: ::c_int = 119; | |
343 | pub const EALREADY: ::c_int = 120; | |
344 | pub const EDESTADDRREQ: ::c_int = 121; | |
345 | pub const EMSGSIZE: ::c_int = 122; | |
346 | pub const EPROTONOSUPPORT: ::c_int = 123; | |
347 | pub const EADDRNOTAVAIL: ::c_int = 125; | |
348 | pub const ENETRESET: ::c_int = 126; | |
349 | pub const EISCONN: ::c_int = 127; | |
350 | pub const ENOTCONN: ::c_int = 128; | |
351 | pub const ETOOMANYREFS: ::c_int = 129; | |
352 | pub const EDQUOT: ::c_int = 132; | |
353 | pub const ESTALE: ::c_int = 133; | |
354 | pub const ENOTSUP: ::c_int = 134; | |
355 | pub const EILSEQ: ::c_int = 138; | |
356 | pub const EOVERFLOW: ::c_int = 139; | |
357 | pub const ECANCELED: ::c_int = 140; | |
358 | pub const ENOTRECOVERABLE: ::c_int = 141; | |
359 | pub const EOWNERDEAD: ::c_int = 142; | |
360 | pub const EWOULDBLOCK: ::c_int = 11; | |
361 | ||
362 | pub const F_DUPFD: ::c_int = 0; | |
363 | pub const F_GETFD: ::c_int = 1; | |
364 | pub const F_SETFD: ::c_int = 2; | |
365 | pub const F_GETFL: ::c_int = 3; | |
366 | pub const F_SETFL: ::c_int = 4; | |
367 | pub const F_GETOWN: ::c_int = 5; | |
368 | pub const F_SETOWN: ::c_int = 6; | |
369 | pub const F_GETLK: ::c_int = 7; | |
370 | pub const F_SETLK: ::c_int = 8; | |
371 | pub const F_SETLKW: ::c_int = 9; | |
372 | pub const F_RGETLK: ::c_int = 10; | |
373 | pub const F_RSETLK: ::c_int = 11; | |
374 | pub const F_CNVT: ::c_int = 12; | |
375 | pub const F_RSETLKW: ::c_int = 13; | |
376 | pub const F_DUPFD_CLOEXEC: ::c_int = 14; | |
377 | ||
378 | pub const O_RDONLY: ::c_int = 0; | |
379 | pub const O_WRONLY: ::c_int = 1; | |
380 | pub const O_RDWR: ::c_int = 2; | |
381 | pub const O_APPEND: ::c_int = 8; | |
382 | pub const O_CREAT: ::c_int = 512; | |
383 | pub const O_TRUNC: ::c_int = 1024; | |
384 | pub const O_EXCL: ::c_int = 2048; | |
385 | pub const O_SYNC: ::c_int = 8192; | |
386 | pub const O_NONBLOCK: ::c_int = 16384; | |
387 | ||
388 | pub const O_ACCMODE: ::c_int = 3; | |
389 | pub const O_CLOEXEC: ::c_int = 0x80000; | |
390 | ||
abe05a73 XL |
391 | pub const RTLD_LAZY: ::c_int = 0x1; |
392 | ||
041b39d2 XL |
393 | pub const STDIN_FILENO: ::c_int = 0; |
394 | pub const STDOUT_FILENO: ::c_int = 1; | |
395 | pub const STDERR_FILENO: ::c_int = 2; | |
396 | ||
397 | pub const SEEK_SET: ::c_int = 0; | |
398 | pub const SEEK_CUR: ::c_int = 1; | |
399 | pub const SEEK_END: ::c_int = 2; | |
400 | ||
416331ca XL |
401 | pub const FIOCLEX: ::c_ulong = 0x20006601; |
402 | pub const FIONCLEX: ::c_ulong = 0x20006602; | |
041b39d2 XL |
403 | |
404 | pub const S_BLKSIZE: ::mode_t = 1024; | |
405 | pub const S_IREAD: ::mode_t = 256; | |
406 | pub const S_IWRITE: ::mode_t = 128; | |
407 | pub const S_IEXEC: ::mode_t = 64; | |
408 | pub const S_ENFMT: ::mode_t = 1024; | |
409 | pub const S_IFMT: ::mode_t = 61440; | |
410 | pub const S_IFDIR: ::mode_t = 16384; | |
411 | pub const S_IFCHR: ::mode_t = 8192; | |
412 | pub const S_IFBLK: ::mode_t = 24576; | |
413 | pub const S_IFREG: ::mode_t = 32768; | |
414 | pub const S_IFLNK: ::mode_t = 40960; | |
415 | pub const S_IFSOCK: ::mode_t = 49152; | |
416 | pub const S_IFIFO: ::mode_t = 4096; | |
417 | pub const S_IRUSR: ::mode_t = 256; | |
418 | pub const S_IWUSR: ::mode_t = 128; | |
419 | pub const S_IXUSR: ::mode_t = 64; | |
420 | pub const S_IRGRP: ::mode_t = 32; | |
421 | pub const S_IWGRP: ::mode_t = 16; | |
422 | pub const S_IXGRP: ::mode_t = 8; | |
423 | pub const S_IROTH: ::mode_t = 4; | |
424 | pub const S_IWOTH: ::mode_t = 2; | |
425 | pub const S_IXOTH: ::mode_t = 1; | |
426 | ||
041b39d2 XL |
427 | pub const SOL_TCP: ::c_int = 6; |
428 | ||
429 | pub const PF_UNSPEC: ::c_int = 0; | |
430 | pub const PF_INET: ::c_int = 2; | |
431 | pub const PF_INET6: ::c_int = 23; | |
432 | ||
433 | pub const AF_UNSPEC: ::c_int = 0; | |
434 | pub const AF_INET: ::c_int = 2; | |
041b39d2 | 435 | |
ba9703b0 XL |
436 | pub const CLOCK_REALTIME: ::clockid_t = 1; |
437 | pub const CLOCK_MONOTONIC: ::clockid_t = 4; | |
438 | pub const CLOCK_BOOTTIME: ::clockid_t = 4; | |
439 | ||
041b39d2 XL |
440 | pub const SOCK_STREAM: ::c_int = 1; |
441 | pub const SOCK_DGRAM: ::c_int = 2; | |
442 | ||
041b39d2 XL |
443 | pub const SHUT_RD: ::c_int = 0; |
444 | pub const SHUT_WR: ::c_int = 1; | |
445 | pub const SHUT_RDWR: ::c_int = 2; | |
446 | ||
416331ca XL |
447 | pub const SO_BINTIME: ::c_int = 0x2000; |
448 | pub const SO_NO_OFFLOAD: ::c_int = 0x4000; | |
449 | pub const SO_NO_DDP: ::c_int = 0x8000; | |
450 | pub const SO_REUSEPORT_LB: ::c_int = 0x10000; | |
451 | pub const SO_LABEL: ::c_int = 0x1009; | |
452 | pub const SO_PEERLABEL: ::c_int = 0x1010; | |
453 | pub const SO_LISTENQLIMIT: ::c_int = 0x1011; | |
454 | pub const SO_LISTENQLEN: ::c_int = 0x1012; | |
455 | pub const SO_LISTENINCQLEN: ::c_int = 0x1013; | |
456 | pub const SO_SETFIB: ::c_int = 0x1014; | |
457 | pub const SO_USER_COOKIE: ::c_int = 0x1015; | |
458 | pub const SO_PROTOCOL: ::c_int = 0x1016; | |
459 | pub const SO_PROTOTYPE: ::c_int = SO_PROTOCOL; | |
460 | pub const SO_VENDOR: ::c_int = 0x80000000; | |
461 | pub const SO_DEBUG: ::c_int = 0x01; | |
462 | pub const SO_ACCEPTCONN: ::c_int = 0x0002; | |
463 | pub const SO_REUSEADDR: ::c_int = 0x0004; | |
464 | pub const SO_KEEPALIVE: ::c_int = 0x0008; | |
465 | pub const SO_DONTROUTE: ::c_int = 0x0010; | |
466 | pub const SO_BROADCAST: ::c_int = 0x0020; | |
467 | pub const SO_USELOOPBACK: ::c_int = 0x0040; | |
468 | pub const SO_LINGER: ::c_int = 0x0080; | |
469 | pub const SO_OOBINLINE: ::c_int = 0x0100; | |
470 | pub const SO_REUSEPORT: ::c_int = 0x0200; | |
471 | pub const SO_TIMESTAMP: ::c_int = 0x0400; | |
472 | pub const SO_NOSIGPIPE: ::c_int = 0x0800; | |
473 | pub const SO_ACCEPTFILTER: ::c_int = 0x1000; | |
474 | pub const SO_SNDBUF: ::c_int = 0x1001; | |
475 | pub const SO_RCVBUF: ::c_int = 0x1002; | |
476 | pub const SO_SNDLOWAT: ::c_int = 0x1003; | |
477 | pub const SO_RCVLOWAT: ::c_int = 0x1004; | |
478 | pub const SO_SNDTIMEO: ::c_int = 0x1005; | |
479 | pub const SO_RCVTIMEO: ::c_int = 0x1006; | |
480 | pub const SO_ERROR: ::c_int = 0x1007; | |
481 | pub const SO_TYPE: ::c_int = 0x1008; | |
041b39d2 XL |
482 | |
483 | pub const SOCK_CLOEXEC: ::c_int = O_CLOEXEC; | |
484 | ||
041b39d2 XL |
485 | pub 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 | |
489 | pub const IFF_UP: ::c_int = 0x1; // interface is up | |
490 | pub const IFF_BROADCAST: ::c_int = 0x2; // broadcast address valid | |
491 | pub const IFF_DEBUG: ::c_int = 0x4; // turn on debugging | |
492 | pub const IFF_LOOPBACK: ::c_int = 0x8; // is a loopback net | |
493 | pub const IFF_POINTOPOINT: ::c_int = 0x10; // interface is point-to-point link | |
494 | pub const IFF_NOTRAILERS: ::c_int = 0x20; // avoid use of trailers | |
495 | pub const IFF_RUNNING: ::c_int = 0x40; // resources allocated | |
496 | pub const IFF_NOARP: ::c_int = 0x80; // no address resolution protocol | |
497 | pub const IFF_PROMISC: ::c_int = 0x100; // receive all packets | |
498 | pub const IFF_ALLMULTI: ::c_int = 0x200; // receive all multicast packets | |
499 | pub const IFF_OACTIVE: ::c_int = 0x400; // transmission in progress | |
500 | pub const IFF_SIMPLEX: ::c_int = 0x800; // can't hear own transmissions | |
501 | pub const IFF_LINK0: ::c_int = 0x1000; // per link layer defined bit | |
502 | pub const IFF_LINK1: ::c_int = 0x2000; // per link layer defined bit | |
503 | pub const IFF_LINK2: ::c_int = 0x4000; // per link layer defined bit | |
504 | pub const IFF_ALTPHYS: ::c_int = IFF_LINK2; // use alternate physical connection | |
505 | pub const IFF_MULTICAST: ::c_int = 0x8000; // supports multicast | |
506 | ||
041b39d2 XL |
507 | pub const TCP_NODELAY: ::c_int = 8193; |
508 | pub const TCP_MAXSEG: ::c_int = 8194; | |
416331ca XL |
509 | pub const TCP_NOPUSH: ::c_int = 4; |
510 | pub const TCP_NOOPT: ::c_int = 8; | |
511 | pub const TCP_KEEPIDLE: ::c_int = 256; | |
512 | pub const TCP_KEEPINTVL: ::c_int = 512; | |
513 | pub const TCP_KEEPCNT: ::c_int = 1024; | |
041b39d2 | 514 | |
416331ca | 515 | pub const IP_TOS: ::c_int = 3; |
041b39d2 | 516 | pub const IP_TTL: ::c_int = 8; |
416331ca | 517 | pub const IP_MULTICAST_IF: ::c_int = 9; |
041b39d2 | 518 | pub const IP_MULTICAST_TTL: ::c_int = 10; |
416331ca | 519 | pub const IP_MULTICAST_LOOP: ::c_int = 11; |
041b39d2 XL |
520 | pub const IP_ADD_MEMBERSHIP: ::c_int = 11; |
521 | pub const IP_DROP_MEMBERSHIP: ::c_int = 12; | |
522 | ||
416331ca XL |
523 | pub const IPV6_UNICAST_HOPS: ::c_int = 4; |
524 | pub const IPV6_MULTICAST_IF: ::c_int = 9; | |
525 | pub const IPV6_MULTICAST_HOPS: ::c_int = 10; | |
526 | pub const IPV6_MULTICAST_LOOP: ::c_int = 11; | |
527 | pub const IPV6_V6ONLY: ::c_int = 27; | |
528 | pub const IPV6_JOIN_GROUP: ::c_int = 12; | |
529 | pub const IPV6_LEAVE_GROUP: ::c_int = 13; | |
530 | pub const IPV6_ADD_MEMBERSHIP: ::c_int = 12; | |
531 | pub const IPV6_DROP_MEMBERSHIP: ::c_int = 13; | |
532 | ||
041b39d2 XL |
533 | pub const HOST_NOT_FOUND: ::c_int = 1; |
534 | pub const NO_DATA: ::c_int = 2; | |
535 | pub const NO_ADDRESS: ::c_int = 2; | |
536 | pub const NO_RECOVERY: ::c_int = 3; | |
537 | pub const TRY_AGAIN: ::c_int = 4; | |
538 | ||
539 | pub const AI_PASSIVE: ::c_int = 1; | |
540 | pub const AI_CANONNAME: ::c_int = 2; | |
541 | pub const AI_NUMERICHOST: ::c_int = 4; | |
542 | pub const AI_NUMERICSERV: ::c_int = 0; | |
543 | pub const AI_ADDRCONFIG: ::c_int = 0; | |
544 | ||
545 | pub const NI_MAXHOST: ::c_int = 1025; | |
546 | pub const NI_MAXSERV: ::c_int = 32; | |
547 | pub const NI_NOFQDN: ::c_int = 1; | |
548 | pub const NI_NUMERICHOST: ::c_int = 2; | |
549 | pub const NI_NAMEREQD: ::c_int = 4; | |
550 | pub const NI_NUMERICSERV: ::c_int = 0; | |
551 | pub const NI_DGRAM: ::c_int = 0; | |
552 | ||
553 | pub const EAI_FAMILY: ::c_int = -303; | |
554 | pub const EAI_MEMORY: ::c_int = -304; | |
555 | pub const EAI_NONAME: ::c_int = -305; | |
556 | pub const EAI_SOCKTYPE: ::c_int = -307; | |
557 | ||
f035d41b XL |
558 | pub const EXIT_SUCCESS: ::c_int = 0; |
559 | pub const EXIT_FAILURE: ::c_int = 1; | |
560 | ||
561 | pub const PRIO_PROCESS: ::c_int = 0; | |
562 | pub const PRIO_PGRP: ::c_int = 1; | |
563 | pub const PRIO_USER: ::c_int = 2; | |
564 | ||
041b39d2 XL |
565 | f! { |
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 | 593 | extern "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 | ||
702 | cfg_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 | |
722 | cfg_if! { | |
723 | if #[cfg(libc_align)] { | |
724 | #[macro_use] | |
725 | mod align; | |
726 | } else { | |
727 | #[macro_use] | |
728 | mod no_align; | |
729 | } | |
730 | } | |
731 | expand_align!(); |