]>
git.proxmox.com Git - rustc.git/blob - src/vendor/libc/src/unix/bsd/mod.rs
1 use dox
::{mem, Option}
;
4 pub type wchar_t
= i32;
6 pub type useconds_t
= u32;
7 pub type blkcnt_t
= i64;
8 pub type socklen_t
= u32;
9 pub type sa_family_t
= u8;
10 pub type pthread_t
= ::uintptr_t
;
11 pub type nfds_t
= ::c_uint
;
16 pub sa_family
: sa_family_t
,
17 pub sa_data
: [::c_char
; 14],
20 pub struct sockaddr_in6
{
22 pub sin6_family
: sa_family_t
,
23 pub sin6_port
: ::in_port_t
,
24 pub sin6_flowinfo
: u32,
25 pub sin6_addr
: ::in6_addr
,
26 pub sin6_scope_id
: u32,
29 pub struct sockaddr_un
{
31 pub sun_family
: sa_family_t
,
32 pub sun_path
: [c_char
; 104]
36 pub pw_name
: *mut ::c_char
,
37 pub pw_passwd
: *mut ::c_char
,
40 pub pw_change
: ::time_t
,
41 pub pw_class
: *mut ::c_char
,
42 pub pw_gecos
: *mut ::c_char
,
43 pub pw_dir
: *mut ::c_char
,
44 pub pw_shell
: *mut ::c_char
,
45 pub pw_expire
: ::time_t
,
47 #[cfg(not(any(target_os = "macos",
50 target_os
= "openbsd")))]
51 pub pw_fields
: ::c_int
,
55 pub ifa_next
: *mut ifaddrs
,
56 pub ifa_name
: *mut ::c_char
,
57 pub ifa_flags
: ::c_uint
,
58 pub ifa_addr
: *mut ::sockaddr
,
59 pub ifa_netmask
: *mut ::sockaddr
,
60 pub ifa_dstaddr
: *mut ::sockaddr
,
61 pub ifa_data
: *mut ::c_void
65 #[cfg(all(target_pointer_width = "64",
66 any(target_os
= "freebsd", target_os
= "dragonfly")))]
67 fds_bits
: [i64; FD_SETSIZE
/ 64],
68 #[cfg(not(all(target_pointer_width = "64",
69 any(target_os
= "freebsd", target_os
= "dragonfly"))))]
70 fds_bits
: [i32; FD_SETSIZE
/ 32],
82 pub tm_isdst
: ::c_int
,
83 pub tm_gmtoff
: ::c_long
,
84 pub tm_zone
: *mut ::c_char
,
88 #[cfg(not(target_os = "dragonfly"))]
89 pub sysname
: [::c_char
; 256],
90 #[cfg(target_os = "dragonfly")]
91 pub sysname
: [::c_char
; 32],
92 #[cfg(not(target_os = "dragonfly"))]
93 pub nodename
: [::c_char
; 256],
94 #[cfg(target_os = "dragonfly")]
95 pub nodename
: [::c_char
; 32],
96 #[cfg(not(target_os = "dragonfly"))]
97 pub release
: [::c_char
; 256],
98 #[cfg(target_os = "dragonfly")]
99 pub release
: [::c_char
; 32],
100 #[cfg(not(target_os = "dragonfly"))]
101 pub version
: [::c_char
; 256],
102 #[cfg(target_os = "dragonfly")]
103 pub version
: [::c_char
; 32],
104 #[cfg(not(target_os = "dragonfly"))]
105 pub machine
: [::c_char
; 256],
106 #[cfg(target_os = "dragonfly")]
107 pub machine
: [::c_char
; 32],
111 pub msg_name
: *mut ::c_void
,
112 pub msg_namelen
: ::socklen_t
,
113 pub msg_iov
: *mut ::iovec
,
114 pub msg_iovlen
: ::c_int
,
115 pub msg_control
: *mut ::c_void
,
116 pub msg_controllen
: ::socklen_t
,
117 pub msg_flags
: ::c_int
,
121 pub cmsg_len
: ::socklen_t
,
122 pub cmsg_level
: ::c_int
,
123 pub cmsg_type
: ::c_int
,
127 __fsid_val
: [::int32_t
; 2],
130 pub struct if_nameindex
{
131 pub if_index
: ::c_uint
,
132 pub if_name
: *mut ::c_char
,
136 pub const LC_ALL
: ::c_int
= 0;
137 pub const LC_COLLATE
: ::c_int
= 1;
138 pub const LC_CTYPE
: ::c_int
= 2;
139 pub const LC_MONETARY
: ::c_int
= 3;
140 pub const LC_NUMERIC
: ::c_int
= 4;
141 pub const LC_TIME
: ::c_int
= 5;
142 pub const LC_MESSAGES
: ::c_int
= 6;
144 pub const FIOCLEX
: ::c_ulong
= 0x20006601;
145 pub const FIONBIO
: ::c_ulong
= 0x8004667e;
147 pub const PATH_MAX
: ::c_int
= 1024;
149 pub const SA_ONSTACK
: ::c_int
= 0x0001;
150 pub const SA_SIGINFO
: ::c_int
= 0x0040;
151 pub const SA_RESTART
: ::c_int
= 0x0002;
152 pub const SA_RESETHAND
: ::c_int
= 0x0004;
153 pub const SA_NOCLDSTOP
: ::c_int
= 0x0008;
154 pub const SA_NODEFER
: ::c_int
= 0x0010;
155 pub const SA_NOCLDWAIT
: ::c_int
= 0x0020;
157 pub const SS_ONSTACK
: ::c_int
= 1;
158 pub const SS_DISABLE
: ::c_int
= 4;
160 pub const SIGCHLD
: ::c_int
= 20;
161 pub const SIGBUS
: ::c_int
= 10;
162 pub const SIGUSR1
: ::c_int
= 30;
163 pub const SIGUSR2
: ::c_int
= 31;
164 pub const SIGCONT
: ::c_int
= 19;
165 pub const SIGSTOP
: ::c_int
= 17;
166 pub const SIGTSTP
: ::c_int
= 18;
167 pub const SIGURG
: ::c_int
= 16;
168 pub const SIGIO
: ::c_int
= 23;
169 pub const SIGSYS
: ::c_int
= 12;
170 pub const SIGTTIN
: ::c_int
= 21;
171 pub const SIGTTOU
: ::c_int
= 22;
172 pub const SIGXCPU
: ::c_int
= 24;
173 pub const SIGXFSZ
: ::c_int
= 25;
174 pub const SIGVTALRM
: ::c_int
= 26;
175 pub const SIGPROF
: ::c_int
= 27;
176 pub const SIGWINCH
: ::c_int
= 28;
177 pub const SIGINFO
: ::c_int
= 29;
179 pub const SIG_SETMASK
: ::c_int
= 3;
180 pub const SIG_BLOCK
: ::c_int
= 0x1;
181 pub const SIG_UNBLOCK
: ::c_int
= 0x2;
183 pub const IPV6_MULTICAST_LOOP
: ::c_int
= 11;
184 pub const IPV6_V6ONLY
: ::c_int
= 27;
186 pub const ST_RDONLY
: ::c_ulong
= 1;
188 pub const NCCS
: usize = 20;
190 pub const O_ACCMODE
: ::c_int
= 0x3;
191 pub const O_RDONLY
: ::c_int
= 0;
192 pub const O_WRONLY
: ::c_int
= 1;
193 pub const O_RDWR
: ::c_int
= 2;
194 pub const O_APPEND
: ::c_int
= 8;
195 pub const O_CREAT
: ::c_int
= 512;
196 pub const O_TRUNC
: ::c_int
= 1024;
197 pub const O_EXCL
: ::c_int
= 2048;
198 pub const O_ASYNC
: ::c_int
= 0x40;
199 pub const O_SYNC
: ::c_int
= 0x80;
200 pub const O_NONBLOCK
: ::c_int
= 0x4;
201 pub const O_NOFOLLOW
: ::c_int
= 0x100;
202 pub const O_SHLOCK
: ::c_int
= 0x10;
203 pub const O_EXLOCK
: ::c_int
= 0x20;
204 pub const O_FSYNC
: ::c_int
= O_SYNC
;
205 pub const O_NDELAY
: ::c_int
= O_NONBLOCK
;
207 pub const F_GETOWN
: ::c_int
= 5;
208 pub const F_SETOWN
: ::c_int
= 6;
210 pub const MNT_FORCE
: ::c_int
= 0x80000;
212 pub const Q_SYNC
: ::c_int
= 0x600;
213 pub const Q_QUOTAON
: ::c_int
= 0x100;
214 pub const Q_QUOTAOFF
: ::c_int
= 0x200;
216 pub const TCIOFF
: ::c_int
= 3;
217 pub const TCION
: ::c_int
= 4;
218 pub const TCOOFF
: ::c_int
= 1;
219 pub const TCOON
: ::c_int
= 2;
220 pub const TCIFLUSH
: ::c_int
= 1;
221 pub const TCOFLUSH
: ::c_int
= 2;
222 pub const TCIOFLUSH
: ::c_int
= 3;
223 pub const TCSANOW
: ::c_int
= 0;
224 pub const TCSADRAIN
: ::c_int
= 1;
225 pub const TCSAFLUSH
: ::c_int
= 2;
226 pub const VEOF
: usize = 0;
227 pub const VEOL
: usize = 1;
228 pub const VEOL2
: usize = 2;
229 pub const VERASE
: usize = 3;
230 pub const VWERASE
: usize = 4;
231 pub const VKILL
: usize = 5;
232 pub const VREPRINT
: usize = 6;
233 pub const VINTR
: usize = 8;
234 pub const VQUIT
: usize = 9;
235 pub const VSUSP
: usize = 10;
236 pub const VDSUSP
: usize = 11;
237 pub const VSTART
: usize = 12;
238 pub const VSTOP
: usize = 13;
239 pub const VLNEXT
: usize = 14;
240 pub const VDISCARD
: usize = 15;
241 pub const VMIN
: usize = 16;
242 pub const VTIME
: usize = 17;
243 pub const VSTATUS
: usize = 18;
244 pub const _POSIX_VDISABLE
: ::cc_t
= 0xff;
245 pub const IGNBRK
: ::tcflag_t
= 0x00000001;
246 pub const BRKINT
: ::tcflag_t
= 0x00000002;
247 pub const IGNPAR
: ::tcflag_t
= 0x00000004;
248 pub const PARMRK
: ::tcflag_t
= 0x00000008;
249 pub const INPCK
: ::tcflag_t
= 0x00000010;
250 pub const ISTRIP
: ::tcflag_t
= 0x00000020;
251 pub const INLCR
: ::tcflag_t
= 0x00000040;
252 pub const IGNCR
: ::tcflag_t
= 0x00000080;
253 pub const ICRNL
: ::tcflag_t
= 0x00000100;
254 pub const IXON
: ::tcflag_t
= 0x00000200;
255 pub const IXOFF
: ::tcflag_t
= 0x00000400;
256 pub const IXANY
: ::tcflag_t
= 0x00000800;
257 pub const IMAXBEL
: ::tcflag_t
= 0x00002000;
258 pub const OPOST
: ::tcflag_t
= 0x1;
259 pub const ONLCR
: ::tcflag_t
= 0x2;
260 pub const OXTABS
: ::tcflag_t
= 0x4;
261 pub const ONOEOT
: ::tcflag_t
= 0x8;
262 pub const CIGNORE
: ::tcflag_t
= 0x00000001;
263 pub const CSIZE
: ::tcflag_t
= 0x00000300;
264 pub const CS5
: ::tcflag_t
= 0x00000000;
265 pub const CS6
: ::tcflag_t
= 0x00000100;
266 pub const CS7
: ::tcflag_t
= 0x00000200;
267 pub const CS8
: ::tcflag_t
= 0x00000300;
268 pub const CSTOPB
: ::tcflag_t
= 0x00000400;
269 pub const CREAD
: ::tcflag_t
= 0x00000800;
270 pub const PARENB
: ::tcflag_t
= 0x00001000;
271 pub const PARODD
: ::tcflag_t
= 0x00002000;
272 pub const HUPCL
: ::tcflag_t
= 0x00004000;
273 pub const CLOCAL
: ::tcflag_t
= 0x00008000;
274 pub const ECHOKE
: ::tcflag_t
= 0x00000001;
275 pub const ECHOE
: ::tcflag_t
= 0x00000002;
276 pub const ECHOK
: ::tcflag_t
= 0x00000004;
277 pub const ECHO
: ::tcflag_t
= 0x00000008;
278 pub const ECHONL
: ::tcflag_t
= 0x00000010;
279 pub const ECHOPRT
: ::tcflag_t
= 0x00000020;
280 pub const ECHOCTL
: ::tcflag_t
= 0x00000040;
281 pub const ISIG
: ::tcflag_t
= 0x00000080;
282 pub const ICANON
: ::tcflag_t
= 0x00000100;
283 pub const ALTWERASE
: ::tcflag_t
= 0x00000200;
284 pub const IEXTEN
: ::tcflag_t
= 0x00000400;
285 pub const EXTPROC
: ::tcflag_t
= 0x00000800;
286 pub const TOSTOP
: ::tcflag_t
= 0x00400000;
287 pub const FLUSHO
: ::tcflag_t
= 0x00800000;
288 pub const NOKERNINFO
: ::tcflag_t
= 0x02000000;
289 pub const PENDIN
: ::tcflag_t
= 0x20000000;
290 pub const NOFLSH
: ::tcflag_t
= 0x80000000;
291 pub const MDMBUF
: ::tcflag_t
= 0x00100000;
293 pub const WNOHANG
: ::c_int
= 0x00000001;
294 pub const WUNTRACED
: ::c_int
= 0x00000002;
296 pub const RTLD_NOW
: ::c_int
= 0x2;
297 pub const RTLD_NEXT
: *mut ::c_void
= -1isize
as *mut ::c_void
;
298 pub const RTLD_DEFAULT
: *mut ::c_void
= -2isize
as *mut ::c_void
;
299 pub const RTLD_SELF
: *mut ::c_void
= -3isize
as *mut ::c_void
;
301 pub const LOG_CRON
: ::c_int
= 9 << 3;
302 pub const LOG_AUTHPRIV
: ::c_int
= 10 << 3;
303 pub const LOG_FTP
: ::c_int
= 11 << 3;
304 pub const LOG_PERROR
: ::c_int
= 0x20;
306 pub const PIPE_BUF
: usize = 512;
309 pub fn FD_CLR(fd
: ::c_int
, set
: *mut fd_set
) -> () {
310 let bits
= mem
::size_of_val(&(*set
).fds_bits
[0]) * 8;
311 let fd
= fd
as usize;
312 (*set
).fds_bits
[fd
/ bits
] &= !(1 << (fd
% bits
));
316 pub fn FD_ISSET(fd
: ::c_int
, set
: *mut fd_set
) -> bool
{
317 let bits
= mem
::size_of_val(&(*set
).fds_bits
[0]) * 8;
318 let fd
= fd
as usize;
319 return ((*set
).fds_bits
[fd
/ bits
] & (1 << (fd
% bits
))) != 0
322 pub fn FD_SET(fd
: ::c_int
, set
: *mut fd_set
) -> () {
323 let bits
= mem
::size_of_val(&(*set
).fds_bits
[0]) * 8;
324 let fd
= fd
as usize;
325 (*set
).fds_bits
[fd
/ bits
] |= 1 << (fd
% bits
);
329 pub fn FD_ZERO(set
: *mut fd_set
) -> () {
330 for slot
in (*set
).fds_bits
.iter_mut() {
335 pub fn WTERMSIG(status
: ::c_int
) -> ::c_int
{
339 pub fn WIFEXITED(status
: ::c_int
) -> bool
{
340 (status
& 0o177) == 0
343 pub fn WEXITSTATUS(status
: ::c_int
) -> ::c_int
{
347 pub fn WCOREDUMP(status
: ::c_int
) -> bool
{
348 (status
& 0o200) != 0
353 pub fn getifaddrs(ifap
: *mut *mut ::ifaddrs
) -> ::c_int
;
354 pub fn freeifaddrs(ifa
: *mut ::ifaddrs
);
355 pub fn setgroups(ngroups
: ::c_int
,
356 ptr
: *const ::gid_t
) -> ::c_int
;
357 pub fn ioctl(fd
: ::c_int
, request
: ::c_ulong
, ...) -> ::c_int
;
358 pub fn kqueue() -> ::c_int
;
359 pub fn unmount(target
: *const ::c_char
, arg
: ::c_int
) -> ::c_int
;
360 pub fn syscall(num
: ::c_int
, ...) -> ::c_int
;
361 #[cfg_attr(target_os = "netbsd", link_name = "__getpwnam_r50")]
362 pub fn getpwnam_r(name
: *const ::c_char
,
366 result
: *mut *mut passwd
) -> ::c_int
;
367 #[cfg_attr(target_os = "netbsd", link_name = "__getpwuid_r50")]
368 pub fn getpwuid_r(uid
: ::uid_t
,
372 result
: *mut *mut passwd
) -> ::c_int
;
373 #[cfg_attr(target_os = "netbsd", link_name = "__getpwent50")]
374 pub fn getpwent() -> *mut passwd
;
376 pub fn getprogname() -> *const ::c_char
;
377 pub fn setprogname(name
: *const ::c_char
);
378 pub fn getloadavg(loadavg
: *mut ::c_double
, nelem
: ::c_int
) -> ::c_int
;
379 pub fn if_nameindex() -> *mut if_nameindex
;
380 pub fn if_freenameindex(ptr
: *mut if_nameindex
);
382 pub fn getpeereid(socket
: ::c_int
,
384 egid
: *mut ::gid_t
) -> ::c_int
;
386 #[cfg_attr(target_os = "macos", link_name = "glob$INODE64")]
387 #[cfg_attr(target_os = "netbsd", link_name = "__glob30")]
388 pub fn glob(pattern
: *const ::c_char
,
390 errfunc
: Option
<extern fn(epath
: *const ::c_char
,
391 errno
: ::c_int
) -> ::c_int
>,
392 pglob
: *mut ::glob_t
) -> ::c_int
;
393 #[cfg_attr(target_os = "netbsd", link_name = "__globfree30")]
394 pub fn globfree(pglob
: *mut ::glob_t
);
396 pub fn posix_madvise(addr
: *mut ::c_void
, len
: ::size_t
, advice
: ::c_int
)
399 pub fn shm_unlink(name
: *const ::c_char
) -> ::c_int
;
401 #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
402 link_name
= "seekdir$INODE64")]
403 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
404 link_name
= "seekdir$INODE64$UNIX2003")]
405 pub fn seekdir(dirp
: *mut ::DIR
, loc
: ::c_long
);
407 #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
408 link_name
= "telldir$INODE64")]
409 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
410 link_name
= "telldir$INODE64$UNIX2003")]
411 pub fn telldir(dirp
: *mut ::DIR
) -> ::c_long
;
412 pub fn madvise(addr
: *mut ::c_void
, len
: ::size_t
, advice
: ::c_int
)
415 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
416 link_name
= "msync$UNIX2003")]
417 #[cfg_attr(target_os = "netbsd", link_name = "__msync13")]
418 pub fn msync(addr
: *mut ::c_void
, len
: ::size_t
, flags
: ::c_int
) -> ::c_int
;
420 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
421 link_name
= "recvfrom$UNIX2003")]
422 pub fn recvfrom(socket
: ::c_int
, buf
: *mut ::c_void
, len
: ::size_t
,
423 flags
: ::c_int
, addr
: *mut ::sockaddr
,
424 addrlen
: *mut ::socklen_t
) -> ::ssize_t
;
425 pub fn mkstemps(template
: *mut ::c_char
, suffixlen
: ::c_int
) -> ::c_int
;
426 pub fn futimes(fd
: ::c_int
, times
: *const ::timeval
) -> ::c_int
;
427 pub fn nl_langinfo(item
: ::nl_item
) -> *mut ::c_char
;
429 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
430 link_name
= "bind$UNIX2003")]
431 pub fn bind(socket
: ::c_int
, address
: *const ::sockaddr
,
432 address_len
: ::socklen_t
) -> ::c_int
;
434 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
435 link_name
= "writev$UNIX2003")]
436 pub fn writev(fd
: ::c_int
,
438 iovcnt
: ::c_int
) -> ::ssize_t
;
439 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
440 link_name
= "readv$UNIX2003")]
441 pub fn readv(fd
: ::c_int
,
443 iovcnt
: ::c_int
) -> ::ssize_t
;
445 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
446 link_name
= "sendmsg$UNIX2003")]
447 pub fn sendmsg(fd
: ::c_int
,
448 msg
: *const ::msghdr
,
449 flags
: ::c_int
) -> ::ssize_t
;
450 #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
451 link_name
= "recvmsg$UNIX2003")]
452 pub fn recvmsg(fd
: ::c_int
, msg
: *mut ::msghdr
, flags
: ::c_int
)
459 if #[cfg(any(target_os = "macos", target_os = "ios"))] {
461 pub use self::apple
::*;
462 } else if #[cfg(any(target_os = "openbsd", target_os = "netbsd",
463 target_os
= "bitrig"))] {
465 pub use self::netbsdlike
::*;
466 } else if #[cfg(any(target_os = "freebsd", target_os = "dragonfly"))] {
468 pub use self::freebsdlike
::*;