From c618f366f3f55e83c4931f1961bc7c831be529ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Marie?= Date: Mon, 21 Dec 2015 17:26:41 +0100 Subject: [PATCH 01/17] add openbsd support to libc-test --- libc-test/build.rs | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index f94f7051faf29..893c5e889726f 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,9 @@ fn main() { let target2 = target.clone(); cfg.field_name(move |struct_, field| { match field { + "d_namelen" if openbsd && struct_ == "dirent" => "d_namlen".to_string(), + "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 +319,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, From 9e8707902f721828c29c63b7ff280e5522d54aab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Marie?= Date: Mon, 21 Dec 2015 10:43:44 +0100 Subject: [PATCH 02/17] there are no `pw_fields` in `struct passwd` under openbsd --- src/unix/bsd/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 144240d42397c..32418933b4932 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, } From 15cb33670dabbdfa8b253198c08f352db3218fe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Marie?= Date: Mon, 21 Dec 2015 10:52:28 +0100 Subject: [PATCH 03/17] move Dl_info struct per system - under openbsd and bitrig: dli_saddr member is *mut ::c_void - under netbsd: it is *const ::c_void --- src/unix/bsd/openbsdlike/bitrig.rs | 7 +++++++ src/unix/bsd/openbsdlike/mod.rs | 7 ------- src/unix/bsd/openbsdlike/netbsd.rs | 7 +++++++ src/unix/bsd/openbsdlike/openbsd.rs | 7 +++++++ 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/unix/bsd/openbsdlike/bitrig.rs b/src/unix/bsd/openbsdlike/bitrig.rs index e7b0f59c0a80e..da7098dc3f364 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; diff --git a/src/unix/bsd/openbsdlike/mod.rs b/src/unix/bsd/openbsdlike/mod.rs index 85a77dc96c56d..0ca1b27437112 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, diff --git a/src/unix/bsd/openbsdlike/netbsd.rs b/src/unix/bsd/openbsdlike/netbsd.rs index fd3b8c81e5bd8..25afa5009ee65 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; diff --git a/src/unix/bsd/openbsdlike/openbsd.rs b/src/unix/bsd/openbsdlike/openbsd.rs index 28e7a4fe2046c..9ab3d771c3d65 100644 --- a/src/unix/bsd/openbsdlike/openbsd.rs +++ b/src/unix/bsd/openbsdlike/openbsd.rs @@ -102,6 +102,13 @@ s! { pub si_addr: *mut ::c_void, __pad: [u8; 116], } + + 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; From 85008bd38e37e1ef6bb364ffb67c636f4383cbef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Marie?= Date: Mon, 21 Dec 2015 10:57:26 +0100 Subject: [PATCH 04/17] drop undefined constants under openbsd - IPV6_{ADD,DROP}_MEMBERSHIP - HW_AVAILCPU --- src/unix/bsd/openbsdlike/openbsd.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/unix/bsd/openbsdlike/openbsd.rs b/src/unix/bsd/openbsdlike/openbsd.rs index 9ab3d771c3d65..ed2a74d708440 100644 --- a/src/unix/bsd/openbsdlike/openbsd.rs +++ b/src/unix/bsd/openbsdlike/openbsd.rs @@ -147,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; @@ -215,7 +212,6 @@ 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 From 27fd4f8661d7bea74b1784b12782a15f11b59162 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Marie?= Date: Mon, 21 Dec 2015 10:59:43 +0100 Subject: [PATCH 05/17] rename syscalls constants to follow name under openbsd --- src/unix/bsd/openbsdlike/openbsd.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/bsd/openbsdlike/openbsd.rs b/src/unix/bsd/openbsdlike/openbsd.rs index ed2a74d708440..1c1a9430c6c0c 100644 --- a/src/unix/bsd/openbsdlike/openbsd.rs +++ b/src/unix/bsd/openbsdlike/openbsd.rs @@ -215,7 +215,7 @@ pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2; pub const KERN_PROC_ARGS: ::c_int = 55; // syscall numbers -pub const NR_GETENTROPY: ::c_int = 7; +pub const SYS_getentropy: ::c_int = 7; extern { pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int) From 040976b20fd1dbb854e30cfdd49ee684d2f7056f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Marie?= Date: Mon, 21 Dec 2015 13:48:35 +0100 Subject: [PATCH 06/17] change proto (uint -> int) for pthread_*_np() functions - same prototype on bitrig and openbsd - for netbsd, I did found it at all (?) --- src/unix/bsd/openbsdlike/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/unix/bsd/openbsdlike/mod.rs b/src/unix/bsd/openbsdlike/mod.rs index 0ca1b27437112..1e23be6bff599 100644 --- a/src/unix/bsd/openbsdlike/mod.rs +++ b/src/unix/bsd/openbsdlike/mod.rs @@ -364,10 +364,10 @@ extern { 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; } From 3465481a8c63b615a3f4fcbd0a11e4a920e0de69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Marie?= Date: Mon, 21 Dec 2015 13:52:29 +0100 Subject: [PATCH 07/17] more proto change on openbsd - sysctl: *mut -> *const - mprotect: *const -> *mut - remove sysctlbyname() that don't exists under openbsd --- src/unix/bsd/openbsdlike/openbsd.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/unix/bsd/openbsdlike/openbsd.rs b/src/unix/bsd/openbsdlike/openbsd.rs index 1c1a9430c6c0c..a3489ca9b6bed 100644 --- a/src/unix/bsd/openbsdlike/openbsd.rs +++ b/src/unix/bsd/openbsdlike/openbsd.rs @@ -218,19 +218,13 @@ pub const KERN_PROC_ARGS: ::c_int = 55; pub const SYS_getentropy: ::c_int = 7; extern { - pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::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; } From 5f75552056f9cdf433e4f1d936f777b1984f0c8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Marie?= Date: Mon, 21 Dec 2015 14:58:28 +0100 Subject: [PATCH 08/17] change proto for getnameinfo() arguments `hostlen' and `servlen' are `socklen_t' or `size_t' depending the platform - apple: I don't known, so I don't change the original definition (socklen_t) - netbsd: socklen_t - freebsd: size_t - dragonfly: size_t - openbsd: size_t - bitrig: size_t --- src/unix/bsd/apple/mod.rs | 7 +++++++ src/unix/bsd/freebsdlike/mod.rs | 7 +++++++ src/unix/bsd/mod.rs | 7 ------- src/unix/bsd/openbsdlike/bitrig.rs | 7 +++++++ src/unix/bsd/openbsdlike/netbsd.rs | 7 +++++++ src/unix/bsd/openbsdlike/openbsd.rs | 7 +++++++ 6 files changed, 35 insertions(+), 7 deletions(-) diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 378fc4b771b55..8383e25f8f23b 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -810,6 +810,13 @@ pub const IUTF8: ::tcflag_t = 0x00004000; pub const CRTSCTS: ::tcflag_t = 0x00030000; 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 508fc6b72ce5e..7ec8578ffaead 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -558,6 +558,13 @@ pub const ST_NOSUID: ::c_ulong = 2; pub const HW_AVAILCPU: ::c_int = 25; 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 32418933b4932..361fa1e3f6546 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -322,13 +322,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 da7098dc3f364..c9fb4e70d0584 100644 --- a/src/unix/bsd/openbsdlike/bitrig.rs +++ b/src/unix/bsd/openbsdlike/bitrig.rs @@ -216,6 +216,13 @@ pub const HW_AVAILCPU: ::c_int = 25; pub const KERN_PROC_ARGS: ::c_int = 55; 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/netbsd.rs b/src/unix/bsd/openbsdlike/netbsd.rs index 25afa5009ee65..ee3efcc80a4d1 100644 --- a/src/unix/bsd/openbsdlike/netbsd.rs +++ b/src/unix/bsd/openbsdlike/netbsd.rs @@ -321,6 +321,13 @@ pub const NOTE_PCTRLMASK: ::uint32_t = 0xf0000000; pub const CRTSCTS: ::tcflag_t = 0x00010000; 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 a3489ca9b6bed..088de2ebbef62 100644 --- a/src/unix/bsd/openbsdlike/openbsd.rs +++ b/src/unix/bsd/openbsdlike/openbsd.rs @@ -218,6 +218,13 @@ pub const KERN_PROC_ARGS: ::c_int = 55; pub const SYS_getentropy: ::c_int = 7; 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: *mut ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int; pub fn sysctl(name: *const ::c_int, From c5eadb32939c1bcd2d1ccd29d9000a6d5a533749 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Marie?= Date: Mon, 21 Dec 2015 15:58:52 +0100 Subject: [PATCH 09/17] remove backtrace() prototype that don't exists under - openbsd - bitrig - netbsd --- src/unix/bsd/openbsdlike/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/unix/bsd/openbsdlike/mod.rs b/src/unix/bsd/openbsdlike/mod.rs index 1e23be6bff599..d11646e10d66c 100644 --- a/src/unix/bsd/openbsdlike/mod.rs +++ b/src/unix/bsd/openbsdlike/mod.rs @@ -361,7 +361,6 @@ 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_int; From d732678ddc57f9a7967ca1f3a539d0008d743aea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Marie?= Date: Mon, 21 Dec 2015 16:35:41 +0100 Subject: [PATCH 10/17] change type size to match openbsd C --- src/unix/bsd/openbsdlike/openbsd.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/unix/bsd/openbsdlike/openbsd.rs b/src/unix/bsd/openbsdlike/openbsd.rs index 088de2ebbef62..6a8ee59a222c0 100644 --- a/src/unix/bsd/openbsdlike/openbsd.rs +++ b/src/unix/bsd/openbsdlike/openbsd.rs @@ -3,8 +3,8 @@ 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 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; From b1a108c245a46ed69b8d3ad743aa5fd712431eca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Marie?= Date: Mon, 21 Dec 2015 16:42:08 +0100 Subject: [PATCH 11/17] change sign for `blksize_t` type under openbsd --- src/unix/bsd/openbsdlike/openbsd.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/bsd/openbsdlike/openbsd.rs b/src/unix/bsd/openbsdlike/openbsd.rs index 6a8ee59a222c0..87e2567eabc62 100644 --- a/src/unix/bsd/openbsdlike/openbsd.rs +++ b/src/unix/bsd/openbsdlike/openbsd.rs @@ -2,7 +2,7 @@ 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 blksize_t = ::int32_t; pub type fsblkcnt_t = ::uint64_t; pub type fsfilcnt_t = ::uint64_t; pub type pthread_attr_t = *mut ::c_void; From 6dc38681a66b51788ffdc44bf782f98e6b21a938 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Marie?= Date: Mon, 21 Dec 2015 16:51:42 +0100 Subject: [PATCH 12/17] use proper type of si_addr in siginfo_t under openbsd it is a `caddr_t` which expand to `char *`. as the size of the type change, adjust the padding too. --- src/unix/bsd/openbsdlike/openbsd.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/unix/bsd/openbsdlike/openbsd.rs b/src/unix/bsd/openbsdlike/openbsd.rs index 87e2567eabc62..f1f4cbcb2cab5 100644 --- a/src/unix/bsd/openbsdlike/openbsd.rs +++ b/src/unix/bsd/openbsdlike/openbsd.rs @@ -99,8 +99,8 @@ 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 { From 0f8571b63deb5426ee40290672bd22db98270817 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Marie?= Date: Mon, 21 Dec 2015 17:10:32 +0100 Subject: [PATCH 13/17] properly define SIGSTKSZ under openbsd --- src/unix/bsd/openbsdlike/openbsd.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/bsd/openbsdlike/openbsd.rs b/src/unix/bsd/openbsdlike/openbsd.rs index f1f4cbcb2cab5..2e78062478b79 100644 --- a/src/unix/bsd/openbsdlike/openbsd.rs +++ b/src/unix/bsd/openbsdlike/openbsd.rs @@ -201,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; From 3de62ef5a7810b033a48793c831e2c1d43c5114a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Marie?= Date: Mon, 21 Dec 2015 17:15:52 +0100 Subject: [PATCH 14/17] define TMP_MAX differently for openbsdlike --- src/unix/bsd/openbsdlike/bitrig.rs | 2 ++ src/unix/bsd/openbsdlike/mod.rs | 1 - src/unix/bsd/openbsdlike/netbsd.rs | 2 ++ src/unix/bsd/openbsdlike/openbsd.rs | 2 ++ 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/unix/bsd/openbsdlike/bitrig.rs b/src/unix/bsd/openbsdlike/bitrig.rs index c9fb4e70d0584..5b0635e051a8a 100644 --- a/src/unix/bsd/openbsdlike/bitrig.rs +++ b/src/unix/bsd/openbsdlike/bitrig.rs @@ -215,6 +215,8 @@ 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; + extern { pub fn getnameinfo(sa: *const ::sockaddr, salen: ::socklen_t, diff --git a/src/unix/bsd/openbsdlike/mod.rs b/src/unix/bsd/openbsdlike/mod.rs index d11646e10d66c..72d681c86d671 100644 --- a/src/unix/bsd/openbsdlike/mod.rs +++ b/src/unix/bsd/openbsdlike/mod.rs @@ -57,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; diff --git a/src/unix/bsd/openbsdlike/netbsd.rs b/src/unix/bsd/openbsdlike/netbsd.rs index ee3efcc80a4d1..87e1655ca0537 100644 --- a/src/unix/bsd/openbsdlike/netbsd.rs +++ b/src/unix/bsd/openbsdlike/netbsd.rs @@ -320,6 +320,8 @@ pub const NOTE_PCTRLMASK: ::uint32_t = 0xf0000000; pub const CRTSCTS: ::tcflag_t = 0x00010000; +pub const TMP_MAX : ::c_uint = 308915776; + extern { pub fn getnameinfo(sa: *const ::sockaddr, salen: ::socklen_t, diff --git a/src/unix/bsd/openbsdlike/openbsd.rs b/src/unix/bsd/openbsdlike/openbsd.rs index 2e78062478b79..897b5fbd7586b 100644 --- a/src/unix/bsd/openbsdlike/openbsd.rs +++ b/src/unix/bsd/openbsdlike/openbsd.rs @@ -214,6 +214,8 @@ pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2; pub const KERN_PROC_ARGS: ::c_int = 55; +pub const TMP_MAX : ::c_uint = 0x7fffffff; + // syscall numbers pub const SYS_getentropy: ::c_int = 7; From ee8c0500715a2476f17a31d1bbee125f75258d46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Marie?= Date: Mon, 21 Dec 2015 17:24:46 +0100 Subject: [PATCH 15/17] define NI_MAXHOST per system - under openbsd/bitrig it is 256 - change type to `size_t` where system have `getnameinfo()` with `hostlen` as `size_t` --- src/unix/bsd/apple/mod.rs | 2 ++ src/unix/bsd/freebsdlike/mod.rs | 2 ++ src/unix/bsd/mod.rs | 2 -- src/unix/bsd/openbsdlike/bitrig.rs | 2 ++ src/unix/bsd/openbsdlike/netbsd.rs | 2 ++ src/unix/bsd/openbsdlike/openbsd.rs | 2 ++ 6 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 8383e25f8f23b..406acd10119b3 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -809,6 +809,8 @@ 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, diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 7ec8578ffaead..d41829ceb20ea 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -557,6 +557,8 @@ 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, diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 361fa1e3f6546..5dd890abb522e 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -147,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; diff --git a/src/unix/bsd/openbsdlike/bitrig.rs b/src/unix/bsd/openbsdlike/bitrig.rs index 5b0635e051a8a..ecb0bfdab93ea 100644 --- a/src/unix/bsd/openbsdlike/bitrig.rs +++ b/src/unix/bsd/openbsdlike/bitrig.rs @@ -217,6 +217,8 @@ 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, diff --git a/src/unix/bsd/openbsdlike/netbsd.rs b/src/unix/bsd/openbsdlike/netbsd.rs index 87e1655ca0537..f2a10f4c7b19c 100644 --- a/src/unix/bsd/openbsdlike/netbsd.rs +++ b/src/unix/bsd/openbsdlike/netbsd.rs @@ -322,6 +322,8 @@ 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, diff --git a/src/unix/bsd/openbsdlike/openbsd.rs b/src/unix/bsd/openbsdlike/openbsd.rs index 897b5fbd7586b..e0dc826890bac 100644 --- a/src/unix/bsd/openbsdlike/openbsd.rs +++ b/src/unix/bsd/openbsdlike/openbsd.rs @@ -216,6 +216,8 @@ pub const KERN_PROC_ARGS: ::c_int = 55; pub const TMP_MAX : ::c_uint = 0x7fffffff; +pub const NI_MAXHOST: ::size_t = 256; + // syscall numbers pub const SYS_getentropy: ::c_int = 7; From 6b847426de2ba3eadfd5d1d38d9215a1d2fe33c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Marie?= Date: Tue, 22 Dec 2015 08:10:48 +0100 Subject: [PATCH 16/17] provide getentropy(2) instead of SYS_entropy SYS_entropy is internal and may more easily change than getentropy(2). --- src/unix/bsd/openbsdlike/openbsd.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/unix/bsd/openbsdlike/openbsd.rs b/src/unix/bsd/openbsdlike/openbsd.rs index e0dc826890bac..ac1116417c5d5 100644 --- a/src/unix/bsd/openbsdlike/openbsd.rs +++ b/src/unix/bsd/openbsdlike/openbsd.rs @@ -218,9 +218,6 @@ pub const TMP_MAX : ::c_uint = 0x7fffffff; pub const NI_MAXHOST: ::size_t = 256; -// syscall numbers -pub const SYS_getentropy: ::c_int = 7; - extern { pub fn getnameinfo(sa: *const ::sockaddr, salen: ::socklen_t, @@ -238,4 +235,5 @@ extern { newp: *mut ::c_void, newlen: ::size_t) -> ::c_int; + pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int; } From 6c8a63a9e24676857d40a3dd4f7631c7a2d0c682 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Marie?= Date: Wed, 23 Dec 2015 18:54:25 +0100 Subject: [PATCH 17/17] keep openbsd name for dirent field member --- libc-test/build.rs | 3 +-- src/unix/bsd/openbsdlike/openbsd.rs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 893c5e889726f..9959821a981b1 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -213,8 +213,7 @@ fn main() { let target2 = target.clone(); cfg.field_name(move |struct_, field| { match field { - "d_namelen" if openbsd && struct_ == "dirent" => "d_namlen".to_string(), - "st_birthtime" if openbsd && struct_ == "stat" => "__st_birthtime".to_string(), + "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 diff --git a/src/unix/bsd/openbsdlike/openbsd.rs b/src/unix/bsd/openbsdlike/openbsd.rs index ac1116417c5d5..fddde4506fee9 100644 --- a/src/unix/bsd/openbsdlike/openbsd.rs +++ b/src/unix/bsd/openbsdlike/openbsd.rs @@ -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], }