aboutsummaryrefslogtreecommitdiff
path: root/libc/src
diff options
context:
space:
mode:
Diffstat (limited to 'libc/src')
-rw-r--r--libc/src/redox/mod.rs110
-rw-r--r--libc/src/unix/bsd/apple/mod.rs1
-rw-r--r--libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs1
-rw-r--r--libc/src/unix/bsd/freebsdlike/freebsd/mod.rs20
-rw-r--r--libc/src/unix/bsd/netbsdlike/mod.rs1
-rw-r--r--libc/src/unix/bsd/netbsdlike/netbsd/mod.rs14
-rw-r--r--libc/src/unix/haiku/mod.rs1
-rw-r--r--libc/src/unix/hermit/mod.rs1
-rw-r--r--libc/src/unix/mod.rs1
-rw-r--r--libc/src/unix/newlib/mod.rs1
-rw-r--r--libc/src/unix/notbsd/linux/other/b32/x86.rs21
-rw-r--r--libc/src/unix/notbsd/linux/other/b64/x86_64.rs25
-rw-r--r--libc/src/unix/notbsd/mod.rs1
-rw-r--r--libc/src/unix/solaris/mod.rs1
-rw-r--r--libc/src/unix/uclibc/mod.rs1
15 files changed, 191 insertions, 9 deletions
diff --git a/libc/src/redox/mod.rs b/libc/src/redox/mod.rs
index 9f68632..8dabd90 100644
--- a/libc/src/redox/mod.rs
+++ b/libc/src/redox/mod.rs
@@ -1,4 +1,3 @@
-
pub type int8_t = i8;
pub type int16_t = i16;
pub type int32_t = i32;
@@ -31,18 +30,66 @@ pub type c_char = i8;
pub type c_long = i64;
pub type c_ulong = u64;
-pub type wchar_t = i16;
+pub type wchar_t = i32;
+pub type wint_t = u32;
+pub type wctype_t = i64;
+pub type regoff_t = size_t;
pub type off_t = c_long;
-pub type mode_t = u16;
-pub type time_t = i64;
-pub type pid_t = usize;
-pub type gid_t = usize;
-pub type uid_t = usize;
+pub type mode_t = c_int;
+pub type time_t = c_long;
+pub type pid_t = c_int;
+pub type id_t = c_uint;
+pub type gid_t = c_int;
+pub type uid_t = c_int;
+pub type dev_t = c_long;
+pub type ino_t = c_ulong;
+pub type nlink_t = c_ulong;
+pub type blksize_t = c_long;
+pub type blkcnt_t = c_ulong;
+
+pub type fsblkcnt_t = c_ulong;
+pub type fsfilcnt_t = c_ulong;
+
+pub type useconds_t = c_uint;
+pub type suseconds_t = c_int;
-pub type suseconds_t = i64;
+pub type clock_t = c_long;
+pub type clockid_t = c_int;
+pub type timer_t = *mut c_void;
+
+pub type nfds_t = c_ulong;
s! {
+ pub struct fd_set {
+ fds_bits: [::c_ulong; FD_SETSIZE / ULONG_SIZE],
+ }
+
+ pub struct pollfd {
+ pub fd: ::c_int,
+ pub events: ::c_short,
+ pub revents: ::c_short,
+ }
+
+ pub struct stat {
+ pub st_dev: ::dev_t,
+ pub st_ino: ::ino_t,
+ pub st_nlink: ::nlink_t,
+ pub st_mode: ::mode_t,
+ pub st_uid: ::uid_t,
+ pub st_gid: ::gid_t,
+ pub st_rdev: ::dev_t,
+ pub st_size: ::off_t,
+ pub st_blksize: ::blksize_t,
+ pub st_blocks: ::blkcnt_t,
+
+ pub st_atime: ::timespec,
+ pub st_mtime: ::timespec,
+ pub st_ctime: ::timespec,
+
+ _pad: [c_char; 24],
+ }
+
pub struct timeval {
pub tv_sec: time_t,
pub tv_usec: suseconds_t,
@@ -64,6 +111,27 @@ pub const STDERR_FILENO: ::c_int = 2;
pub const EXIT_FAILURE: ::c_int = 1;
pub const EXIT_SUCCESS: ::c_int = 0;
+pub const FD_SETSIZE: usize = 1024;
+
+pub const MAP_SHARED: ::c_int = 1;
+pub const MAP_PRIVATE: ::c_int = 2;
+pub const MAP_ANONYMOUS: ::c_int = 4;
+pub const MAP_ANON: ::c_int = MAP_ANONYMOUS;
+
+pub const MAP_FAILED: *mut ::c_void = !0 as *mut ::c_void;
+
+pub const POLLIN: ::c_short = 0x001;
+pub const POLLPRI: ::c_short = 0x002;
+pub const POLLOUT: ::c_short = 0x004;
+pub const POLLERR: ::c_short = 0x008;
+pub const POLLHUP: ::c_short = 0x010;
+pub const POLLNVAL: ::c_short = 0x020;
+
+pub const PROT_NONE: ::c_int = 0;
+pub const PROT_EXEC: ::c_int = 1;
+pub const PROT_WRITE: ::c_int = 2;
+pub const PROT_READ: ::c_int = 4;
+
pub const S_ISUID: ::c_int = 0x800;
pub const S_ISGID: ::c_int = 0x400;
pub const S_ISVTX: ::c_int = 0x200;
@@ -98,6 +166,8 @@ pub const F_SETFD: ::c_int = 2;
pub const F_GETFL: ::c_int = 3;
pub const F_SETFL: ::c_int = 4;
+pub const FD_CLOEXEC: ::c_int = 0x0100_0000;
+
pub const O_RDONLY: ::c_int = 0x0001_0000;
pub const O_WRONLY: ::c_int = 0x0002_0000;
pub const O_RDWR: ::c_int = 0x0003_0000;
@@ -152,6 +222,17 @@ pub const SIGSYS: ::c_int = 31;
pub enum FILE {}
pub enum fpos_t {} // TODO: fill this out with a struct
+// intentionally not public, only used for fd_set
+cfg_if! {
+ if #[cfg(target_pointer_width = "32")] {
+ const ULONG_SIZE: usize = 32;
+ } else if #[cfg(target_pointer_width = "64")] {
+ const ULONG_SIZE: usize = 64;
+ } else {
+ // Unknown target_pointer_width
+ }
+}
+
extern {
pub fn isalnum(c: c_int) -> c_int;
pub fn isalpha(c: c_int) -> c_int;
@@ -262,9 +343,22 @@ extern {
pub fn close(fd: ::c_int) -> ::c_int;
pub fn fchown(fd: ::c_int, uid: ::uid_t, gid: ::gid_t) -> ::c_int;
pub fn fcntl(fd: ::c_int, cmd: ::c_int, ...) -> ::c_int;
+ pub fn fstat(fd: ::c_int, buf: *mut stat) -> ::c_int;
+ pub fn fsync(fd: ::c_int) -> ::c_int;
pub fn gethostname(name: *mut ::c_char, len: ::size_t) -> ::c_int;
pub fn getpid() -> pid_t;
pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void;
+ pub fn mmap(addr: *mut ::c_void,
+ len: ::size_t,
+ prot: ::c_int,
+ flags: ::c_int,
+ fd: ::c_int,
+ offset: off_t)
+ -> *mut ::c_void;
+ pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int)
+ -> ::c_int;
+ pub fn munmap(addr: *mut ::c_void, len: ::size_t) -> ::c_int;
+ pub fn poll(fds: *mut pollfd, nfds: nfds_t, timeout: ::c_int) -> ::c_int;
pub fn read(fd: ::c_int, buf: *mut ::c_void, count: ::size_t) -> ::ssize_t;
pub fn setenv(name: *const c_char, val: *const c_char, overwrite: ::c_int)
-> ::c_int;
diff --git a/libc/src/unix/bsd/apple/mod.rs b/libc/src/unix/bsd/apple/mod.rs
index 3d9dd94..13da82c 100644
--- a/libc/src/unix/bsd/apple/mod.rs
+++ b/libc/src/unix/bsd/apple/mod.rs
@@ -2659,6 +2659,7 @@ extern {
fd: ::c_int,
newfd: ::c_int,
) -> ::c_int;
+ pub fn uname(buf: *mut ::utsname) -> ::c_int;
}
cfg_if! {
diff --git a/libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs
index 0414380..41b6956 100644
--- a/libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs
+++ b/libc/src/unix/bsd/freebsdlike/dragonfly/mod.rs
@@ -801,4 +801,5 @@ extern {
pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int;
pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int;
+ pub fn uname(buf: *mut ::utsname) -> ::c_int;
}
diff --git a/libc/src/unix/bsd/freebsdlike/freebsd/mod.rs b/libc/src/unix/bsd/freebsdlike/freebsd/mod.rs
index 03b19eb..878deea 100644
--- a/libc/src/unix/bsd/freebsdlike/freebsd/mod.rs
+++ b/libc/src/unix/bsd/freebsdlike/freebsd/mod.rs
@@ -447,6 +447,19 @@ pub const TIOCSIG: ::c_uint = 0x2004745f;
pub const TIOCM_DCD: ::c_int = 0x40;
pub const H4DISC: ::c_int = 0x7;
+pub const FIONCLEX: ::c_ulong = 0x20006602;
+pub const FIONREAD: ::c_ulong = 0x4004667f;
+pub const FIOASYNC: ::c_ulong = 0x8004667d;
+pub const FIOSETOWN: ::c_ulong = 0x8004667c;
+pub const FIOGETOWN: ::c_ulong = 0x4004667b;
+pub const FIODTYPE: ::c_ulong = 0x4004667a;
+pub const FIOGETLBA: ::c_ulong = 0x40046679;
+pub const FIODGNAME: ::c_ulong = 0x80106678;
+pub const FIONWRITE: ::c_ulong = 0x40046677;
+pub const FIONSPACE: ::c_ulong = 0x40046676;
+pub const FIOSEEKDATA: ::c_ulong = 0xc0086661;
+pub const FIOSEEKHOLE: ::c_ulong = 0xc0086662;
+
pub const JAIL_API_VERSION: u32 = 2;
pub const JAIL_CREATE: ::c_int = 0x01;
pub const JAIL_UPDATE: ::c_int = 0x02;
@@ -949,6 +962,12 @@ pub const UF_READONLY: ::c_ulong = 0x00001000;
pub const UF_HIDDEN: ::c_ulong = 0x00008000;
pub const SF_SNAPSHOT: ::c_ulong = 0x00200000;
+f! {
+ pub fn uname(buf: *mut ::utsname) -> ::c_int {
+ __xuname(256, buf as *mut ::c_void)
+ }
+}
+
extern {
pub fn __error() -> *mut ::c_int;
@@ -1135,6 +1154,7 @@ extern {
pub fn fstatfs(fd: ::c_int, buf: *mut statfs) -> ::c_int;
pub fn dup3(src: ::c_int, dst: ::c_int, flags: ::c_int) -> ::c_int;
+ pub fn __xuname(nmln: ::c_int, buf: *mut ::c_void) -> ::c_int;
}
#[link(name = "util")]
diff --git a/libc/src/unix/bsd/netbsdlike/mod.rs b/libc/src/unix/bsd/netbsdlike/mod.rs
index abd014c..15f84d9 100644
--- a/libc/src/unix/bsd/netbsdlike/mod.rs
+++ b/libc/src/unix/bsd/netbsdlike/mod.rs
@@ -676,6 +676,7 @@ extern {
-> ::c_int;
pub fn getdomainname(name: *mut ::c_char, len: ::size_t) -> ::c_int;
pub fn setdomainname(name: *const ::c_char, len: ::size_t) -> ::c_int;
+ pub fn uname(buf: *mut ::utsname) -> ::c_int;
}
cfg_if! {
diff --git a/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs b/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs
index 9c8173f..760582c 100644
--- a/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs
+++ b/libc/src/unix/bsd/netbsdlike/netbsd/mod.rs
@@ -987,6 +987,20 @@ pub const CHWFLOW: ::tcflag_t = ::MDMBUF | ::CRTSCTS | ::CDTRCTS;
pub const SOCK_CLOEXEC: ::c_int = 0x10000000;
pub const SOCK_NONBLOCK: ::c_int = 0x20000000;
+pub const FIONCLEX: ::c_ulong = 0x20006602;
+// Uncomment on next NetBSD release
+// pub const FIOSEEKDATA: ::c_ulong = 0xc0086661;
+// pub const FIOSEEKHOLE: ::c_ulong = 0xc0086662;
+pub const FIONREAD: ::c_ulong = 0x4004667f;
+pub const FIOASYNC: ::c_ulong = 0x8004667d;
+pub const FIOSETOWN: ::c_ulong = 0x8004667c;
+pub const FIOGETOWN: ::c_ulong = 0x4004667b;
+pub const OFIOGETBMAP: ::c_ulong = 0xc004667a;
+pub const FIOGETBMAP: ::c_ulong = 0xc008667a;
+pub const FIONWRITE: ::c_ulong = 0x40046679;
+pub const FIONSPACE: ::c_ulong = 0x40046678;
+pub const FIBMAP: ::c_ulong = 0xc008667a;
+
pub const SIGSTKSZ : ::size_t = 40960;
pub const PT_DUMPCORE: ::c_int = 12;
diff --git a/libc/src/unix/haiku/mod.rs b/libc/src/unix/haiku/mod.rs
index e65bca7..2aa5d13 100644
--- a/libc/src/unix/haiku/mod.rs
+++ b/libc/src/unix/haiku/mod.rs
@@ -1242,6 +1242,7 @@ extern {
termp: *mut termios,
winp: *mut ::winsize) -> ::pid_t;
pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int;
+ pub fn uname(buf: *mut ::utsname) -> ::c_int;
}
cfg_if! {
diff --git a/libc/src/unix/hermit/mod.rs b/libc/src/unix/hermit/mod.rs
index aadfa1c..ba7a90f 100644
--- a/libc/src/unix/hermit/mod.rs
+++ b/libc/src/unix/hermit/mod.rs
@@ -727,6 +727,7 @@ extern {
-> ::c_int;
pub fn setgroups(ngroups: ::c_int, grouplist: *const ::gid_t) -> ::c_int;
+ pub fn uname(buf: *mut ::utsname) -> ::c_int;
}
cfg_if! {
diff --git a/libc/src/unix/mod.rs b/libc/src/unix/mod.rs
index 370d7f4..88e13c5 100644
--- a/libc/src/unix/mod.rs
+++ b/libc/src/unix/mod.rs
@@ -972,7 +972,6 @@ extern {
#[cfg_attr(target_os = "freebsd", link_name = "mknod@FBSD_1.0")]
pub fn mknod(pathname: *const ::c_char, mode: ::mode_t,
dev: ::dev_t) -> ::c_int;
- pub fn uname(buf: *mut ::utsname) -> ::c_int;
pub fn gethostname(name: *mut ::c_char, len: ::size_t) -> ::c_int;
pub fn getservbyname(name: *const ::c_char,
proto: *const ::c_char) -> *mut servent;
diff --git a/libc/src/unix/newlib/mod.rs b/libc/src/unix/newlib/mod.rs
index 77a4eb9..0cc411d 100644
--- a/libc/src/unix/newlib/mod.rs
+++ b/libc/src/unix/newlib/mod.rs
@@ -728,6 +728,7 @@ extern {
link_name = "popen$UNIX2003")]
pub fn popen(command: *const c_char,
mode: *const c_char) -> *mut ::FILE;
+ pub fn uname(buf: *mut ::utsname) -> ::c_int;
}
cfg_if! {
diff --git a/libc/src/unix/notbsd/linux/other/b32/x86.rs b/libc/src/unix/notbsd/linux/other/b32/x86.rs
index 1506aca..6c41718 100644
--- a/libc/src/unix/notbsd/linux/other/b32/x86.rs
+++ b/libc/src/unix/notbsd/linux/other/b32/x86.rs
@@ -758,6 +758,27 @@ pub const EFL: ::c_int = 14;
pub const UESP: ::c_int = 15;
pub const SS: ::c_int = 16;
+// offsets in mcontext_t.gregs from sys/ucontext.h
+pub const REG_GS: ::c_int = 0;
+pub const REG_FS: ::c_int = 1;
+pub const REG_ES: ::c_int = 2;
+pub const REG_DS: ::c_int = 3;
+pub const REG_EDI: ::c_int = 4;
+pub const REG_ESI: ::c_int = 5;
+pub const REG_EBP: ::c_int = 6;
+pub const REG_ESP: ::c_int = 7;
+pub const REG_EBX: ::c_int = 8;
+pub const REG_EDX: ::c_int = 9;
+pub const REG_ECX: ::c_int = 10;
+pub const REG_EAX: ::c_int = 11;
+pub const REG_TRAPNO: ::c_int = 12;
+pub const REG_ERR: ::c_int = 13;
+pub const REG_EIP: ::c_int = 14;
+pub const REG_CS: ::c_int = 15;
+pub const REG_EFL: ::c_int = 16;
+pub const REG_UESP: ::c_int = 17;
+pub const REG_SS: ::c_int = 18;
+
extern {
pub fn getcontext(ucp: *mut ucontext_t) -> ::c_int;
pub fn setcontext(ucp: *const ucontext_t) -> ::c_int;
diff --git a/libc/src/unix/notbsd/linux/other/b64/x86_64.rs b/libc/src/unix/notbsd/linux/other/b64/x86_64.rs
index 43b8b9f..0d7137e 100644
--- a/libc/src/unix/notbsd/linux/other/b64/x86_64.rs
+++ b/libc/src/unix/notbsd/linux/other/b64/x86_64.rs
@@ -644,6 +644,31 @@ pub const ES: ::c_int = 24;
pub const FS: ::c_int = 25;
pub const GS: ::c_int = 26;
+// offsets in mcontext_t.gregs from sys/ucontext.h
+pub const REG_R8: ::c_int = 0;
+pub const REG_R9: ::c_int = 1;
+pub const REG_R10: ::c_int = 2;
+pub const REG_R11: ::c_int = 3;
+pub const REG_R12: ::c_int = 4;
+pub const REG_R13: ::c_int = 5;
+pub const REG_R14: ::c_int = 6;
+pub const REG_R15: ::c_int = 7;
+pub const REG_RDI: ::c_int = 8;
+pub const REG_RSI: ::c_int = 9;
+pub const REG_RBP: ::c_int = 10;
+pub const REG_RBX: ::c_int = 11;
+pub const REG_RDX: ::c_int = 12;
+pub const REG_RAX: ::c_int = 13;
+pub const REG_RCX: ::c_int = 14;
+pub const REG_RSP: ::c_int = 15;
+pub const REG_RIP: ::c_int = 16;
+pub const REG_EFL: ::c_int = 17;
+pub const REG_CSGSFS: ::c_int = 18;
+pub const REG_ERR: ::c_int = 19;
+pub const REG_TRAPNO: ::c_int = 20;
+pub const REG_OLDMASK: ::c_int = 21;
+pub const REG_CR2: ::c_int = 22;
+
extern {
pub fn getcontext(ucp: *mut ucontext_t) -> ::c_int;
pub fn setcontext(ucp: *const ucontext_t) -> ::c_int;
diff --git a/libc/src/unix/notbsd/mod.rs b/libc/src/unix/notbsd/mod.rs
index 6ff0807..668c25f 100644
--- a/libc/src/unix/notbsd/mod.rs
+++ b/libc/src/unix/notbsd/mod.rs
@@ -1242,6 +1242,7 @@ extern {
flags: ::c_int) -> ::ssize_t;
pub fn recvmsg(fd: ::c_int, msg: *mut ::msghdr, flags: ::c_int)
-> ::ssize_t;
+ pub fn uname(buf: *mut ::utsname) -> ::c_int;
}
cfg_if! {
diff --git a/libc/src/unix/solaris/mod.rs b/libc/src/unix/solaris/mod.rs
index c4ec111..c991e62 100644
--- a/libc/src/unix/solaris/mod.rs
+++ b/libc/src/unix/solaris/mod.rs
@@ -1466,4 +1466,5 @@ extern {
mode: *const c_char) -> *mut ::FILE;
pub fn dup3(src: ::c_int, dst: ::c_int, flags: ::c_int) -> ::c_int;
+ pub fn uname(buf: *mut ::utsname) -> ::c_int;
}
diff --git a/libc/src/unix/uclibc/mod.rs b/libc/src/unix/uclibc/mod.rs
index 9d8e97e..c04c22a 100644
--- a/libc/src/unix/uclibc/mod.rs
+++ b/libc/src/unix/uclibc/mod.rs
@@ -1953,6 +1953,7 @@ extern {
link_name = "popen$UNIX2003")]
pub fn popen(command: *const c_char,
mode: *const c_char) -> *mut ::FILE;
+ pub fn uname(buf: *mut ::utsname) -> ::c_int;
}
cfg_if! {