summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2016-01-10 14:19:17 -0800
committerAlex Crichton <alex@alexcrichton.com>2016-01-10 14:19:17 -0800
commit0e67fabda37271b5d122daf65c74df8433bb4b4e (patch)
treecba9821589808b9008f2e224e5192b23d48609d7
parent52f4f39a77fb88fc7147256642edeae18bf08bc5 (diff)
parent6c8a63a9e24676857d40a3dd4f7631c7a2d0c682 (diff)
downloadrust-libc-0e67fabda37271b5d122daf65c74df8433bb4b4e.tar.gz
Merge branch 'openbsd-cleanup' of https://github.com/semarie/libc into merge
-rw-r--r--libc-test/build.rs23
-rw-r--r--src/unix/bsd/apple/mod.rs9
-rw-r--r--src/unix/bsd/freebsdlike/mod.rs9
-rw-r--r--src/unix/bsd/mod.rs12
-rw-r--r--src/unix/bsd/openbsdlike/bitrig.rs18
-rw-r--r--src/unix/bsd/openbsdlike/mod.rs13
-rw-r--r--src/unix/bsd/openbsdlike/netbsd.rs18
-rw-r--r--src/unix/bsd/openbsdlike/openbsd.rs48
8 files changed, 104 insertions, 46 deletions
diff --git a/libc-test/build.rs b/libc-test/build.rs
index f94f7051fa..9959821a98 100644
--- a/libc-test/build.rs
+++ b/libc-test/build.rs
@@ -16,8 +16,9 @@ fn main() {
let freebsd = target.contains("freebsd");
let mips = target.contains("mips");
let netbsd = target.contains("netbsd");
+ let openbsd = target.contains("openbsd");
let rumprun = target.contains("rumprun");
- let bsdlike = freebsd || apple || netbsd;
+ let bsdlike = freebsd || apple || netbsd || openbsd;
let mut cfg = ctest::TestGenerator::new();
// Pull in extra goodies on linux/mingw
@@ -61,6 +62,9 @@ fn main() {
} else {
cfg.header("ctype.h");
cfg.header("dirent.h");
+ if openbsd {
+ cfg.header("sys/socket.h");
+ }
cfg.header("net/if.h");
cfg.header("netdb.h");
cfg.header("netinet/in.h");
@@ -96,13 +100,15 @@ fn main() {
} else if !windows {
cfg.header("glob.h");
cfg.header("ifaddrs.h");
- cfg.header("sys/quota.h");
+ if !openbsd {
+ cfg.header("sys/quota.h");
+ }
cfg.header("sys/statvfs.h");
if !musl {
cfg.header("sys/sysctl.h");
- if !netbsd {
+ if !netbsd && !openbsd {
cfg.header("execinfo.h");
}
}
@@ -161,6 +167,13 @@ fn main() {
cfg.header("sys/ioctl_compat.h");
}
+ if openbsd {
+ cfg.header("ufs/ufs/quota.h");
+ cfg.header("rpcsvc/rex.h");
+ cfg.header("pthread_np.h");
+ cfg.header("sys/syscall.h");
+ }
+
cfg.type_name(move |ty, is_struct| {
match ty {
// Just pass all these through, no need for a "struct" prefix
@@ -200,6 +213,8 @@ fn main() {
let target2 = target.clone();
cfg.field_name(move |struct_, field| {
match field {
+ "st_birthtime" if openbsd && struct_ == "stat" => "__st_birthtime".to_string(),
+ "st_birthtime_nsec" if openbsd && struct_ == "stat" => "__st_birthtimensec".to_string(),
// Our stat *_nsec fields normally don't actually exist but are part
// of a timeval struct
s if s.ends_with("_nsec") && struct_.starts_with("stat") => {
@@ -303,7 +318,7 @@ fn main() {
"strerror_r" if linux => true, // actually xpg-something-or-other
// typed 2nd arg on linux and android
- "gettimeofday" if linux || android || freebsd => true,
+ "gettimeofday" if linux || android || freebsd || openbsd => true,
// not declared in newer android toolchains
"getdtablesize" if android => true,
diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs
index 378fc4b771..406acd1011 100644
--- a/src/unix/bsd/apple/mod.rs
+++ b/src/unix/bsd/apple/mod.rs
@@ -809,7 +809,16 @@ pub const VT1: ::c_int = 0x00010000;
pub const IUTF8: ::tcflag_t = 0x00004000;
pub const CRTSCTS: ::tcflag_t = 0x00030000;
+pub const NI_MAXHOST: ::socklen_t = 1025;
+
extern {
+ pub fn getnameinfo(sa: *const ::sockaddr,
+ salen: ::socklen_t,
+ host: *mut ::c_char,
+ hostlen: ::socklen_t,
+ serv: *mut ::c_char,
+ sevlen: ::socklen_t,
+ flags: ::c_int) -> ::c_int;
pub fn mincore(addr: *const ::c_void, len: ::size_t,
vec: *mut ::c_char) -> ::c_int;
pub fn sysctlnametomib(name: *const ::c_char,
diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs
index 508fc6b72c..d41829ceb2 100644
--- a/src/unix/bsd/freebsdlike/mod.rs
+++ b/src/unix/bsd/freebsdlike/mod.rs
@@ -557,7 +557,16 @@ pub const ST_NOSUID: ::c_ulong = 2;
pub const HW_AVAILCPU: ::c_int = 25;
+pub const NI_MAXHOST: ::size_t = 1025;
+
extern {
+ pub fn getnameinfo(sa: *const ::sockaddr,
+ salen: ::socklen_t,
+ host: *mut ::c_char,
+ hostlen: ::size_t,
+ serv: *mut ::c_char,
+ servlen: ::size_t,
+ flags: ::c_int) -> ::c_int;
pub fn mincore(addr: *const ::c_void, len: ::size_t,
vec: *mut ::c_char) -> ::c_int;
pub fn sysctlnametomib(name: *const ::c_char,
diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs
index 144240d423..5dd890abb5 100644
--- a/src/unix/bsd/mod.rs
+++ b/src/unix/bsd/mod.rs
@@ -43,7 +43,8 @@ s! {
#[cfg(not(any(target_os = "macos",
target_os = "ios",
- target_os = "netbsd")))]
+ target_os = "netbsd",
+ target_os = "openbsd")))]
pub pw_fields: ::c_int,
}
@@ -146,8 +147,6 @@ pub const IPV6_V6ONLY: ::c_int = 27;
pub const ST_RDONLY: ::c_ulong = 1;
-pub const NI_MAXHOST: ::socklen_t = 1025;
-
pub const CTL_HW: ::c_int = 6;
pub const HW_NCPU: ::c_int = 3;
@@ -321,13 +320,6 @@ extern {
pub fn setgroups(ngroups: ::c_int,
ptr: *const ::gid_t) -> ::c_int;
pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
- pub fn getnameinfo(sa: *const ::sockaddr,
- salen: ::socklen_t,
- host: *mut ::c_char,
- hostlen: ::socklen_t,
- serv: *mut ::c_char,
- sevlen: ::socklen_t,
- flags: ::c_int) -> ::c_int;
pub fn kqueue() -> ::c_int;
pub fn unmount(target: *const ::c_char, arg: ::c_int) -> ::c_int;
pub fn syscall(num: ::c_int, ...) -> ::c_int;
diff --git a/src/unix/bsd/openbsdlike/bitrig.rs b/src/unix/bsd/openbsdlike/bitrig.rs
index e7b0f59c0a..ecb0bfdab9 100644
--- a/src/unix/bsd/openbsdlike/bitrig.rs
+++ b/src/unix/bsd/openbsdlike/bitrig.rs
@@ -99,6 +99,13 @@ s! {
pub si_errno: ::c_int,
pub si_addr: *mut ::c_void
}
+
+ pub struct Dl_info {
+ pub dli_fname: *const ::c_char,
+ pub dli_fbase: *mut ::c_void,
+ pub dli_sname: *const ::c_char,
+ pub dli_saddr: *mut ::c_void,
+ }
}
pub const O_CLOEXEC: ::c_int = 0x10000;
@@ -208,7 +215,18 @@ pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2;
pub const HW_AVAILCPU: ::c_int = 25;
pub const KERN_PROC_ARGS: ::c_int = 55;
+pub const TMP_MAX : ::c_uint = 0x7fffffff;
+
+pub const NI_MAXHOST: ::size_t = 256;
+
extern {
+ pub fn getnameinfo(sa: *const ::sockaddr,
+ salen: ::socklen_t,
+ host: *mut ::c_char,
+ hostlen: ::size_t,
+ serv: *mut ::c_char,
+ servlen: ::size_t,
+ flags: ::c_int) -> ::c_int;
pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int)
-> ::c_int;
pub fn sysctl(name: *mut ::c_int,
diff --git a/src/unix/bsd/openbsdlike/mod.rs b/src/unix/bsd/openbsdlike/mod.rs
index 85a77dc96c..72d681c86d 100644
--- a/src/unix/bsd/openbsdlike/mod.rs
+++ b/src/unix/bsd/openbsdlike/mod.rs
@@ -24,13 +24,6 @@ s! {
pub ss_flags: ::c_int,
}
- pub struct Dl_info {
- pub dli_fname: *const ::c_char,
- pub dli_fbase: *mut ::c_void,
- pub dli_sname: *const ::c_char,
- pub dli_saddr: *const ::c_void,
- }
-
pub struct sockaddr_in {
pub sin_len: u8,
pub sin_family: ::sa_family_t,
@@ -64,7 +57,6 @@ pub const BUFSIZ : ::c_uint = 1024;
pub const FOPEN_MAX : ::c_uint = 20;
pub const FILENAME_MAX : ::c_uint = 1024;
pub const L_tmpnam : ::c_uint = 1024;
-pub const TMP_MAX : ::c_uint = 308915776;
pub const O_RDONLY : ::c_int = 0;
pub const O_WRONLY : ::c_int = 1;
pub const O_RDWR : ::c_int = 2;
@@ -368,13 +360,12 @@ extern {
#[cfg_attr(target_os = "netbsd", link_name = "__clock_gettime50")]
pub fn clock_gettime(clk_id: ::c_int, tp: *mut ::timespec) -> ::c_int;
pub fn __errno() -> *mut ::c_int;
- pub fn backtrace(buf: *mut *mut ::c_void, sz: ::size_t) -> ::size_t;
pub fn shm_open(name: *const ::c_char, oflag: ::c_int, mode: ::mode_t)
-> ::c_int;
- pub fn pthread_main_np() -> ::c_uint;
+ pub fn pthread_main_np() -> ::c_int;
pub fn pthread_set_name_np(tid: ::pthread_t, name: *const ::c_char);
pub fn pthread_stackseg_np(thread: ::pthread_t,
- sinfo: *mut ::stack_t) -> ::c_uint;
+ sinfo: *mut ::stack_t) -> ::c_int;
pub fn memrchr(cx: *const ::c_void, c: ::c_int, n: ::size_t) -> *mut ::c_void;
}
diff --git a/src/unix/bsd/openbsdlike/netbsd.rs b/src/unix/bsd/openbsdlike/netbsd.rs
index fd3b8c81e5..f2a10f4c7b 100644
--- a/src/unix/bsd/openbsdlike/netbsd.rs
+++ b/src/unix/bsd/openbsdlike/netbsd.rs
@@ -182,6 +182,13 @@ s! {
pub dqb_btime: ::int32_t,
pub dqb_itime: ::int32_t,
}
+
+ pub struct Dl_info {
+ pub dli_fname: *const ::c_char,
+ pub dli_fbase: *mut ::c_void,
+ pub dli_sname: *const ::c_char,
+ pub dli_saddr: *const ::c_void,
+ }
}
pub const O_CLOEXEC: ::c_int = 0x400000;
@@ -313,7 +320,18 @@ pub const NOTE_PCTRLMASK: ::uint32_t = 0xf0000000;
pub const CRTSCTS: ::tcflag_t = 0x00010000;
+pub const TMP_MAX : ::c_uint = 308915776;
+
+pub const NI_MAXHOST: ::socklen_t = 1025;
+
extern {
+ pub fn getnameinfo(sa: *const ::sockaddr,
+ salen: ::socklen_t,
+ host: *mut ::c_char,
+ hostlen: ::socklen_t,
+ serv: *mut ::c_char,
+ sevlen: ::socklen_t,
+ flags: ::c_int) -> ::c_int;
pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int)
-> ::c_int;
pub fn sysctl(name: *const ::c_int,
diff --git a/src/unix/bsd/openbsdlike/openbsd.rs b/src/unix/bsd/openbsdlike/openbsd.rs
index 28e7a4fe20..fddde4506f 100644
--- a/src/unix/bsd/openbsdlike/openbsd.rs
+++ b/src/unix/bsd/openbsdlike/openbsd.rs
@@ -2,9 +2,9 @@ pub type clock_t = i64;
pub type suseconds_t = i64;
pub type dev_t = i32;
pub type sigset_t = ::c_uint;
-pub type blksize_t = ::uint32_t;
-pub type fsblkcnt_t = ::c_uint;
-pub type fsfilcnt_t = ::c_uint;
+pub type blksize_t = ::int32_t;
+pub type fsblkcnt_t = ::uint64_t;
+pub type fsfilcnt_t = ::uint64_t;
pub type pthread_attr_t = *mut ::c_void;
pub type pthread_mutex_t = *mut ::c_void;
pub type pthread_mutexattr_t = *mut ::c_void;
@@ -17,7 +17,7 @@ s! {
pub d_off: ::off_t,
pub d_reclen: u16,
pub d_type: u8,
- pub d_namelen: u8,
+ pub d_namlen: u8,
__d_padding: [u8; 4],
pub d_name: [::c_char; 256],
}
@@ -99,8 +99,15 @@ s! {
pub si_signo: ::c_int,
pub si_code: ::c_int,
pub si_errno: ::c_int,
- pub si_addr: *mut ::c_void,
- __pad: [u8; 116],
+ pub si_addr: *mut ::c_char,
+ __pad: [u8; 108],
+ }
+
+ pub struct Dl_info {
+ pub dli_fname: *const ::c_char,
+ pub dli_fbase: *mut ::c_void,
+ pub dli_sname: *const ::c_char,
+ pub dli_saddr: *mut ::c_void,
}
}
@@ -140,9 +147,6 @@ pub const EMEDIUMTYPE : ::c_int = 86;
pub const RUSAGE_THREAD: ::c_int = 1;
-pub const IPV6_ADD_MEMBERSHIP: ::c_int = 12;
-pub const IPV6_DROP_MEMBERSHIP: ::c_int = 13;
-
pub const MAP_COPY : ::c_int = 0x0002;
pub const MAP_NOEXTEND : ::c_int = 0x0000;
@@ -197,7 +201,7 @@ pub const _SC_RTSIG_MAX : ::c_int = 66;
pub const _SC_SIGQUEUE_MAX : ::c_int = 70;
pub const _SC_TIMER_MAX : ::c_int = 93;
-pub const SIGSTKSZ: ::size_t = 131072;
+pub const SIGSTKSZ: ::size_t = 40960;
pub const FD_SETSIZE: usize = 1024;
@@ -208,26 +212,28 @@ 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;
-pub const HW_AVAILCPU: ::c_int = 25;
pub const KERN_PROC_ARGS: ::c_int = 55;
-// syscall numbers
-pub const NR_GETENTROPY: ::c_int = 7;
+pub const TMP_MAX : ::c_uint = 0x7fffffff;
+
+pub const NI_MAXHOST: ::size_t = 256;
extern {
- pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int)
+ pub fn getnameinfo(sa: *const ::sockaddr,
+ salen: ::socklen_t,
+ host: *mut ::c_char,
+ hostlen: ::size_t,
+ serv: *mut ::c_char,
+ servlen: ::size_t,
+ flags: ::c_int) -> ::c_int;
+ pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int)
-> ::c_int;
- pub fn sysctl(name: *mut ::c_int,
+ pub fn sysctl(name: *const ::c_int,
namelen: ::c_uint,
oldp: *mut ::c_void,
oldlenp: *mut ::size_t,
newp: *mut ::c_void,
newlen: ::size_t)
-> ::c_int;
- pub fn sysctlbyname(name: *const ::c_char,
- oldp: *mut ::c_void,
- oldlenp: *mut ::size_t,
- newp: *mut ::c_void,
- newlen: ::size_t)
- -> ::c_int;
+ pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int;
}