]> git.proxmox.com Git - rustc.git/blame - src/liblibc/src/unix/newlib/mod.rs
New upstream version 1.22.1+dfsg1
[rustc.git] / src / liblibc / src / unix / newlib / mod.rs
CommitLineData
3b2f2976
XL
1use dox::mem;
2
3pub type blkcnt_t = i32;
4pub type blksize_t = i32;
5pub type clock_t = i32;
6pub type clockid_t = ::c_ulong;
7pub type dev_t = u32;
8pub type fsblkcnt_t = u64;
9pub type fsfilcnt_t = u32;
10pub type id_t = u32;
11pub type ino_t = u32;
12pub type key_t = ::c_int;
13pub type loff_t = ::c_longlong;
14pub type mode_t = ::c_uint;
15pub type nfds_t = u32;
16pub type nlink_t = ::c_ushort;
17pub type off_t = i64;
18pub type pthread_t = ::c_ulong;
19pub type pthread_key_t = ::c_uint;
20pub type rlim_t = u32;
21pub type sa_family_t = u8;
22pub type socklen_t = u32;
23pub type speed_t = u32;
24pub type suseconds_t = i32;
25pub type tcflag_t = ::c_uint;
26pub type time_t = i32;
27pub type useconds_t = u32;
28
29s! {
30 pub struct sockaddr {
31 pub sa_family: sa_family_t,
32 pub sa_data: [::c_char; 14],
33 }
34
35 pub struct sockaddr_in {
36 pub sin_family: sa_family_t,
37 pub sin_port: ::in_port_t,
38 pub sin_addr: ::in_addr,
39 pub sin_zero: [u8; 8],
40 }
41
42 pub struct sockaddr_in6 { // Unverified
43 pub sin6_family: sa_family_t,
44 pub sin6_port: ::in_port_t,
45 pub sin6_flowinfo: u32,
46 pub sin6_addr: ::in6_addr,
47 pub sin6_scope_id: u32,
48 }
49
50 pub struct sockaddr_storage {
51 pub ss_family: sa_family_t,
52 pub __ss_padding: [u8; 26],
53 }
54
55 pub struct addrinfo {
56 pub ai_flags: ::c_int,
57 pub ai_family: ::c_int,
58 pub ai_socktype: ::c_int,
59 pub ai_protocol: ::c_int,
60 pub ai_addrlen: socklen_t,
61 pub ai_canonname: *mut ::c_char,
62 pub ai_addr: *mut sockaddr,
63 pub ai_next: *mut addrinfo,
64 }
65
66 pub struct ip_mreq {
67 pub imr_multiaddr: in_addr,
68 pub imr_interface: in_addr,
69 }
70
71 pub struct linger {
72 pub l_onoff: ::c_int,
73 pub l_linger: ::c_int,
74 }
75
76 pub struct in_addr {
77 pub s_addr: ::in_addr_t,
78 }
79
80 pub struct hostent {
81 pub h_name: *mut ::c_char,
82 pub h_aliases: *mut *mut ::c_char,
83 pub h_addrtype: ::c_int,
84 pub h_length: ::c_int,
85 pub h_addr_list: *mut *mut ::c_char,
86 pub h_addr: *mut ::c_char,
87 }
88
89 pub struct pollfd {
90 pub fd: ::c_int,
91 pub events: ::c_int,
92 pub revents: ::c_int,
93 }
94
95 pub struct lconv {
96 pub decimal_point: *mut ::c_char,
97 pub thousands_sep: *mut ::c_char,
98 pub grouping: *mut ::c_char,
99 pub int_curr_symbol: *mut ::c_char,
100 pub currency_symbol: *mut ::c_char,
101 pub mon_decimal_point: *mut ::c_char,
102 pub mon_thousands_sep: *mut ::c_char,
103 pub mon_grouping: *mut ::c_char,
104 pub positive_sign: *mut ::c_char,
105 pub negative_sign: *mut ::c_char,
106 pub int_frac_digits: ::c_char,
107 pub frac_digits: ::c_char,
108 pub p_cs_precedes: ::c_char,
109 pub p_sep_by_space: ::c_char,
110 pub n_cs_precedes: ::c_char,
111 pub n_sep_by_space: ::c_char,
112 pub p_sign_posn: ::c_char,
113 pub n_sign_posn: ::c_char,
114 pub int_n_cs_precedes: ::c_char,
115 pub int_n_sep_by_space: ::c_char,
116 pub int_n_sign_posn: ::c_char,
117 pub int_p_cs_precedes: ::c_char,
118 pub int_p_sep_by_space: ::c_char,
119 pub int_p_sign_posn: ::c_char,
120 }
121
122 pub struct tm {
123 pub tm_sec: ::c_int,
124 pub tm_min: ::c_int,
125 pub tm_hour: ::c_int,
126 pub tm_mday: ::c_int,
127 pub tm_mon: ::c_int,
128 pub tm_year: ::c_int,
129 pub tm_wday: ::c_int,
130 pub tm_yday: ::c_int,
131 pub tm_isdst: ::c_int,
132 }
133
134 pub struct stat {
135 pub st_dev: ::dev_t,
136 pub st_ino: ::ino_t,
137 pub st_mode: ::mode_t,
138 pub st_nlink: ::nlink_t,
139 pub st_uid: ::uid_t,
140 pub st_gid: ::gid_t,
141 pub st_rdev: dev_t,
142 pub st_size: off_t,
143 pub st_atime: time_t,
144 pub st_spare1: ::c_long,
145 pub st_mtime: time_t,
146 pub st_spare2: ::c_long,
147 pub st_ctime: time_t,
148 pub st_spare3: ::c_long,
149 pub st_blksize: blksize_t,
150 pub st_blocks: blkcnt_t,
151 pub st_spare4: [::c_long; 2usize],
152 }
153
154 pub struct statvfs {
155 pub f_bsize: ::c_ulong,
156 pub f_frsize: ::c_ulong,
157 pub f_blocks: fsblkcnt_t,
158 pub f_bfree: fsblkcnt_t,
159 pub f_bavail: fsblkcnt_t,
160 pub f_files: fsfilcnt_t,
161 pub f_ffree: fsfilcnt_t,
162 pub f_favail: fsfilcnt_t,
163 pub f_fsid: ::c_ulong,
164 pub f_flag: ::c_ulong,
165 pub f_namemax: ::c_ulong,
166 }
167
168 pub struct sigset_t {
169 __val: [::c_ulong; 16],
170 }
171
172 pub struct sigaction {
173 pub sa_handler: extern fn(arg1: ::c_int),
174 pub sa_mask: sigset_t,
175 pub sa_flags: ::c_int,
176 }
177
178 pub struct dirent {
179 pub d_ino: ino_t,
180 pub d_type: ::c_uchar,
181 pub d_name: [::c_char; 256usize],
182 }
183
184 pub struct stack_t {
185 pub ss_sp: *mut ::c_void,
186 pub ss_flags: ::c_int,
187 pub ss_size: usize,
188 }
189
190 pub struct fd_set { // Unverified
191 fds_bits: [::c_ulong; FD_SETSIZE / ULONG_SIZE],
192 }
193
194 pub struct passwd { // Unverified
195 pub pw_name: *mut ::c_char,
196 pub pw_passwd: *mut ::c_char,
197 pub pw_uid: ::uid_t,
198 pub pw_gid: ::gid_t,
199 pub pw_gecos: *mut ::c_char,
200 pub pw_dir: *mut ::c_char,
201 pub pw_shell: *mut ::c_char,
202 }
203
204 pub struct termios { // Unverified
205 pub c_iflag: ::tcflag_t,
206 pub c_oflag: ::tcflag_t,
207 pub c_cflag: ::tcflag_t,
208 pub c_lflag: ::tcflag_t,
209 pub c_line: ::cc_t,
210 pub c_cc: [::cc_t; ::NCCS],
211 }
212
213 pub struct sem_t { // Unverified
214 __size: [::c_char; 16],
215 }
216
217 pub struct Dl_info { // Unverified
218 pub dli_fname: *const ::c_char,
219 pub dli_fbase: *mut ::c_void,
220 pub dli_sname: *const ::c_char,
221 pub dli_saddr: *mut ::c_void,
222 }
223
224 pub struct utsname { // Unverified
225 pub sysname: [::c_char; 65],
226 pub nodename: [::c_char; 65],
227 pub release: [::c_char; 65],
228 pub version: [::c_char; 65],
229 pub machine: [::c_char; 65],
230 pub domainname: [::c_char; 65]
231 }
232
233 pub struct cpu_set_t { // Unverified
234 bits: [u32; 32],
235 }
236
237 pub struct pthread_attr_t { // Unverified
238 __size: [u64; 7]
239 }
240
241 pub struct pthread_mutex_t { // Unverified
242 #[cfg(any(target_arch = "mips", target_arch = "arm",
243 target_arch = "powerpc"))]
244 __align: [::c_long; 0],
245 #[cfg(not(any(target_arch = "mips", target_arch = "arm",
246 target_arch = "powerpc")))]
247 __align: [::c_longlong; 0],
248 size: [u8; __SIZEOF_PTHREAD_MUTEX_T],
249 }
250
251 pub struct pthread_rwlock_t { // Unverified
252 #[cfg(any(target_arch = "mips", target_arch = "arm",
253 target_arch = "powerpc"))]
254 __align: [::c_long; 0],
255 #[cfg(not(any(target_arch = "mips", target_arch = "arm",
256 target_arch = "powerpc")))]
257 __align: [::c_longlong; 0],
258 size: [u8; __SIZEOF_PTHREAD_RWLOCK_T],
259 }
260
261 pub struct pthread_mutexattr_t { // Unverified
262 #[cfg(any(target_arch = "x86_64", target_arch = "powerpc64",
263 target_arch = "mips64", target_arch = "s390x",
264 target_arch = "sparc64"))]
265 __align: [::c_int; 0],
266 #[cfg(not(any(target_arch = "x86_64", target_arch = "powerpc64",
267 target_arch = "mips64", target_arch = "s390x",
268 target_arch = "sparc64")))]
269 __align: [::c_long; 0],
270 size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T],
271 }
272
273 pub struct pthread_rwlockattr_t { // Unverified
274 __lockkind: ::c_int,
275 __pshared: ::c_int,
276 }
277
278 pub struct pthread_cond_t { // Unverified
279 __align: [::c_longlong; 0],
280 size: [u8; __SIZEOF_PTHREAD_COND_T],
281 }
282
283 pub struct pthread_condattr_t { // Unverified
284 __align: [::c_int; 0],
285 size: [u8; __SIZEOF_PTHREAD_CONDATTR_T],
286 }
287
288}
289
290// unverified constants
291pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
292 __align: [],
293 size: [0; __SIZEOF_PTHREAD_MUTEX_T],
294};
295pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t {
296 __align: [],
297 size: [0; __SIZEOF_PTHREAD_COND_T],
298};
299pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t {
300 __align: [],
301 size: [0; __SIZEOF_PTHREAD_RWLOCK_T],
302};
303pub const NCCS: usize = 32;
304pub const __SIZEOF_PTHREAD_ATTR_T: usize = 56;
305pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40;
306pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4;
307pub const __SIZEOF_PTHREAD_COND_T: usize = 48;
308pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4;
309pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56;
310pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8;
311pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32;
312pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4;
313pub const __PTHREAD_MUTEX_HAVE_PREV: usize = 1;
314pub const __PTHREAD_RWLOCK_INT_FLAGS_SHARED: usize = 1;
315pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0;
316pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1;
317pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 2;
318pub const FD_SETSIZE: usize = 1024;
319// intentionally not public, only used for fd_set
320const ULONG_SIZE: usize = 32;
321
322// Other constants
323pub const EPERM: ::c_int = 1;
324pub const ENOENT: ::c_int = 2;
325pub const ESRCH: ::c_int = 3;
326pub const EINTR: ::c_int = 4;
327pub const EIO: ::c_int = 5;
328pub const ENXIO: ::c_int = 6;
329pub const E2BIG: ::c_int = 7;
330pub const ENOEXEC: ::c_int = 8;
331pub const EBADF: ::c_int = 9;
332pub const ECHILD: ::c_int = 10;
333pub const EAGAIN: ::c_int = 11;
334pub const ENOMEM: ::c_int = 12;
335pub const EACCES: ::c_int = 13;
336pub const EFAULT: ::c_int = 14;
337pub const EBUSY: ::c_int = 16;
338pub const EEXIST: ::c_int = 17;
339pub const EXDEV: ::c_int = 18;
340pub const ENODEV: ::c_int = 19;
341pub const ENOTDIR: ::c_int = 20;
342pub const EISDIR: ::c_int = 21;
343pub const EINVAL: ::c_int = 22;
344pub const ENFILE: ::c_int = 23;
345pub const EMFILE: ::c_int = 24;
346pub const ENOTTY: ::c_int = 25;
347pub const ETXTBSY: ::c_int = 26;
348pub const EFBIG: ::c_int = 27;
349pub const ENOSPC: ::c_int = 28;
350pub const ESPIPE: ::c_int = 29;
351pub const EROFS: ::c_int = 30;
352pub const EMLINK: ::c_int = 31;
353pub const EPIPE: ::c_int = 32;
354pub const EDOM: ::c_int = 33;
355pub const ERANGE: ::c_int = 34;
356pub const ENOMSG: ::c_int = 35;
357pub const EIDRM: ::c_int = 36;
358pub const EDEADLK: ::c_int = 45;
359pub const ENOLCK: ::c_int = 46;
360pub const ENOSTR: ::c_int = 60;
361pub const ENODATA: ::c_int = 61;
362pub const ETIME: ::c_int = 62;
363pub const ENOSR: ::c_int = 63;
364pub const ENOLINK: ::c_int = 67;
365pub const EPROTO: ::c_int = 71;
366pub const EMULTIHOP: ::c_int = 74;
367pub const EBADMSG: ::c_int = 77;
368pub const EFTYPE: ::c_int = 79;
369pub const ENOSYS: ::c_int = 88;
370pub const ENOTEMPTY: ::c_int = 90;
371pub const ENAMETOOLONG: ::c_int = 91;
372pub const ELOOP: ::c_int = 92;
373pub const EOPNOTSUPP: ::c_int = 95;
374pub const EPFNOSUPPORT: ::c_int = 96;
375pub const ECONNRESET: ::c_int = 104;
376pub const ENOBUFS: ::c_int = 105;
377pub const EAFNOSUPPORT: ::c_int = 106;
378pub const EPROTOTYPE: ::c_int = 107;
379pub const ENOTSOCK: ::c_int = 108;
380pub const ENOPROTOOPT: ::c_int = 109;
381pub const ECONNREFUSED: ::c_int = 111;
382pub const EADDRINUSE: ::c_int = 112;
383pub const ECONNABORTED: ::c_int = 113;
384pub const ENETUNREACH: ::c_int = 114;
385pub const ENETDOWN: ::c_int = 115;
386pub const ETIMEDOUT: ::c_int = 116;
387pub const EHOSTDOWN: ::c_int = 117;
388pub const EHOSTUNREACH: ::c_int = 118;
389pub const EINPROGRESS: ::c_int = 119;
390pub const EALREADY: ::c_int = 120;
391pub const EDESTADDRREQ: ::c_int = 121;
392pub const EMSGSIZE: ::c_int = 122;
393pub const EPROTONOSUPPORT: ::c_int = 123;
394pub const EADDRNOTAVAIL: ::c_int = 125;
395pub const ENETRESET: ::c_int = 126;
396pub const EISCONN: ::c_int = 127;
397pub const ENOTCONN: ::c_int = 128;
398pub const ETOOMANYREFS: ::c_int = 129;
399pub const EDQUOT: ::c_int = 132;
400pub const ESTALE: ::c_int = 133;
401pub const ENOTSUP: ::c_int = 134;
402pub const EILSEQ: ::c_int = 138;
403pub const EOVERFLOW: ::c_int = 139;
404pub const ECANCELED: ::c_int = 140;
405pub const ENOTRECOVERABLE: ::c_int = 141;
406pub const EOWNERDEAD: ::c_int = 142;
407pub const EWOULDBLOCK: ::c_int = 11;
408
409pub const F_DUPFD: ::c_int = 0;
410pub const F_GETFD: ::c_int = 1;
411pub const F_SETFD: ::c_int = 2;
412pub const F_GETFL: ::c_int = 3;
413pub const F_SETFL: ::c_int = 4;
414pub const F_GETOWN: ::c_int = 5;
415pub const F_SETOWN: ::c_int = 6;
416pub const F_GETLK: ::c_int = 7;
417pub const F_SETLK: ::c_int = 8;
418pub const F_SETLKW: ::c_int = 9;
419pub const F_RGETLK: ::c_int = 10;
420pub const F_RSETLK: ::c_int = 11;
421pub const F_CNVT: ::c_int = 12;
422pub const F_RSETLKW: ::c_int = 13;
423pub const F_DUPFD_CLOEXEC: ::c_int = 14;
424
425pub const O_RDONLY: ::c_int = 0;
426pub const O_WRONLY: ::c_int = 1;
427pub const O_RDWR: ::c_int = 2;
428pub const O_APPEND: ::c_int = 8;
429pub const O_CREAT: ::c_int = 512;
430pub const O_TRUNC: ::c_int = 1024;
431pub const O_EXCL: ::c_int = 2048;
432pub const O_SYNC: ::c_int = 8192;
433pub const O_NONBLOCK: ::c_int = 16384;
434
435pub const O_ACCMODE: ::c_int = 3;
436pub const O_CLOEXEC: ::c_int = 0x80000;
437
3b2f2976
XL
438pub const STDIN_FILENO: ::c_int = 0;
439pub const STDOUT_FILENO: ::c_int = 1;
440pub const STDERR_FILENO: ::c_int = 2;
441
442pub const SEEK_SET: ::c_int = 0;
443pub const SEEK_CUR: ::c_int = 1;
444pub const SEEK_END: ::c_int = 2;
445
446pub const FIONBIO: ::c_int = 1;
447
448pub const S_BLKSIZE: ::mode_t = 1024;
449pub const S_IREAD: ::mode_t = 256;
450pub const S_IWRITE: ::mode_t = 128;
451pub const S_IEXEC: ::mode_t = 64;
452pub const S_ENFMT: ::mode_t = 1024;
453pub const S_IFMT: ::mode_t = 61440;
454pub const S_IFDIR: ::mode_t = 16384;
455pub const S_IFCHR: ::mode_t = 8192;
456pub const S_IFBLK: ::mode_t = 24576;
457pub const S_IFREG: ::mode_t = 32768;
458pub const S_IFLNK: ::mode_t = 40960;
459pub const S_IFSOCK: ::mode_t = 49152;
460pub const S_IFIFO: ::mode_t = 4096;
461pub const S_IRUSR: ::mode_t = 256;
462pub const S_IWUSR: ::mode_t = 128;
463pub const S_IXUSR: ::mode_t = 64;
464pub const S_IRGRP: ::mode_t = 32;
465pub const S_IWGRP: ::mode_t = 16;
466pub const S_IXGRP: ::mode_t = 8;
467pub const S_IROTH: ::mode_t = 4;
468pub const S_IWOTH: ::mode_t = 2;
469pub const S_IXOTH: ::mode_t = 1;
470
471pub const SOL_SOCKET: ::c_int = 65535;
472pub const SOL_TCP: ::c_int = 6;
473
474pub const PF_UNSPEC: ::c_int = 0;
475pub const PF_INET: ::c_int = 2;
476pub const PF_INET6: ::c_int = 23;
477
478pub const AF_UNSPEC: ::c_int = 0;
479pub const AF_INET: ::c_int = 2;
480pub const AF_INET6: ::c_int = 23;
481
482pub const SOCK_STREAM: ::c_int = 1;
483pub const SOCK_DGRAM: ::c_int = 2;
484
485pub const MSG_OOB: ::c_int = 1;
486pub const MSG_PEEK: ::c_int = 2;
487pub const MSG_DONTWAIT: ::c_int = 4;
488pub const MSG_DONTROUTE: ::c_int = 0;
489pub const MSG_WAITALL: ::c_int = 0;
490pub const MSG_MORE: ::c_int = 0;
491pub const MSG_NOSIGNAL: ::c_int = 0;
492
493pub const SHUT_RD: ::c_int = 0;
494pub const SHUT_WR: ::c_int = 1;
495pub const SHUT_RDWR: ::c_int = 2;
496
497pub const SO_REUSEADDR: ::c_int = 4;
498pub const SO_LINGER: ::c_int = 128;
499pub const SO_OOBINLINE: ::c_int = 256;
500pub const SO_SNDBUF: ::c_int = 4097;
501pub const SO_RCVBUF: ::c_int = 4098;
502pub const SO_SNDLOWAT: ::c_int = 4099;
503pub const SO_RCVLOWAT: ::c_int = 4100;
504pub const SO_TYPE: ::c_int = 4104;
505pub const SO_ERROR: ::c_int = 4105;
506
507pub const SOCK_CLOEXEC: ::c_int = O_CLOEXEC;
508
509pub const INET_ADDRSTRLEN: ::c_int = 16;
510
511pub const IPPROTO_IP: ::c_int = 0;
512pub const IPPROTO_UDP: ::c_int = 17;
513pub const IPPROTO_TCP: ::c_int = 6;
514
515pub const TCP_NODELAY: ::c_int = 8193;
516pub const TCP_MAXSEG: ::c_int = 8194;
517
518pub const IP_TOS: ::c_int = 7;
519pub const IP_TTL: ::c_int = 8;
520pub const IP_MULTICAST_LOOP: ::c_int = 9;
521pub const IP_MULTICAST_TTL: ::c_int = 10;
522pub const IP_ADD_MEMBERSHIP: ::c_int = 11;
523pub const IP_DROP_MEMBERSHIP: ::c_int = 12;
524
525pub const HOST_NOT_FOUND: ::c_int = 1;
526pub const NO_DATA: ::c_int = 2;
527pub const NO_ADDRESS: ::c_int = 2;
528pub const NO_RECOVERY: ::c_int = 3;
529pub const TRY_AGAIN: ::c_int = 4;
530
531pub const AI_PASSIVE: ::c_int = 1;
532pub const AI_CANONNAME: ::c_int = 2;
533pub const AI_NUMERICHOST: ::c_int = 4;
534pub const AI_NUMERICSERV: ::c_int = 0;
535pub const AI_ADDRCONFIG: ::c_int = 0;
536
537pub const NI_MAXHOST: ::c_int = 1025;
538pub const NI_MAXSERV: ::c_int = 32;
539pub const NI_NOFQDN: ::c_int = 1;
540pub const NI_NUMERICHOST: ::c_int = 2;
541pub const NI_NAMEREQD: ::c_int = 4;
542pub const NI_NUMERICSERV: ::c_int = 0;
543pub const NI_DGRAM: ::c_int = 0;
544
545pub const EAI_FAMILY: ::c_int = -303;
546pub const EAI_MEMORY: ::c_int = -304;
547pub const EAI_NONAME: ::c_int = -305;
548pub const EAI_SOCKTYPE: ::c_int = -307;
549
550f! {
551 pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () {
552 let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8;
553 let fd = fd as usize;
554 (*set).fds_bits[fd / bits] &= !(1 << (fd % bits));
555 return
556 }
557
558 pub fn FD_ISSET(fd: ::c_int, set: *mut fd_set) -> bool {
559 let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8;
560 let fd = fd as usize;
561 return ((*set).fds_bits[fd / bits] & (1 << (fd % bits))) != 0
562 }
563
564 pub fn FD_SET(fd: ::c_int, set: *mut fd_set) -> () {
565 let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8;
566 let fd = fd as usize;
567 (*set).fds_bits[fd / bits] |= 1 << (fd % bits);
568 return
569 }
570
571 pub fn FD_ZERO(set: *mut fd_set) -> () {
572 for slot in (*set).fds_bits.iter_mut() {
573 *slot = 0;
574 }
575 }
576}
577
578extern {
579 pub fn bind(fd: ::c_int, addr: *const sockaddr, len: socklen_t) -> ::c_int;
580 pub fn closesocket(sockfd: ::c_int) -> ::c_int;
581 pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
582 pub fn recvfrom(fd: ::c_int, buf: *mut ::c_void, n: usize, flags: ::c_int,
583 addr: *mut sockaddr, addr_len: *mut socklen_t) -> isize;
584 pub fn getnameinfo(sa: *const sockaddr, salen: socklen_t,
585 host: *mut ::c_char, hostlen: socklen_t,
586 serv: *mut ::c_char, servlen: socklen_t,
587 flags: ::c_int) -> ::c_int;
588 pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void;
589 pub fn fexecve(fd: ::c_int, argv: *const *const ::c_char,
590 envp: *const *const ::c_char)
591 -> ::c_int;
592 #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrgid_r")]
593 pub fn getgrgid_r(uid: ::uid_t,
594 grp: *mut ::group,
595 buf: *mut ::c_char,
596 buflen: ::size_t,
597 result: *mut *mut ::group) -> ::c_int;
598 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
599 link_name = "sigaltstack$UNIX2003")]
600 #[cfg_attr(target_os = "netbsd", link_name = "__sigaltstack14")]
601 pub fn sigaltstack(ss: *const stack_t,
602 oss: *mut stack_t) -> ::c_int;
603 pub fn sem_close(sem: *mut sem_t) -> ::c_int;
604 pub fn getdtablesize() -> ::c_int;
605 #[cfg_attr(target_os = "solaris", link_name = "__posix_getgrnam_r")]
606 pub fn getgrnam_r(name: *const ::c_char,
607 grp: *mut ::group,
608 buf: *mut ::c_char,
609 buflen: ::size_t,
610 result: *mut *mut ::group) -> ::c_int;
611 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
612 link_name = "pthread_sigmask$UNIX2003")]
613 pub fn pthread_sigmask(how: ::c_int, set: *const sigset_t,
614 oldset: *mut sigset_t) -> ::c_int;
615 pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t;
616 pub fn getgrnam(name: *const ::c_char) -> *mut ::group;
617 pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int;
618 pub fn sem_unlink(name: *const ::c_char) -> ::c_int;
619 pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int;
620 #[cfg_attr(target_os = "netbsd", link_name = "__getpwnam_r50")]
621 #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwnam_r")]
622 pub fn getpwnam_r(name: *const ::c_char,
623 pwd: *mut passwd,
624 buf: *mut ::c_char,
625 buflen: ::size_t,
626 result: *mut *mut passwd) -> ::c_int;
627 #[cfg_attr(target_os = "netbsd", link_name = "__getpwuid_r50")]
628 #[cfg_attr(target_os = "solaris", link_name = "__posix_getpwuid_r")]
629 pub fn getpwuid_r(uid: ::uid_t,
630 pwd: *mut passwd,
631 buf: *mut ::c_char,
632 buflen: ::size_t,
633 result: *mut *mut passwd) -> ::c_int;
634 #[cfg_attr(all(target_os = "macos", target_arch ="x86"),
635 link_name = "sigwait$UNIX2003")]
636 #[cfg_attr(target_os = "solaris", link_name = "__posix_sigwait")]
637 pub fn sigwait(set: *const sigset_t,
638 sig: *mut ::c_int) -> ::c_int;
639 pub fn pthread_atfork(prepare: Option<unsafe extern fn()>,
640 parent: Option<unsafe extern fn()>,
641 child: Option<unsafe extern fn()>) -> ::c_int;
642 pub fn getgrgid(gid: ::gid_t) -> *mut ::group;
643 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
644 link_name = "popen$UNIX2003")]
645 pub fn popen(command: *const c_char,
646 mode: *const c_char) -> *mut ::FILE;
647}
648
649cfg_if! {
650 if #[cfg(target_arch = "arm")] {
651 mod arm;
652 pub use self::arm::*;
653 } else {
654 // Only tested on ARM so far. Other platforms might have different
655 // definitions for types and constants.
656 pub use target_arch_not_implemented;
657 }
658}