diff options
author | Alex Crichton <alex@alexcrichton.com> | 2015-09-17 14:47:40 -0700 |
---|---|---|
committer | Alex Crichton <alex@alexcrichton.com> | 2015-09-17 14:47:40 -0700 |
commit | cd9b33e32b91a7738e33c711d99b49b71f368b97 (patch) | |
tree | 1823657786acbd0765a38e7014d4b7b55493c61e /src/unix | |
parent | 242d3d33e274ea362f96c6348f96a88e3ce91940 (diff) | |
download | rust-libc-cd9b33e32b91a7738e33c711d99b49b71f368b97.tar.gz |
Import lots of the stdlib
Diffstat (limited to 'src/unix')
-rw-r--r-- | src/unix/bsd/apple/b32.rs | 4 | ||||
-rw-r--r-- | src/unix/bsd/apple/b64.rs | 4 | ||||
-rw-r--r-- | src/unix/bsd/apple/mod.rs | 67 | ||||
-rw-r--r-- | src/unix/bsd/freebsdlike/dragonfly.rs | 4 | ||||
-rw-r--r-- | src/unix/bsd/freebsdlike/freebsd.rs | 4 | ||||
-rw-r--r-- | src/unix/bsd/freebsdlike/mod.rs | 33 | ||||
-rw-r--r-- | src/unix/bsd/mod.rs | 28 | ||||
-rw-r--r-- | src/unix/bsd/openbsdlike/mod.rs | 34 | ||||
-rw-r--r-- | src/unix/mod.rs | 99 | ||||
-rw-r--r-- | src/unix/notbsd/android.rs | 83 | ||||
-rw-r--r-- | src/unix/notbsd/linux/mips.rs | 37 | ||||
-rw-r--r-- | src/unix/notbsd/linux/mod.rs | 57 | ||||
-rw-r--r-- | src/unix/notbsd/linux/notmips/b32/mod.rs | 7 | ||||
-rw-r--r-- | src/unix/notbsd/linux/notmips/b64/aarch64.rs | 2 | ||||
-rw-r--r-- | src/unix/notbsd/linux/notmips/b64/mod.rs | 8 | ||||
-rw-r--r-- | src/unix/notbsd/linux/notmips/b64/x86_64.rs | 2 | ||||
-rw-r--r-- | src/unix/notbsd/linux/notmips/mod.rs | 30 | ||||
-rw-r--r-- | src/unix/notbsd/mod.rs | 15 |
18 files changed, 506 insertions, 12 deletions
diff --git a/src/unix/bsd/apple/b32.rs b/src/unix/bsd/apple/b32.rs index 62caa5fdd5..293822e721 100644 --- a/src/unix/bsd/apple/b32.rs +++ b/src/unix/bsd/apple/b32.rs @@ -7,6 +7,10 @@ pub type ptrdiff_t = i32; pub type intptr_t = i32; pub type uintptr_t = u32; +pub const __PTHREAD_MUTEX_SIZE__: usize = 40; +pub const __PTHREAD_COND_SIZE__: usize = 24; +pub const __PTHREAD_RWLOCK_SIZE__: usize = 124; + s! { pub struct pthread_attr_t { __sig: c_long, diff --git a/src/unix/bsd/apple/b64.rs b/src/unix/bsd/apple/b64.rs index 1a79be3036..fb9f58ccd2 100644 --- a/src/unix/bsd/apple/b64.rs +++ b/src/unix/bsd/apple/b64.rs @@ -7,6 +7,10 @@ pub type ptrdiff_t = i64; pub type intptr_t = i64; pub type uintptr_t = u64; +pub const __PTHREAD_MUTEX_SIZE__: usize = 56; +pub const __PTHREAD_COND_SIZE__: usize = 40; +pub const __PTHREAD_RWLOCK_SIZE__: usize = 192; + s! { pub struct pthread_attr_t { __sig: c_long, diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 71b24a6931..173788df3d 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -41,6 +41,8 @@ pub type pthread_t = uintptr_t; pub type rlim_t = u64; pub type sighandler_t = size_t; pub type mach_timebase_info_data_t = mach_timebase_info; +pub type pthread_key_t = c_ulong; +pub type sigset_t = u32; pub enum timezone {} @@ -120,6 +122,41 @@ s! { pub st_qspare: [::int64_t; 2], } + + pub struct pthread_mutex_t { + __sig: libc::c_long, + __opaque: [u8; __PTHREAD_MUTEX_SIZE__], + } + pub struct pthread_mutexattr_t { + __sig: libc::c_long, + __opaque: [u8; 16], + } + + pub struct pthread_cond_t { + __sig: libc::c_long, + __opaque: [u8; __PTHREAD_COND_SIZE__], + } + + pub struct pthread_rwlock_t { + __sig: libc::c_long, + __opaque: [u8; __PTHREAD_RWLOCK_SIZE__], + } + + pub struct siginfo_t { + pub _signo: ::c_int, + pub _errno: ::c_int, + pub _code: ::c_int, + pub _pid: ::pid_t, + pub _uid: ::uid_t, + pub _status: ::c_int, + pub si_addr: *mut ::c_void + } + + pub struct sigaction { + pub sa_sigaction: sighandler_t, + pub sa_mask: sigset_t, + pub sa_flags: ::c_int, + } } pub const EXIT_FAILURE: c_int = 1; @@ -334,7 +371,6 @@ pub const F_SETFL: c_int = 4; pub const O_ACCMODE: c_int = 3; pub const SIGTRAP: c_int = 5; -pub const SIG_IGN: size_t = 1; pub const GLOB_APPEND : c_int = 0x0001; pub const GLOB_DOOFFS : c_int = 0x0002; @@ -601,9 +637,30 @@ pub const _SC_TRACE_SYS_MAX: c_int = 129; pub const _SC_TRACE_USER_EVENT_MAX: c_int = 130; pub const _SC_PASS_MAX: c_int = 131; + +pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2; +pub const _PTHREAD_MUTEX_SIG_INIT: ::c_long = 0x32AAABA7; +pub const _PTHREAD_COND_SIG_INIT: ::c_long = 0x3CB0B1BB; +pub const _PTHREAD_RWLOCK_SIG_INIT: ::c_long = 0x2DA8B3B4; +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + __sig: _PTHREAD_MUTEX_SIG_INIT, + __opaque: [0; __PTHREAD_MUTEX_SIZE__], +}; +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + __sig: _PTHREAD_COND_SIG_INIT, + __opaque: [0; __PTHREAD_COND_SIZE__], +}; +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + __sig: _PTHREAD_RWLOCK_SIG_INIT, + __opaque: [0; __PTHREAD_RWLOCK_SIZE__], +}; + extern { pub fn _NSGetExecutablePath(buf: *mut ::c_char, bufsize: *mut ::uint32_t) -> ::c_int; + pub fn _NSGetArgc() -> *mut c_int; + pub fn _NSGetArgv() -> *mut *mut *mut c_char; + pub fn _NSGetEnviron() -> *mut *const *const c_char; #[cfg_attr(all(target_os = "macos", target_arch = "x86"), link_name = "mprotect$UNIX2003")] pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) @@ -622,6 +679,14 @@ extern { newp: *mut ::c_void, newlen: ::size_t) -> ::c_int; + pub fn _tlv_atexit(dtor: unsafe extern fn(*mut u8), + arg: *mut u8); + pub fn mach_absolute_time() -> u64; + pub fn mach_timebase_info(info: *mut ::mach_timebase_info) -> ::c_int; + pub fn pthread_setname_np(name: *const ::c_char) -> ::c_int; + pub fn pthread_get_stackaddr_np(thread: pthread_t) -> *mut ::c_void; + pub fn pthread_get_stacksize_np(thread: pthread_t) -> ::size_t; + pub fn __error() -> *const ::c_int; } cfg_if! { diff --git a/src/unix/bsd/freebsdlike/dragonfly.rs b/src/unix/bsd/freebsdlike/dragonfly.rs index a677d1a521..f158cda803 100644 --- a/src/unix/bsd/freebsdlike/dragonfly.rs +++ b/src/unix/bsd/freebsdlike/dragonfly.rs @@ -1,2 +1,6 @@ pub const PTHREAD_STACK_MIN: ::size_t = 1024; pub const KERN_PROC_PATHNAME: ::c_int = 9; + +extern { + pub fn __dfly_error() -> *const ::c_int; +} diff --git a/src/unix/bsd/freebsdlike/freebsd.rs b/src/unix/bsd/freebsdlike/freebsd.rs index c4998379ba..808f6eac95 100644 --- a/src/unix/bsd/freebsdlike/freebsd.rs +++ b/src/unix/bsd/freebsdlike/freebsd.rs @@ -1,2 +1,6 @@ pub const PTHREAD_STACK_MIN: ::size_t = 2048; pub const KERN_PROC_PATHNAME: ::c_int = 12; + +extern { + pub fn __error() -> *const ::c_int; +} diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index fc50c2201b..4ca588f941 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -5,6 +5,11 @@ pub type socklen_t = u32; pub type sa_family_t = u8; pub type in_port_t = u16; pub type in_addr_t = u32; +pub type pthread_mutex_t = *mut ::c_void; +pub type pthread_mutexattr_t = *mut ::c_void; +pub type pthread_cond_t = *mut ::c_void; +pub type pthread_rwlock_t = *mut ::c_void; +pub type pthread_key_t = ::c_int; pub enum timezone {} @@ -53,6 +58,26 @@ s! { pub ifa_dstaddr: *mut ::sockaddr, pub ifa_data: *mut ::c_void } + + pub struct sigset_t { + bits: [u32; 4], + } + + pub struct siginfo_t { + pub _signo: ::c_int, + pub _errno: ::c_int, + pub _code: ::c_int, + pub _pid: ::pid_t, + pub _uid: ::uid_t, + pub _status: ::c_int, + pub si_addr: *mut ::c_void + } + + pub struct sigaction { + pub sa_sigaction: sighandler_t, + pub sa_flags: ::c_int, + pub sa_mask: sigset_t, + } } pub const EXIT_FAILURE: ::c_int = 1; @@ -247,7 +272,6 @@ pub const F_GETFL: ::c_int = 3; pub const F_SETFL: ::c_int = 4; pub const SIGTRAP: ::c_int = 5; -pub const SIG_IGN: size_t = 1; pub const GLOB_APPEND : ::c_int = 0x0001; pub const GLOB_DOOFFS : ::c_int = 0x0002; @@ -462,6 +486,11 @@ pub const _SC_SEM_VALUE_MAX: ::c_int = 50; pub const _SC_SIGQUEUE_MAX: ::c_int = 51; pub const _SC_TIMER_MAX: ::c_int = 52; +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = 0 as *mut _; +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = 0 as *mut _; +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = 0 as *mut _; +pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2; + extern { pub fn mprotect(addr: *const ::c_void, len: size_t, prot: c_int) -> c_int; @@ -480,6 +509,8 @@ extern { newp: *const ::c_void, newlen: size_t) -> c_int; + pub fn clock_gettime(clk_id: ::c_int, tp: *mut ::timespec) -> ::c_int; + pub fn pthread_set_name_np(tid: ::pthread_t, name: *const ::c_char); } cfg_if! { diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index d55c78162d..5dd2fb7092 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -27,8 +27,36 @@ s! { pub sun_family: sa_family_t, pub sun_path: [c_char; 104] } + + pub struct passwd { + pub pw_name: *mut ::c_char, + pub pw_passwd: *mut ::c_char, + pub pw_uid: ::uid_t, + pub pw_gid: ::gid_t, + pub pw_change: ::time_t, + pub pw_class: *mut ::c_char, + pub pw_gecos: *mut ::c_char, + pub pw_dir: *mut ::c_char, + pub pw_shell: *mut ::c_char, + pub pw_expire: ::time_t, + } + + pub struct sigaltstack { + pub ss_sp: *mut ::c_void, + pub ss_size: ::size_t, + pub ss_flags: ::c_int, + } } +pub const FIOCLEX: c_ulong = 0x20006601; + +pub const SA_ONSTACK: ::c_int = 0x0001; +pub const SA_SIGINFO: ::c_int = 0x0040; + +pub const SIGSTKSZ: ::size_t = 131072; +pub const SIGBUS: ::c_int = 10; +pub const SIG_SETMASK: ::c_int = 3; + extern { pub fn mincore(addr: *const ::c_void, len: size_t, vec: *mut c_char) -> c_int; diff --git a/src/unix/bsd/openbsdlike/mod.rs b/src/unix/bsd/openbsdlike/mod.rs index f003630199..ef40db4458 100644 --- a/src/unix/bsd/openbsdlike/mod.rs +++ b/src/unix/bsd/openbsdlike/mod.rs @@ -1,3 +1,21 @@ + pub type sigset_t = libc::c_uint; +pub type pthread_key_t = ::c_int; + struct stack_t { + ss_sp: *mut libc::c_void, + ss_size: libc::size_t, + ss_flags: libc::c_int, + } + pub struct siginfo_t { + pub si_signo: libc::c_int, + pub si_code: libc::c_int, + pub si_errno: libc::c_int, + pub si_addr: *mut libc::c_void + } + pub struct sigaction { + pub sa_sigaction: sighandler_t, + pub sa_mask: sigset_t, + pub sa_flags: libc::c_int, + } #[cfg(any(target_os = "bitrig", target_os = "netbsd", target_os ="openbsd"))] pub mod os { @@ -497,7 +515,6 @@ pub const F_DUPFD_CLOEXEC : c_int = 10; pub const SIGTRAP : c_int = 5; - pub const SIG_IGN: size_t = 1; pub const GLOB_APPEND : c_int = 0x0001; pub const GLOB_DOOFFS : c_int = 0x0002; @@ -710,6 +727,15 @@ pub const _SC_TIMERS : c_int = 94; } } + pub type pthread_mutex_t = *mut libc::c_void; + pub type pthread_mutexattr_t = *mut libc::c_void; + pub type pthread_cond_t = *mut libc::c_void; + pub type pthread_rwlock_t = *mut libc::c_void; + + pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = ptr::null_mut(); + pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = ptr::null_mut(); + pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = ptr::null_mut(); + pub const PTHREAD_MUTEX_RECURSIVE: libc::c_int = 2; extern { pub fn mprotect(addr: *const ::c_void, len: size_t, prot: c_int) -> c_int; @@ -728,4 +754,10 @@ extern { newp: *mut ::c_void, newlen: size_t) -> c_int; + pub fn clock_gettime(clk_id: ::c_int, tp: *mut ::timespec) -> ::c_int; + pub fn pthread_set_name_np(tid: ::pthread_t, name: *const ::c_char); + pub fn pthread_main_np() -> ::c_uint; + pub fn pthread_stackseg_np(thread: pthread_t, + sinfo: *mut stack_t) -> ::c_uint; + pub fn __errno() -> *const ::c_int; } diff --git a/src/unix/mod.rs b/src/unix/mod.rs index f05e6337cd..2dabfd1544 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -66,9 +66,14 @@ s! { } } +pub const WNOHANG: c_int = 1; +pub const SIG_DFL: sighandler_t = 0 as sighandler_t; +pub const SIG_IGN: sighandler_t = 1 as sighandler_t; +pub const SIG_ERR: sighandler_t = !0 as sighandler_t; + cfg_if! { if #[cfg(feature = "default")] { - // cargo build, don't pull in anything extra as the libstd libc dep + // cargo build, don't pull in anything extra as the libstd dep // already pulls in all libs. } else if #[cfg(target_env = "musl")] { #[link(name = "c", kind = "static")] @@ -193,9 +198,7 @@ extern { pub fn getgroups(ngroups_max: c_int, groups: *mut gid_t) -> c_int; pub fn getlogin() -> *mut c_char; - // GNU getopt(3) modifies its arguments despite the - // char * const [] prototype; see the manpage. - pub fn getopt(argc: c_int, argv: *mut *mut c_char, + pub fn getopt(argc: c_int, argv: *const *mut c_char, optstr: *const c_char) -> c_int; pub fn getpgrp() -> pid_t; pub fn getpid() -> pid_t; @@ -303,8 +306,8 @@ extern { pub fn getdtablesize() -> c_int; #[cfg_attr(target_os = "macos", link_name = "realpath$DARWIN_EXTSN")] - pub fn realpath(pathname: *const c_char, resolved: *mut c_char) - -> *mut c_char; + pub fn realpath(pathname: *const ::c_char, resolved: *mut ::c_char) + -> *mut ::c_char; pub fn flock(fd: c_int, operation: c_int) -> c_int; } @@ -318,7 +321,7 @@ extern { flags: c_int, errfunc: ::dox::Option<extern "C" fn(epath: *const c_char, errno: c_int) -> c_int>, - pglob: *mut glob_t); + pglob: *mut glob_t) -> c_int; pub fn globfree(pglob: *mut glob_t); pub fn posix_madvise(addr: *mut ::c_void, len: size_t, advice: c_int) @@ -371,6 +374,88 @@ extern { pub fn recv(socket: c_int, buf: *mut ::c_void, len: size_t, flags: c_int) -> ssize_t; pub fn mkfifo(path: *const c_char, mode: mode_t) -> c_int; + pub fn gettimeofday(tp: *mut ::timeval, + tz: *mut ::c_void) -> ::c_int; + + 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; + pub fn pthread_join(native: ::pthread_t, + value: *mut *mut ::c_void) -> ::c_int; + pub fn pthread_attr_init(attr: *mut ::pthread_attr_t) -> ::c_int; + pub fn pthread_attr_destroy(attr: *mut ::pthread_attr_t) -> ::c_int; + pub fn pthread_attr_setstacksize(attr: *mut ::pthread_attr_t, + stack_size: ::size_t) -> ::c_int; + pub fn pthread_attr_setdetachstate(attr: *mut ::pthread_attr_t, + state: ::c_int) -> ::c_int; + pub fn pthread_detach(thread: ::pthread_t) -> ::c_int; + pub fn sched_yield() -> ::c_int; + pub fn pthread_key_create(key: *mut pthread_key_t, + dtor: Option<unsafe extern fn(*mut ::c_void)>) + -> c_int; + pub fn pthread_key_delete(key: pthread_key_t) -> c_int; + pub fn pthread_getspecific(key: pthread_key_t) -> *mut ::c_void; + pub fn pthread_setspecific(key: pthread_key_t, value: *const ::c_void) + -> c_int; + pub fn pthread_mutex_init(lock: *mut pthread_mutex_t, + attr: *const pthread_mutexattr_t) -> ::c_int; + pub fn pthread_mutex_destroy(lock: *mut pthread_mutex_t) -> ::c_int; + pub fn pthread_mutex_lock(lock: *mut pthread_mutex_t) -> ::c_int; + pub fn pthread_mutex_trylock(lock: *mut pthread_mutex_t) -> ::c_int; + pub fn pthread_mutex_unlock(lock: *mut pthread_mutex_t) -> ::c_int; + + pub fn pthread_mutexattr_init(attr: *mut pthread_mutexattr_t) -> ::c_int; + pub fn pthread_mutexattr_destroy(attr: *mut pthread_mutexattr_t) -> ::c_int; + pub fn pthread_mutexattr_settype(attr: *mut pthread_mutexattr_t, + _type: ::c_int) -> ::c_int; + + pub fn pthread_cond_wait(cond: *mut pthread_cond_t, + lock: *mut pthread_mutex_t) -> ::c_int; + pub fn pthread_cond_timedwait(cond: *mut pthread_cond_t, + lock: *mut pthread_mutex_t, + abstime: *const ::timespec) -> ::c_int; + pub fn pthread_cond_signal(cond: *mut pthread_cond_t) -> ::c_int; + pub fn pthread_cond_broadcast(cond: *mut pthread_cond_t) -> ::c_int; + pub fn pthread_cond_destroy(cond: *mut pthread_cond_t) -> ::c_int; + pub fn pthread_rwlock_destroy(lock: *mut pthread_rwlock_t) -> ::c_int; + pub fn pthread_rwlock_rdlock(lock: *mut pthread_rwlock_t) -> ::c_int; + pub fn pthread_rwlock_tryrdlock(lock: *mut pthread_rwlock_t) -> ::c_int; + pub fn pthread_rwlock_wrlock(lock: *mut pthread_rwlock_t) -> ::c_int; + pub fn pthread_rwlock_trywrlock(lock: *mut pthread_rwlock_t) -> ::c_int; + pub fn pthread_rwlock_unlock(lock: *mut pthread_rwlock_t) -> ::c_int; + pub fn pthread_sigmask(how: ::c_int, set: *const sigset_t, + oldset: *mut sigset_t) -> ::c_int; + + // #[cfg_attr(target_os = "linux", link_name = "__xpg_strerror_r")] + pub fn strerror_r(errnum: c_int, buf: *mut c_char, + buflen: size_t) -> c_int; + + pub fn getsockopt(sockfd: ::c_int, + level: ::c_int, + optname: ::c_int, + optval: *mut ::c_void, + optlen: *mut ::socklen_t) -> ::c_int; + pub fn raise(signum: ::c_int) -> ::c_int; + pub fn sigaction(signum: ::c_int, + act: *const sigaction, + oldact: *mut sigaction) -> ::c_int; + pub fn sigaltstack(ss: *const sigaltstack, + oss: *mut sigaltstack) -> ::c_int; + pub fn sigemptyset(set: *mut sigset_t) -> ::c_int; + + pub fn getpwuid_r(uid: ::uid_t, + pwd: *mut passwd, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut passwd) -> ::c_int; + + pub fn utimes(filename: *const ::c_char, + times: *const ::timeval) -> ::c_int; + pub fn gai_strerror(errcode: ::c_int) -> *const ::c_char; + pub fn setgroups(ngroups: ::size_t, + ptr: *const ::gid_t) -> ::c_int; } cfg_if! { diff --git a/src/unix/notbsd/android.rs b/src/unix/notbsd/android.rs index 96fdc20032..6f4833ce9f 100644 --- a/src/unix/notbsd/android.rs +++ b/src/unix/notbsd/android.rs @@ -22,6 +22,8 @@ pub type nlink_t = u16; pub type useconds_t = i32; pub type socklen_t = i32; pub type pthread_t = c_long; +pub type pthread_mutexattr_t = ::c_long; +pub type sigset_t = c_ulong; s! { pub struct stat { @@ -54,6 +56,63 @@ s! { pub sched_policy: ::int32_t, pub sched_priority: ::int32_t, } + + pub struct pthread_mutex_t { value: ::c_int } + + pub struct pthread_cond_t { value: ::c_int } + + pub struct pthread_rwlock_t { + lock: pthread_mutex_t, + cond: pthread_cond_t, + numLocks: ::c_int, + writerThreadId: ::c_int, + pendingReaders: ::c_int, + pendingWriters: ::c_int, + reserved: [*mut ::c_void; 4], + } + + pub struct passwd { + pub pw_name: *mut ::c_char, + pub pw_passwd: *mut ::c_char, + pub pw_uid: ::uid_t, + pub pw_gid: ::gid_t, + pub pw_dir: *mut ::c_char, + pub pw_shell: *mut ::c_char, + } + + pub struct sigaltstack { + pub ss_sp: *mut ::c_void, + pub ss_flags: ::c_int, + pub ss_size: ::size_t + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_errno: ::c_int, + pub si_code: ::c_int, + pub _pad: [::c_int; 29], + _align: [u64; 0], + } +} + +#[cfg(target_pointer_width = "32")] +s!{ + pub struct sigaction { + pub sa_sigaction: sighandler_t, + pub sa_flags: libc::c_ulong, + _restorer: *mut libc::c_void, + pub sa_mask: sigset_t, + } +} + +#[cfg(target_pointer_width = "64")] +s!{ + pub struct sigaction { + pub sa_flags: libc::c_uint, + pub sa_sigaction: sighandler_t, + pub sa_mask: sigset_t, + _restorer: *mut libc::c_void, + } } pub const BUFSIZ: ::c_uint = 1024; @@ -121,9 +180,33 @@ pub const _SC_THREAD_PRIO_PROTECT: ::c_int = 84; pub const _SC_THREAD_SAFE_FUNCTIONS: ::c_int = 85; pub const PTHREAD_STACK_MIN: ::size_t = 8192; +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + value: 0, +}; +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + value: 0, +}; +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + lock: PTHREAD_MUTEX_INITIALIZER, + cond: PTHREAD_COND_INITIALIZER, + numLocks: 0, + writerThreadId: 0, + pendingReaders: 0, + pendingWriters: 0, + reserved: [0 as *mut _; 4], +}; +pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1; pub const O_SYNC: ::c_int = 0x1000; +pub const FIOCLEX: ::c_ulong = 0x5451; + +pub const SA_ONSTACK: ::c_ulong = 0x08000000; +pub const SA_SIGINFO: ::c_ulong = 0x00000004; + +pub const SIGBUS: ::c_int = 7; +pub const SIG_SETMASK: ::c_int = 2; + extern { pub fn madvise(addr: *const ::c_void, len: ::size_t, advice: ::c_int) -> ::c_int; diff --git a/src/unix/notbsd/linux/mips.rs b/src/unix/notbsd/linux/mips.rs index 75125d4c2e..8364e7bed4 100644 --- a/src/unix/notbsd/linux/mips.rs +++ b/src/unix/notbsd/linux/mips.rs @@ -44,6 +44,31 @@ s! { pub struct pthread_attr_t { __size: [u32; 9] } + + pub struct sigaction { + pub sa_flags: ::c_uint, + pub sa_sigaction: ::sighandler_t, + pub sa_mask: sigset_t, + _restorer: *mut ::c_void, + _resv: [::c_int; 1], + } + + pub struct sigaltstack { + pub ss_sp: *mut ::c_void, + pub ss_size: ::size_t, + pub ss_flags: ::c_int, + } + + pub struct sigset_t { + __val: [::c_ulong; 32], + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_code: ::c_int, + pub si_errno: ::c_int, + pub _pad: [::c_int; 29], + } } pub const RLIMIT_NOFILE: ::c_int = 5; @@ -177,3 +202,15 @@ pub const SO_SNDLOWAT: ::c_int = 4099; pub const SO_RCVTIMEO: ::c_int = 4102; pub const SO_SNDTIMEO: ::c_int = 4101; pub const SO_ACCEPTCONN: ::c_int = 4105; + +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24; +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32; + +pub const FIOCLEX: ::c_ulong = 0x6601; + +pub const SA_ONSTACK: ::c_ulong = 0x08000000; +pub const SA_SIGINFO: ::c_ulong = 0x00000008; + +pub const SIGBUS: ::c_int = 10; + +pub const SIG_SETMASK: ::c_int = 3; diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs index d17f3306a7..e119bbd64e 100644 --- a/src/unix/notbsd/linux/mod.rs +++ b/src/unix/notbsd/linux/mod.rs @@ -28,6 +28,46 @@ s! { pub ifa_ifu: *mut ::sockaddr, // FIXME This should be a union pub ifa_data: *mut ::c_void } + + pub struct pthread_mutex_t { + #[cfg(any(target_arch = "mips", target_arch = "mipsel", + target_arch = "arm"))] + __align: [::c_long; 0], + #[cfg(not(any(target_arch = "mips", target_arch = "mipsel", + target_arch = "arm")))] + __align: [::c_longlong; 0], + size: [u8; __SIZEOF_PTHREAD_MUTEX_T], + } + + pub struct pthread_rwlock_t { + #[cfg(any(target_arch = "mips", target_arch = "mipsel", + target_arch = "arm"))] + __align: [::c_long; 0], + #[cfg(not(any(target_arch = "mips", target_arch = "mipsel", + target_arch = "arm")))] + __align: [::c_longlong; 0], + size: [u8; __SIZEOF_PTHREAD_RWLOCK_T], + } + + pub struct pthread_mutexattr_t { + __align: [::c_int; 0], + size: [u8; __SIZEOF_PTHREAD_MUTEXATTR_T], + } + + pub struct pthread_cond_t { + __align: [::c_longlong; 0], + size: [u8; __SIZEOF_PTHREAD_COND_T], + } + + pub struct passwd { + pub pw_name: *mut ::c_char, + pub pw_passwd: *mut ::c_char, + pub pw_uid: ::uid_t, + pub pw_gid: ::gid_t, + pub pw_gecos: *mut ::c_char, + pub pw_dir: *mut ::c_char, + pub pw_shell: *mut ::c_char, + } } pub const BUFSIZ: ::c_uint = 8192; @@ -160,6 +200,22 @@ pub const MAP_32BIT: ::c_int = 0x0040; pub const TCP_MD5SIG: ::c_int = 14; +pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { + __align: [], + size: [0; __SIZEOF_PTHREAD_MUTEX_T], +}; +pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { + __align: [], + size: [0; __SIZEOF_PTHREAD_COND_T], +}; +pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { + __align: [], + size: [0; __SIZEOF_PTHREAD_RWLOCK_T], +}; +pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 1; +pub const __SIZEOF_PTHREAD_COND_T: usize = 48; +pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; + extern { pub fn shm_open(name: *const c_char, oflag: ::c_int, mode: mode_t) -> ::c_int; @@ -173,6 +229,7 @@ extern { -> ::c_int; pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int; + pub fn __errno_location() -> *mut ::c_int; } cfg_if! { diff --git a/src/unix/notbsd/linux/notmips/b32/mod.rs b/src/unix/notbsd/linux/notmips/b32/mod.rs index 6928962cba..fcf75da464 100644 --- a/src/unix/notbsd/linux/notmips/b32/mod.rs +++ b/src/unix/notbsd/linux/notmips/b32/mod.rs @@ -17,6 +17,9 @@ pub type blksize_t = i32; pub type mode_t = u32; pub type nlink_t = u32; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 24; +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 32; + s! { pub struct stat { pub st_dev: ::dev_t, @@ -44,6 +47,10 @@ s! { pub struct pthread_attr_t { __size: [u32; 9] } + + pub struct sigset_t { + __val: [::c_ulong; 32], + } } cfg_if! { diff --git a/src/unix/notbsd/linux/notmips/b64/aarch64.rs b/src/unix/notbsd/linux/notmips/b64/aarch64.rs index 4bc5293de9..cf23b3fb93 100644 --- a/src/unix/notbsd/linux/notmips/b64/aarch64.rs +++ b/src/unix/notbsd/linux/notmips/b64/aarch64.rs @@ -5,6 +5,8 @@ pub type nlink_t = u32; pub type blksize_t = i32; pub type wchar_t = u32; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 48; + s! { pub struct stat { pub st_dev: ::dev_t, diff --git a/src/unix/notbsd/linux/notmips/b64/mod.rs b/src/unix/notbsd/linux/notmips/b64/mod.rs index 582895b4ff..8f55e09d60 100644 --- a/src/unix/notbsd/linux/notmips/b64/mod.rs +++ b/src/unix/notbsd/linux/notmips/b64/mod.rs @@ -15,6 +15,14 @@ pub type mode_t = u32; pub type ssize_t = i64; pub type blkcnt_t = i64; +s! { + pub struct sigset_t { + __val: [::c_ulong; 16], + } +} + +pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; + cfg_if! { if #[cfg(target_arch = "aarch64")] { mod aarch64; diff --git a/src/unix/notbsd/linux/notmips/b64/x86_64.rs b/src/unix/notbsd/linux/notmips/b64/x86_64.rs index 22d0accb42..fec4a9224d 100644 --- a/src/unix/notbsd/linux/notmips/b64/x86_64.rs +++ b/src/unix/notbsd/linux/notmips/b64/x86_64.rs @@ -5,6 +5,8 @@ pub type nlink_t = u64; pub type blksize_t = i64; pub type wchar_t = i32; +pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; + s! { pub struct stat { pub st_dev: ::dev_t, diff --git a/src/unix/notbsd/linux/notmips/mod.rs b/src/unix/notbsd/linux/notmips/mod.rs index 3b3109c008..d836971758 100644 --- a/src/unix/notbsd/linux/notmips/mod.rs +++ b/src/unix/notbsd/linux/notmips/mod.rs @@ -1,3 +1,25 @@ +s! { + pub struct sigaction { + pub sa_sigaction: ::sighandler_t, + pub sa_mask: ::sigset_t, + pub sa_flags: ::c_int, + _restorer: *mut ::c_void, + } + + pub struct sigaltstack { + pub ss_sp: *mut ::c_void, + pub ss_flags: ::c_int, + pub ss_size: ::size_t + } + + pub struct siginfo_t { + pub si_signo: ::c_int, + pub si_errno: ::c_int, + pub si_code: ::c_int, + pub _pad: [::c_int; 29], + _align: [usize; 0], + } +} pub const RLIMIT_RSS: ::c_int = 5; pub const RLIMIT_NOFILE: ::c_int = 7; @@ -147,6 +169,14 @@ pub const TCP_TIMESTAMP: ::c_int = 24; pub const SO_REUSEPORT: ::c_int = 15; +pub const FIOCLEX: ::c_ulong = 0x5451; + +pub const SA_ONSTACK: ::c_ulong = 0x08000000; +pub const SA_SIGINFO: ::c_ulong = 0x00000004; + +pub const SIGBUS: ::c_int = 7; +pub const SIG_SETMASK: ::c_int = 2; + cfg_if! { if #[cfg(any(target_arch = "x86", target_arch = "arm"))] { mod b32; diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs index 8591420ce5..9cd3f45459 100644 --- a/src/unix/notbsd/mod.rs +++ b/src/unix/notbsd/mod.rs @@ -18,6 +18,7 @@ pub type in_port_t = u16; pub type rlim_t = c_ulong; pub type sa_family_t = u16; pub type sighandler_t = size_t; +pub type pthread_key_t = c_uint; pub enum timezone {} @@ -68,7 +69,7 @@ s! { pub ai_canonname: *mut c_char, - #[cfg(any(target_os = "android", target_os = "nacl"))] + #[cfg(target_os = "android")] pub ai_addr: *mut ::sockaddr, pub ai_next: *mut addrinfo, @@ -105,7 +106,6 @@ pub const F_SETFL: c_int = 4; pub const O_ACCMODE: c_int = 3; pub const SIGTRAP: c_int = 5; -pub const SIG_IGN: size_t = 1; pub const PTHREAD_CREATE_JOINABLE: c_int = 0; pub const PTHREAD_CREATE_DETACHED: c_int = 1; @@ -303,10 +303,21 @@ pub const LOCK_EX: ::c_int = 2; pub const LOCK_NB: ::c_int = 4; pub const LOCK_UN: ::c_int = 8; +pub const SIGSTKSZ: ::size_t = 8192; + extern { pub fn fdatasync(fd: ::c_int) -> ::c_int; pub fn mincore(addr: *mut ::c_void, len: ::size_t, vec: *mut ::c_uchar) -> ::c_int; + pub fn clock_gettime(clk_id: ::c_int, tp: *mut ::timespec) -> ::c_int; + pub fn prctl(option: ::c_int, ...) -> ::c_int; + pub fn pthread_getattr_np(native: ::pthread_t, + attr: *mut ::pthread_attr_t) -> ::c_int; + pub fn pthread_attr_getguardsize(attr: *const ::pthread_attr_t, + guardsize: *mut ::size_t) -> ::c_int; + pub fn pthread_attr_getstack(attr: *const ::pthread_attr_t, + stackaddr: *mut *mut ::c_void, + stacksize: *mut ::size_t) -> ::c_int; } cfg_if! { |