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