]> git.proxmox.com Git - rustc.git/blob - src/liblibc/src/unix/bsd/openbsdlike/mod.rs
Imported Upstream version 1.9.0+dfsg1
[rustc.git] / src / liblibc / src / unix / bsd / openbsdlike / mod.rs
1 pub type c_long = i64;
2 pub type c_ulong = u64;
3 pub type time_t = i64;
4 pub type mode_t = u32;
5 pub type nlink_t = ::uint32_t;
6 pub type ino_t = ::uint64_t;
7 pub type pthread_key_t = ::c_int;
8 pub type rlim_t = u64;
9 pub type speed_t = ::c_uint;
10 pub type tcflag_t = ::c_uint;
11 pub type clockid_t = ::c_int;
12
13 pub enum timezone {}
14
15 s! {
16 pub struct sigaction {
17 pub sa_sigaction: ::sighandler_t,
18 pub sa_mask: ::sigset_t,
19 pub sa_flags: ::c_int,
20 }
21
22 pub struct stack_t {
23 pub ss_sp: *mut ::c_void,
24 pub ss_size: ::size_t,
25 pub ss_flags: ::c_int,
26 }
27
28 pub struct sockaddr_in {
29 pub sin_len: u8,
30 pub sin_family: ::sa_family_t,
31 pub sin_port: ::in_port_t,
32 pub sin_addr: ::in_addr,
33 pub sin_zero: [::int8_t; 8],
34 }
35
36 pub struct termios {
37 pub c_iflag: ::tcflag_t,
38 pub c_oflag: ::tcflag_t,
39 pub c_cflag: ::tcflag_t,
40 pub c_lflag: ::tcflag_t,
41 pub c_cc: [::cc_t; ::NCCS],
42 pub c_ispeed: ::c_int,
43 pub c_ospeed: ::c_int,
44 }
45
46 pub struct flock {
47 pub l_start: ::off_t,
48 pub l_len: ::off_t,
49 pub l_pid: ::pid_t,
50 pub l_type: ::c_short,
51 pub l_whence: ::c_short,
52 }
53 }
54
55 pub const EXIT_FAILURE : ::c_int = 1;
56 pub const EXIT_SUCCESS : ::c_int = 0;
57 pub const RAND_MAX : ::c_int = 2147483647;
58 pub const EOF : ::c_int = -1;
59 pub const SEEK_SET : ::c_int = 0;
60 pub const SEEK_CUR : ::c_int = 1;
61 pub const SEEK_END : ::c_int = 2;
62 pub const _IOFBF : ::c_int = 0;
63 pub const _IONBF : ::c_int = 2;
64 pub const _IOLBF : ::c_int = 1;
65 pub const BUFSIZ : ::c_uint = 1024;
66 pub const FOPEN_MAX : ::c_uint = 20;
67 pub const FILENAME_MAX : ::c_uint = 1024;
68 pub const L_tmpnam : ::c_uint = 1024;
69 pub const O_RDONLY : ::c_int = 0;
70 pub const O_WRONLY : ::c_int = 1;
71 pub const O_RDWR : ::c_int = 2;
72 pub const O_ACCMODE : ::c_int = 3;
73 pub const O_APPEND : ::c_int = 8;
74 pub const O_CREAT : ::c_int = 512;
75 pub const O_EXCL : ::c_int = 2048;
76 pub const O_NOCTTY : ::c_int = 32768;
77 pub const O_TRUNC : ::c_int = 1024;
78 pub const O_SYNC : ::c_int = 128;
79 pub const S_IFIFO : mode_t = 4096;
80 pub const S_IFCHR : mode_t = 8192;
81 pub const S_IFBLK : mode_t = 24576;
82 pub const S_IFDIR : mode_t = 16384;
83 pub const S_IFREG : mode_t = 32768;
84 pub const S_IFLNK : mode_t = 40960;
85 pub const S_IFSOCK : mode_t = 49152;
86 pub const S_IFMT : mode_t = 61440;
87 pub const S_IEXEC : mode_t = 64;
88 pub const S_IWRITE : mode_t = 128;
89 pub const S_IREAD : mode_t = 256;
90 pub const S_IRWXU : mode_t = 448;
91 pub const S_IXUSR : mode_t = 64;
92 pub const S_IWUSR : mode_t = 128;
93 pub const S_IRUSR : mode_t = 256;
94 pub const S_IRWXG : mode_t = 56;
95 pub const S_IXGRP : mode_t = 8;
96 pub const S_IWGRP : mode_t = 16;
97 pub const S_IRGRP : mode_t = 32;
98 pub const S_IRWXO : mode_t = 7;
99 pub const S_IXOTH : mode_t = 1;
100 pub const S_IWOTH : mode_t = 2;
101 pub const S_IROTH : mode_t = 4;
102 pub const F_OK : ::c_int = 0;
103 pub const R_OK : ::c_int = 4;
104 pub const W_OK : ::c_int = 2;
105 pub const X_OK : ::c_int = 1;
106 pub const STDIN_FILENO : ::c_int = 0;
107 pub const STDOUT_FILENO : ::c_int = 1;
108 pub const STDERR_FILENO : ::c_int = 2;
109 pub const F_LOCK : ::c_int = 1;
110 pub const F_TEST : ::c_int = 3;
111 pub const F_TLOCK : ::c_int = 2;
112 pub const F_ULOCK : ::c_int = 0;
113 pub const F_GETLK: ::c_int = 7;
114 pub const F_SETLK: ::c_int = 8;
115 pub const F_SETLKW: ::c_int = 9;
116 pub const SIGHUP : ::c_int = 1;
117 pub const SIGINT : ::c_int = 2;
118 pub const SIGQUIT : ::c_int = 3;
119 pub const SIGILL : ::c_int = 4;
120 pub const SIGABRT : ::c_int = 6;
121 pub const SIGFPE : ::c_int = 8;
122 pub const SIGKILL : ::c_int = 9;
123 pub const SIGSEGV : ::c_int = 11;
124 pub const SIGPIPE : ::c_int = 13;
125 pub const SIGALRM : ::c_int = 14;
126 pub const SIGTERM : ::c_int = 15;
127 pub const SIGSTKSZ : ::size_t = 40960;
128
129 pub const PROT_NONE : ::c_int = 0;
130 pub const PROT_READ : ::c_int = 1;
131 pub const PROT_WRITE : ::c_int = 2;
132 pub const PROT_EXEC : ::c_int = 4;
133
134 pub const MAP_FILE : ::c_int = 0x0000;
135 pub const MAP_SHARED : ::c_int = 0x0001;
136 pub const MAP_PRIVATE : ::c_int = 0x0002;
137 pub const MAP_FIXED : ::c_int = 0x0010;
138 pub const MAP_ANON : ::c_int = 0x1000;
139
140 pub const MAP_FAILED : *mut ::c_void = !0 as *mut ::c_void;
141
142 pub const MCL_CURRENT : ::c_int = 0x0001;
143 pub const MCL_FUTURE : ::c_int = 0x0002;
144
145 pub const MS_ASYNC : ::c_int = 0x0001;
146
147 pub const EPERM : ::c_int = 1;
148 pub const ENOENT : ::c_int = 2;
149 pub const ESRCH : ::c_int = 3;
150 pub const EINTR : ::c_int = 4;
151 pub const EIO : ::c_int = 5;
152 pub const ENXIO : ::c_int = 6;
153 pub const E2BIG : ::c_int = 7;
154 pub const ENOEXEC : ::c_int = 8;
155 pub const EBADF : ::c_int = 9;
156 pub const ECHILD : ::c_int = 10;
157 pub const EDEADLK : ::c_int = 11;
158 pub const ENOMEM : ::c_int = 12;
159 pub const EACCES : ::c_int = 13;
160 pub const EFAULT : ::c_int = 14;
161 pub const ENOTBLK : ::c_int = 15;
162 pub const EBUSY : ::c_int = 16;
163 pub const EEXIST : ::c_int = 17;
164 pub const EXDEV : ::c_int = 18;
165 pub const ENODEV : ::c_int = 19;
166 pub const ENOTDIR : ::c_int = 20;
167 pub const EISDIR : ::c_int = 21;
168 pub const EINVAL : ::c_int = 22;
169 pub const ENFILE : ::c_int = 23;
170 pub const EMFILE : ::c_int = 24;
171 pub const ENOTTY : ::c_int = 25;
172 pub const ETXTBSY : ::c_int = 26;
173 pub const EFBIG : ::c_int = 27;
174 pub const ENOSPC : ::c_int = 28;
175 pub const ESPIPE : ::c_int = 29;
176 pub const EROFS : ::c_int = 30;
177 pub const EMLINK : ::c_int = 31;
178 pub const EPIPE : ::c_int = 32;
179 pub const EDOM : ::c_int = 33;
180 pub const ERANGE : ::c_int = 34;
181 pub const EAGAIN : ::c_int = 35;
182 pub const EWOULDBLOCK : ::c_int = 35;
183 pub const EINPROGRESS : ::c_int = 36;
184 pub const EALREADY : ::c_int = 37;
185 pub const ENOTSOCK : ::c_int = 38;
186 pub const EDESTADDRREQ : ::c_int = 39;
187 pub const EMSGSIZE : ::c_int = 40;
188 pub const EPROTOTYPE : ::c_int = 41;
189 pub const ENOPROTOOPT : ::c_int = 42;
190 pub const EPROTONOSUPPORT : ::c_int = 43;
191 pub const ESOCKTNOSUPPORT : ::c_int = 44;
192 pub const EOPNOTSUPP : ::c_int = 45;
193 pub const EPFNOSUPPORT : ::c_int = 46;
194 pub const EAFNOSUPPORT : ::c_int = 47;
195 pub const EADDRINUSE : ::c_int = 48;
196 pub const EADDRNOTAVAIL : ::c_int = 49;
197 pub const ENETDOWN : ::c_int = 50;
198 pub const ENETUNREACH : ::c_int = 51;
199 pub const ENETRESET : ::c_int = 52;
200 pub const ECONNABORTED : ::c_int = 53;
201 pub const ECONNRESET : ::c_int = 54;
202 pub const ENOBUFS : ::c_int = 55;
203 pub const EISCONN : ::c_int = 56;
204 pub const ENOTCONN : ::c_int = 57;
205 pub const ESHUTDOWN : ::c_int = 58;
206 pub const ETOOMANYREFS : ::c_int = 59;
207 pub const ETIMEDOUT : ::c_int = 60;
208 pub const ECONNREFUSED : ::c_int = 61;
209 pub const ELOOP : ::c_int = 62;
210 pub const ENAMETOOLONG : ::c_int = 63;
211 pub const EHOSTDOWN : ::c_int = 64;
212 pub const EHOSTUNREACH : ::c_int = 65;
213 pub const ENOTEMPTY : ::c_int = 66;
214 pub const EPROCLIM : ::c_int = 67;
215 pub const EUSERS : ::c_int = 68;
216 pub const EDQUOT : ::c_int = 69;
217 pub const ESTALE : ::c_int = 70;
218 pub const EREMOTE : ::c_int = 71;
219 pub const EBADRPC : ::c_int = 72;
220 pub const ERPCMISMATCH : ::c_int = 73;
221 pub const EPROGUNAVAIL : ::c_int = 74;
222 pub const EPROGMISMATCH : ::c_int = 75;
223 pub const EPROCUNAVAIL : ::c_int = 76;
224 pub const ENOLCK : ::c_int = 77;
225 pub const ENOSYS : ::c_int = 78;
226 pub const EFTYPE : ::c_int = 79;
227 pub const EAUTH : ::c_int = 80;
228 pub const ENEEDAUTH : ::c_int = 81;
229
230 pub const F_DUPFD : ::c_int = 0;
231 pub const F_GETFD : ::c_int = 1;
232 pub const F_SETFD : ::c_int = 2;
233 pub const F_GETFL : ::c_int = 3;
234 pub const F_SETFL : ::c_int = 4;
235
236 pub const SIGTRAP : ::c_int = 5;
237
238 pub const GLOB_APPEND : ::c_int = 0x0001;
239 pub const GLOB_DOOFFS : ::c_int = 0x0002;
240 pub const GLOB_ERR : ::c_int = 0x0004;
241 pub const GLOB_MARK : ::c_int = 0x0008;
242 pub const GLOB_NOCHECK : ::c_int = 0x0010;
243 pub const GLOB_NOSORT : ::c_int = 0x0020;
244 pub const GLOB_NOESCAPE : ::c_int = 0x1000;
245
246 pub const GLOB_NOSPACE : ::c_int = -1;
247 pub const GLOB_ABORTED : ::c_int = -2;
248 pub const GLOB_NOMATCH : ::c_int = -3;
249 pub const GLOB_NOSYS : ::c_int = -4;
250
251 pub const POSIX_MADV_NORMAL : ::c_int = 0;
252 pub const POSIX_MADV_RANDOM : ::c_int = 1;
253 pub const POSIX_MADV_SEQUENTIAL : ::c_int = 2;
254 pub const POSIX_MADV_WILLNEED : ::c_int = 3;
255 pub const POSIX_MADV_DONTNEED : ::c_int = 4;
256
257 pub const _SC_XOPEN_SHM : ::c_int = 30;
258
259 pub const PTHREAD_CREATE_JOINABLE : ::c_int = 0;
260 pub const PTHREAD_CREATE_DETACHED : ::c_int = 1;
261
262 // http://man.openbsd.org/OpenBSD-current/man2/clock_getres.2
263 // The man page says clock_gettime(3) can accept various values as clockid_t but
264 // http://fxr.watson.org/fxr/source/kern/kern_time.c?v=OPENBSD;im=excerpts#L161
265 // the implementation rejects anything other than the below two
266 //
267 // http://netbsd.gw.com/cgi-bin/man-cgi?clock_gettime
268 // https://github.com/jsonn/src/blob/HEAD/sys/kern/subr_time.c#L222
269 // Basically the same goes for NetBSD
270 pub const CLOCK_REALTIME: clockid_t = 0;
271 pub const CLOCK_MONOTONIC: clockid_t = 3;
272
273 pub const RLIMIT_CPU: ::c_int = 0;
274 pub const RLIMIT_FSIZE: ::c_int = 1;
275 pub const RLIMIT_DATA: ::c_int = 2;
276 pub const RLIMIT_STACK: ::c_int = 3;
277 pub const RLIMIT_CORE: ::c_int = 4;
278 pub const RLIMIT_RSS: ::c_int = 5;
279 pub const RLIMIT_MEMLOCK: ::c_int = 6;
280 pub const RLIMIT_NPROC: ::c_int = 7;
281 pub const RLIMIT_NOFILE: ::c_int = 8;
282
283 pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff;
284 pub const RLIM_SAVED_MAX: rlim_t = RLIM_INFINITY;
285 pub const RLIM_SAVED_CUR: rlim_t = RLIM_INFINITY;
286
287 pub const RUSAGE_SELF: ::c_int = 0;
288 pub const RUSAGE_CHILDREN: ::c_int = -1;
289
290 pub const MADV_NORMAL : ::c_int = 0;
291 pub const MADV_RANDOM : ::c_int = 1;
292 pub const MADV_SEQUENTIAL : ::c_int = 2;
293 pub const MADV_WILLNEED : ::c_int = 3;
294 pub const MADV_DONTNEED : ::c_int = 4;
295 pub const MADV_FREE : ::c_int = 6;
296
297 pub const AF_UNIX: ::c_int = 1;
298 pub const AF_INET: ::c_int = 2;
299 pub const AF_INET6: ::c_int = 24;
300 pub const SOCK_STREAM: ::c_int = 1;
301 pub const SOCK_DGRAM: ::c_int = 2;
302 pub const SOCK_RAW: ::c_int = 3;
303 pub const IPPROTO_TCP: ::c_int = 6;
304 pub const IPPROTO_IP: ::c_int = 0;
305 pub const IPPROTO_IPV6: ::c_int = 41;
306 pub const IP_MULTICAST_TTL: ::c_int = 10;
307 pub const IP_MULTICAST_LOOP: ::c_int = 11;
308 pub const IP_TTL: ::c_int = 4;
309 pub const IP_HDRINCL: ::c_int = 2;
310 pub const IP_ADD_MEMBERSHIP: ::c_int = 12;
311 pub const IP_DROP_MEMBERSHIP: ::c_int = 13;
312
313 pub const TCP_NODELAY: ::c_int = 0x01;
314 pub const SOL_SOCKET: ::c_int = 0xffff;
315 pub const SO_DEBUG: ::c_int = 0x01;
316 pub const SO_ACCEPTCONN: ::c_int = 0x0002;
317 pub const SO_REUSEADDR: ::c_int = 0x0004;
318 pub const SO_KEEPALIVE: ::c_int = 0x0008;
319 pub const SO_DONTROUTE: ::c_int = 0x0010;
320 pub const SO_BROADCAST: ::c_int = 0x0020;
321 pub const SO_USELOOPBACK: ::c_int = 0x0040;
322 pub const SO_LINGER: ::c_int = 0x0080;
323 pub const SO_OOBINLINE: ::c_int = 0x0100;
324 pub const SO_REUSEPORT: ::c_int = 0x0200;
325 pub const SO_SNDBUF: ::c_int = 0x1001;
326 pub const SO_RCVBUF: ::c_int = 0x1002;
327 pub const SO_SNDLOWAT: ::c_int = 0x1003;
328 pub const SO_RCVLOWAT: ::c_int = 0x1004;
329 pub const SO_ERROR: ::c_int = 0x1007;
330 pub const SO_TYPE: ::c_int = 0x1008;
331
332 pub const IFF_LOOPBACK: ::c_int = 0x8;
333
334 pub const SHUT_RD: ::c_int = 0;
335 pub const SHUT_WR: ::c_int = 1;
336 pub const SHUT_RDWR: ::c_int = 2;
337
338 pub const LOCK_SH: ::c_int = 1;
339 pub const LOCK_EX: ::c_int = 2;
340 pub const LOCK_NB: ::c_int = 4;
341 pub const LOCK_UN: ::c_int = 8;
342
343 pub const O_NONBLOCK : ::c_int = 4;
344 pub const CTL_KERN : ::c_int = 1;
345
346 pub const IPPROTO_RAW : ::c_int = 255;
347
348 pub const _SC_ARG_MAX : ::c_int = 1;
349 pub const _SC_CHILD_MAX : ::c_int = 2;
350 pub const _SC_NGROUPS_MAX : ::c_int = 4;
351 pub const _SC_OPEN_MAX : ::c_int = 5;
352 pub const _SC_JOB_CONTROL : ::c_int = 6;
353 pub const _SC_SAVED_IDS : ::c_int = 7;
354 pub const _SC_VERSION : ::c_int = 8;
355 pub const _SC_BC_BASE_MAX : ::c_int = 9;
356 pub const _SC_BC_DIM_MAX : ::c_int = 10;
357 pub const _SC_BC_SCALE_MAX : ::c_int = 11;
358 pub const _SC_BC_STRING_MAX : ::c_int = 12;
359 pub const _SC_COLL_WEIGHTS_MAX : ::c_int = 13;
360 pub const _SC_EXPR_NEST_MAX : ::c_int = 14;
361 pub const _SC_LINE_MAX : ::c_int = 15;
362 pub const _SC_RE_DUP_MAX : ::c_int = 16;
363 pub const _SC_2_VERSION : ::c_int = 17;
364 pub const _SC_2_C_BIND : ::c_int = 18;
365 pub const _SC_2_C_DEV : ::c_int = 19;
366 pub const _SC_2_CHAR_TERM : ::c_int = 20;
367 pub const _SC_2_FORT_DEV : ::c_int = 21;
368 pub const _SC_2_FORT_RUN : ::c_int = 22;
369 pub const _SC_2_LOCALEDEF : ::c_int = 23;
370 pub const _SC_2_SW_DEV : ::c_int = 24;
371 pub const _SC_2_UPE : ::c_int = 25;
372 pub const _SC_STREAM_MAX : ::c_int = 26;
373 pub const _SC_TZNAME_MAX : ::c_int = 27;
374 pub const _SC_PAGESIZE : ::c_int = 28;
375 pub const _SC_PAGE_SIZE: ::c_int = _SC_PAGESIZE;
376 pub const _SC_FSYNC : ::c_int = 29;
377
378 pub const KERN_PROC_ARGV: ::c_int = 1;
379 pub const KERN_PROC_NARGV: ::c_int = 2;
380 pub const KERN_PROC_ENV: ::c_int = 3;
381 pub const KERN_PROC_NENV: ::c_int = 4;
382
383 pub const Q_GETQUOTA: ::c_int = 0x300;
384 pub const Q_SETQUOTA: ::c_int = 0x400;
385
386 pub const RTLD_GLOBAL: ::c_int = 0x100;
387
388 #[link(name = "util")]
389 extern {
390 pub fn mincore(addr: *mut ::c_void, len: ::size_t,
391 vec: *mut ::c_char) -> ::c_int;
392 #[cfg_attr(target_os = "netbsd", link_name = "__clock_getres50")]
393 pub fn clock_getres(clk_id: clockid_t, tp: *mut ::timespec) -> ::c_int;
394 #[cfg_attr(target_os = "netbsd", link_name = "__clock_gettime50")]
395 pub fn clock_gettime(clk_id: clockid_t, tp: *mut ::timespec) -> ::c_int;
396 pub fn __errno() -> *mut ::c_int;
397 pub fn shm_open(name: *const ::c_char, oflag: ::c_int, mode: ::mode_t)
398 -> ::c_int;
399 pub fn memrchr(cx: *const ::c_void,
400 c: ::c_int,
401 n: ::size_t) -> *mut ::c_void;
402 pub fn mkostemp(template: *mut ::c_char, flags: ::c_int) -> ::c_int;
403 pub fn mkostemps(template: *mut ::c_char,
404 suffixlen: ::c_int,
405 flags: ::c_int) -> ::c_int;
406 pub fn futimens(fd: ::c_int, times: *const ::timespec) -> ::c_int;
407 pub fn fdatasync(fd: ::c_int) -> ::c_int;
408 pub fn openpty(amaster: *mut ::c_int,
409 aslave: *mut ::c_int,
410 name: *mut ::c_char,
411 termp: *mut termios,
412 winp: *mut ::winsize) -> ::c_int;
413 pub fn forkpty(amaster: *mut ::c_int,
414 name: *mut ::c_char,
415 termp: *mut termios,
416 winp: *mut ::winsize) -> ::pid_t;
417 }
418
419 cfg_if! {
420 if #[cfg(target_os = "bitrig")] {
421 mod bitrig;
422 pub use self::bitrig::*;
423 } else if #[cfg(target_os = "netbsd")] {
424 mod netbsd;
425 pub use self::netbsd::*;
426 } else if #[cfg(target_os = "openbsd")] {
427 mod openbsd;
428 pub use self::openbsd::*;
429 } else {
430 // Unknown target_os
431 }
432 }