summaryrefslogtreecommitdiff
path: root/libc/src/unix/mod.rs
diff options
context:
space:
mode:
authorDaniel Mueller <deso@posteo.net>2017-09-16 08:42:30 -0700
committerDaniel Mueller <deso@posteo.net>2017-09-16 08:42:30 -0700
commitbcaabae7c22d27fdbb07ea6009a6f4a9c3672fa2 (patch)
treee7470179e1bfb3fff279450e402ddcaf038ae086 /libc/src/unix/mod.rs
parentab3c2a935b1ba655de2f3fec35da2c14b69966dc (diff)
downloadnitrocli-bcaabae7c22d27fdbb07ea6009a6f4a9c3672fa2.tar.gz
nitrocli-bcaabae7c22d27fdbb07ea6009a6f4a9c3672fa2.tar.bz2
Update libc crate to 0.2.30
Import subrepo libc/:libc at 3520512a8c9cb55661910318a6fb169a75c02a59
Diffstat (limited to 'libc/src/unix/mod.rs')
-rw-r--r--libc/src/unix/mod.rs95
1 files changed, 55 insertions, 40 deletions
diff --git a/libc/src/unix/mod.rs b/libc/src/unix/mod.rs
index c2d1f10..fcbc3eb 100644
--- a/libc/src/unix/mod.rs
+++ b/libc/src/unix/mod.rs
@@ -62,7 +62,7 @@ s! {
pub ru_nvcsw: c_long,
pub ru_nivcsw: c_long,
- #[cfg(any(target_env = "musl"))]
+ #[cfg(any(target_env = "musl", target_os = "emscripten"))]
__reserved: [c_long; 16],
}
@@ -124,6 +124,20 @@ s! {
// Actually a union of an int and a void*
pub sival_ptr: *mut ::c_void
}
+
+ // <sys/time.h>
+ pub struct itimerval {
+ pub it_interval: ::timeval,
+ pub it_value: ::timeval,
+ }
+
+ // <sys/times.h>
+ pub struct tms {
+ pub tms_utime: ::clock_t,
+ pub tms_stime: ::clock_t,
+ pub tms_cutime: ::clock_t,
+ pub tms_cstime: ::clock_t,
+ }
}
pub const SIG_DFL: sighandler_t = 0 as sighandler_t;
@@ -203,9 +217,23 @@ pub const PRIO_USER: ::c_int = 2;
pub const PRIO_MIN: ::c_int = -20;
pub const PRIO_MAX: ::c_int = 20;
+pub const IPPROTO_ICMP: ::c_int = 1;
+pub const IPPROTO_ICMPV6: ::c_int = 58;
+pub const IPPROTO_TCP: ::c_int = 6;
+pub const IPPROTO_UDP: ::c_int = 17;
+pub const IPPROTO_IP: ::c_int = 0;
+pub const IPPROTO_IPV6: ::c_int = 41;
+
+pub const INADDR_LOOPBACK: in_addr_t = 2130706433;
+pub const INADDR_ANY: in_addr_t = 0;
+pub const INADDR_BROADCAST: in_addr_t = 4294967295;
+pub const INADDR_NONE: in_addr_t = 4294967295;
+
cfg_if! {
if #[cfg(dox)] {
// on dox builds don't pull in anything
+ } else if #[cfg(target_os = "l4re")] {
+ // required libraries for L4Re are linked externally, ATM
} else if #[cfg(all(not(stdbuild), feature = "use_std"))] {
// cargo build, don't pull in anything extra as the libstd dep
// already pulls in all libs.
@@ -238,6 +266,10 @@ cfg_if! {
#[link(name = "c")]
#[link(name = "mxio")]
extern {}
+ } else if #[cfg(target_env = "newlib")] {
+ #[link(name = "c")]
+ #[link(name = "m")]
+ extern {}
} else {
#[link(name = "c")]
#[link(name = "m")]
@@ -248,10 +280,6 @@ cfg_if! {
}
extern {
- pub fn getgrnam(name: *const ::c_char) -> *mut group;
- pub fn getgrgid(gid: ::gid_t) -> *mut group;
-
- pub fn endpwent();
#[cfg_attr(target_os = "netbsd", link_name = "__getpwnam50")]
pub fn getpwnam(name: *const ::c_char) -> *mut passwd;
#[cfg_attr(target_os = "netbsd", link_name = "__getpwuid50")]
@@ -321,10 +349,6 @@ extern {
#[cfg_attr(target_os = "netbsd", link_name = "__stat50")]
pub fn stat(path: *const c_char, buf: *mut stat) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "popen$UNIX2003")]
- pub fn popen(command: *const c_char,
- mode: *const c_char) -> *mut ::FILE;
pub fn pclose(stream: *mut ::FILE) -> ::c_int;
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
link_name = "fdopen$UNIX2003")]
@@ -366,8 +390,6 @@ extern {
pub fn openat(dirfd: ::c_int, pathname: *const ::c_char,
flags: ::c_int, ...) -> ::c_int;
- pub fn faccessat(dirfd: ::c_int, pathname: *const ::c_char,
- mode: ::c_int, flags: ::c_int) -> ::c_int;
pub fn fchmodat(dirfd: ::c_int, pathname: *const ::c_char,
mode: ::mode_t, flags: ::c_int) -> ::c_int;
pub fn fchown(fd: ::c_int,
@@ -405,7 +427,9 @@ extern {
pub fn lchown(path: *const c_char, uid: uid_t,
gid: gid_t) -> ::c_int;
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "close$UNIX2003")]
+ link_name = "close$NOCANCEL$UNIX2003")]
+ #[cfg_attr(all(target_os = "macos", target_arch = "x86_64"),
+ link_name = "close$NOCANCEL")]
pub fn close(fd: ::c_int) -> ::c_int;
pub fn dup(fd: ::c_int) -> ::c_int;
pub fn dup2(src: ::c_int, dst: ::c_int) -> ::c_int;
@@ -456,6 +480,7 @@ extern {
pub fn read(fd: ::c_int, buf: *mut ::c_void, count: ::size_t)
-> ::ssize_t;
pub fn rmdir(path: *const c_char) -> ::c_int;
+ pub fn seteuid(uid: uid_t) -> ::c_int;
pub fn setgid(gid: gid_t) -> ::c_int;
pub fn setpgid(pid: pid_t, pgid: pid_t) -> ::c_int;
pub fn setsid() -> pid_t;
@@ -555,7 +580,6 @@ extern {
#[cfg_attr(target_os = "netbsd", link_name = "__getrusage50")]
pub fn getrusage(resource: ::c_int, usage: *mut rusage) -> ::c_int;
- pub fn getdtablesize() -> ::c_int;
#[cfg_attr(any(target_os = "macos", target_os = "ios"),
link_name = "realpath$DARWIN_EXTSN")]
pub fn realpath(pathname: *const ::c_char, resolved: *mut ::c_char)
@@ -566,19 +590,14 @@ extern {
#[cfg_attr(target_os = "netbsd", link_name = "__gettimeofday50")]
pub fn gettimeofday(tp: *mut ::timeval,
tz: *mut ::c_void) -> ::c_int;
+ #[cfg_attr(target_os = "netbsd", link_name = "__times13")]
+ pub fn times(buf: *mut ::tms) -> ::clock_t;
pub fn pthread_self() -> ::pthread_t;
- pub fn pthread_create(native: *mut ::pthread_t,
- attr: *const ::pthread_attr_t,
- f: extern fn(*mut ::c_void) -> *mut ::c_void,
- value: *mut ::c_void) -> ::c_int;
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
link_name = "pthread_join$UNIX2003")]
pub fn pthread_join(native: ::pthread_t,
value: *mut *mut ::c_void) -> ::c_int;
- pub fn pthread_atfork(prepare: Option<unsafe extern fn()>,
- parent: Option<unsafe extern fn()>,
- child: Option<unsafe extern fn()>) -> ::c_int;
pub fn pthread_exit(value: *mut ::c_void);
pub fn pthread_attr_init(attr: *mut ::pthread_attr_t) -> ::c_int;
pub fn pthread_attr_destroy(attr: *mut ::pthread_attr_t) -> ::c_int;
@@ -629,6 +648,10 @@ extern {
pub fn pthread_condattr_init(attr: *mut pthread_condattr_t) -> ::c_int;
pub fn pthread_condattr_destroy(attr: *mut pthread_condattr_t) -> ::c_int;
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
+ link_name = "pthread_rwlock_init$UNIX2003")]
+ pub fn pthread_rwlock_init(lock: *mut pthread_rwlock_t,
+ attr: *const pthread_rwlockattr_t) -> ::c_int;
+ #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
link_name = "pthread_rwlock_destroy$UNIX2003")]
pub fn pthread_rwlock_destroy(lock: *mut pthread_rwlock_t) -> ::c_int;
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
@@ -646,11 +669,9 @@ extern {
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
link_name = "pthread_rwlock_unlock$UNIX2003")]
pub fn pthread_rwlock_unlock(lock: *mut pthread_rwlock_t) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "pthread_sigmask$UNIX2003")]
- pub fn pthread_sigmask(how: ::c_int, set: *const sigset_t,
- oldset: *mut sigset_t) -> ::c_int;
- pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int;
+ pub fn pthread_rwlockattr_init(attr: *mut pthread_rwlockattr_t) -> ::c_int;
+ pub fn pthread_rwlockattr_destroy(attr: *mut pthread_rwlockattr_t)
+ -> ::c_int;
#[cfg_attr(all(target_os = "linux", not(target_env = "musl")),
link_name = "__xpg_strerror_r")]
pub fn strerror_r(errnum: ::c_int, buf: *mut c_char,
@@ -666,16 +687,6 @@ extern {
pub fn sigaction(signum: ::c_int,
act: *const sigaction,
oldact: *mut sigaction) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch = "x86"),
- link_name = "sigaltstack$UNIX2003")]
- #[cfg_attr(target_os = "netbsd", link_name = "__sigaltstack14")]
- pub fn sigaltstack(ss: *const stack_t,
- oss: *mut stack_t) -> ::c_int;
- #[cfg_attr(all(target_os = "macos", target_arch ="x86"),
- link_name = "sigwait$UNIX2003")]
- #[cfg_attr(target_os = "solaris", link_name = "__posix_sigwait")]
- pub fn sigwait(set: *const sigset_t,
- sig: *mut ::c_int) -> ::c_int;
#[cfg_attr(target_os = "netbsd", link_name = "__utimes50")]
pub fn utimes(filename: *const ::c_char,
@@ -713,14 +724,15 @@ extern {
pub fn mktime(tm: *mut tm) -> time_t;
#[cfg_attr(target_os = "netbsd", link_name = "__time50")]
pub fn time(time: *mut time_t) -> time_t;
+ #[cfg_attr(target_os = "netbsd", link_name = "__gmtime50")]
+ pub fn gmtime(time_p: *const time_t) -> *mut tm;
#[cfg_attr(target_os = "netbsd", link_name = "__locatime50")]
- pub fn localtime(time: *const time_t) -> *mut tm;
+ pub fn localtime(time_p: *const time_t) -> *mut tm;
#[cfg_attr(target_os = "netbsd", link_name = "__mknod50")]
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 daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int;
pub fn gethostname(name: *mut ::c_char, len: ::size_t) -> ::c_int;
pub fn chroot(name: *const ::c_char) -> ::c_int;
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
@@ -757,9 +769,6 @@ extern {
pub fn localeconv() -> *mut lconv;
pub fn sem_destroy(sem: *mut sem_t) -> ::c_int;
- pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t;
- pub fn sem_close(sem: *mut sem_t) -> ::c_int;
- pub fn sem_unlink(name: *const ::c_char) -> ::c_int;
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
link_name = "sem_wait$UNIX2003")]
pub fn sem_wait(sem: *mut sem_t) -> ::c_int;
@@ -793,6 +802,8 @@ extern {
set: *const sigset_t,
oldset: *mut sigset_t)
-> ::c_int;
+ #[cfg_attr(target_os = "netbsd", link_name = "__sigpending14")]
+ pub fn sigpending(set: *mut sigset_t) -> ::c_int;
#[cfg_attr(target_os = "netbsd", link_name = "__timegm50")]
pub fn timegm(tm: *mut ::tm) -> time_t;
@@ -833,6 +844,7 @@ extern {
termios: *const ::termios) -> ::c_int;
pub fn tcflow(fd: ::c_int, action: ::c_int) -> ::c_int;
pub fn tcflush(fd: ::c_int, action: ::c_int) -> ::c_int;
+ pub fn tcgetsid(fd: ::c_int) -> ::pid_t;
pub fn tcsendbreak(fd: ::c_int, duration: ::c_int) -> ::c_int;
pub fn mkstemp(template: *mut ::c_char) -> ::c_int;
pub fn mkdtemp(template: *mut ::c_char) -> *mut ::c_char;
@@ -857,6 +869,9 @@ cfg_if! {
if #[cfg(target_env = "uclibc")] {
mod uclibc;
pub use self::uclibc::*;
+ } else if #[cfg(target_env = "newlib")] {
+ mod newlib;
+ pub use self::newlib::*;
} else if #[cfg(any(target_os = "linux",
target_os = "android",
target_os = "emscripten",