From a6a64d17a0dff216c58b20beadcfee9b519fabdc Mon Sep 17 00:00:00 2001 From: Michael Neumann Date: Sat, 20 Feb 2016 13:34:01 +0100 Subject: [PATCH] Squashed commit of the following: Running libc-test: PASSED 3426 tests commit 1a7ee714db34f17abd33dc9262d3e10275eec68d Author: Michael Neumann Date: Sat Feb 20 13:30:56 2016 +0100 Fix RLIM_POSIXLOCKS -> RLIMIT_POSIXLOCKS commit 09c49a97ebebf087486659ef8277610d99e5c7b3 Author: Michael Neumann Date: Sat Feb 20 13:29:24 2016 +0100 Ignore signedness check for uuid_t on DragonFly commit aab4d11f59917686280c271683bf00ff34c8040d Author: Michael Neumann Date: Sat Feb 20 13:23:21 2016 +0100 Move FreeBSD-only function into freebsd/mod.rs commit 9921f030b103dbccb37930ab1d64cf1dd587bd48 Author: Michael Neumann Date: Sat Feb 20 13:21:42 2016 +0100 Move POSIX_FADV_* to freebsd/mod.rs commit 2921c2db1e3d0314375aa371936bd227cc6c6e2a Author: Michael Neumann Date: Sat Feb 20 13:20:11 2016 +0100 Fix signedness of blksize_t for DragonFly commit 65e817baee9e01d2d7c86c6202c63ee46d218914 Author: Michael Neumann Date: Sat Feb 20 13:19:02 2016 +0100 Fix Q_{GET,SET}QUOTA for DragonFly commit a0d2d63ef88206d321222140ae6b3d92c93b51bd Author: Michael Neumann Date: Sat Feb 20 13:17:27 2016 +0100 Fix RLIMIT_* for DragonFly commit d04a1600a7c66a792a481e1524a1652234a69939 Author: Michael Neumann Date: Sat Feb 20 13:12:09 2016 +0100 Fix ELAST for DragonFly commit d120b9278426a76ee106e91e6c999885c1f5c7f4 Author: Michael Neumann Date: Sat Feb 20 13:10:28 2016 +0100 Fix F_GETLK, F_SETLK, F_SETLKW for DragonFly commit 963f7da270a14f4d12ea1a52301e363ce745c897 Author: Michael Neumann Date: Sat Feb 20 13:08:51 2016 +0100 Fix O_CLOEXEC for DragonFly commit f4d6c9d5991d690c7cb4460790a8e37e713bc034 Author: Michael Neumann Date: Sat Feb 20 13:07:18 2016 +0100 Fix RAND_MAX for DragonFly commit ba48336da7be613a49702ad9de445ab3850ebb7c Author: Michael Neumann Date: Sat Feb 20 13:04:48 2016 +0100 Fix statvfs for DragonFly commit 9ae480c60a7d77b31a17d34320464f4179e40a4a Author: Michael Neumann Date: Sat Feb 20 12:51:47 2016 +0100 Fix fd_set for DragonFly commit a15e027838288c4980371c503252cca7e32356c0 Author: Michael Neumann Date: Sat Feb 20 12:42:24 2016 +0100 Fix all remaining issues on DragonFly Missing functions and missing constats. commit 3966e4fce0cb81bd0b3ed8cdf50611e6982f7767 Author: Michael Neumann Date: Sat Feb 20 12:27:14 2016 +0100 Use a macro instead of a constant. When using a constant, the libc-test thinks this constant exists as an C equivalent. commit 9b5659aaf54419f317250cb3a4692a1c14fdbc33 Author: Michael Neumann Date: Sat Feb 20 12:21:01 2016 +0100 Use a constant in utsname commit 50484eda3c978a9c0a9652f6fc619c41ad349c2d Author: Michael Neumann Date: Sat Feb 20 12:17:55 2016 +0100 Fix struct utsname commit 832e94248fabc91574d6d42630168da3542c153f Author: Michael Neumann Date: Sat Feb 20 12:07:08 2016 +0100 DragonFly has different stat, dirent, clock_t, ino_t, nlink_t, blksize_t commit f3152a369d75ae8c1558afa5a59aa55e33b33ec6 Author: Michael Neumann Date: Sat Feb 20 11:52:54 2016 +0100 Move DragonFly related stuff into dragonfly/* Replicate x86_64.rs from FreeBSD. Need some twists. commit 9fe35124064aa92303171d019004df119f948223 Author: Michael Neumann Date: Sat Feb 20 11:49:38 2016 +0100 Move FreeBSD code under freebsd/*. Next commit will replicate some of the architecture dependent stuff for DragonFly. commit e91983df8deb14004f7a0fe47878f0e4eb31198d Author: Michael Neumann Date: Sat Feb 20 11:44:25 2016 +0100 struct utsname has a different size on DragonFly --- libc-test/build.rs | 19 ++++- src/unix/bsd/freebsdlike/dragonfly.rs | 11 --- src/unix/bsd/freebsdlike/dragonfly/mod.rs | 76 ++++++++++++++++++ src/unix/bsd/freebsdlike/dragonfly/x86_64.rs | 31 +++++++ src/unix/bsd/freebsdlike/freebsd.rs | 13 --- src/unix/bsd/freebsdlike/freebsd/mod.rs | 80 +++++++++++++++++++ src/unix/bsd/freebsdlike/{ => freebsd}/x86.rs | 0 .../bsd/freebsdlike/{ => freebsd}/x86_64.rs | 0 src/unix/bsd/freebsdlike/mod.rs | 76 +++--------------- src/unix/bsd/mod.rs | 19 +++-- 10 files changed, 225 insertions(+), 100 deletions(-) delete mode 100644 src/unix/bsd/freebsdlike/dragonfly.rs create mode 100644 src/unix/bsd/freebsdlike/dragonfly/mod.rs create mode 100644 src/unix/bsd/freebsdlike/dragonfly/x86_64.rs delete mode 100644 src/unix/bsd/freebsdlike/freebsd.rs create mode 100644 src/unix/bsd/freebsdlike/freebsd/mod.rs rename src/unix/bsd/freebsdlike/{ => freebsd}/x86.rs (100%) rename src/unix/bsd/freebsdlike/{ => freebsd}/x86_64.rs (100%) diff --git a/libc-test/build.rs b/libc-test/build.rs index 9c3b5926..e7ba18d2 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -14,11 +14,12 @@ fn main() { let apple = target.contains("apple"); let musl = target.contains("musl"); let freebsd = target.contains("freebsd"); + let dragonfly = target.contains("dragonfly"); 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 || openbsd; + let bsdlike = freebsd || apple || netbsd || openbsd || dragonfly; let mut cfg = ctest::TestGenerator::new(); // Pull in extra goodies on linux/mingw @@ -103,7 +104,7 @@ fn main() { cfg.header("ifaddrs.h"); cfg.header("sys/statvfs.h"); - if !openbsd && !freebsd { + if !openbsd && !freebsd && !dragonfly { cfg.header("sys/quota.h"); } @@ -177,6 +178,12 @@ fn main() { cfg.header("sys/syscall.h"); } + if dragonfly { + cfg.header("ufs/ufs/quota.h"); + cfg.header("pthread_np.h"); + cfg.header("sys/ioctl_compat.h"); + } + cfg.type_name(move |ty, is_struct| { match ty { // Just pass all these through, no need for a "struct" prefix @@ -192,6 +199,9 @@ fn main() { // OSX calls this something else "sighandler_t" if bsdlike => "sig_t".to_string(), + // does not exist on DragonFly + "fflags_t" if dragonfly => "uint32_t".to_string(), + t if t.ends_with("_t") => t.to_string(), // Windows uppercase structs don't have `struct` in front, there's a @@ -254,12 +264,13 @@ fn main() { } }); - cfg.skip_signededness(|c| { + cfg.skip_signededness(move |c| { match c { "LARGE_INTEGER" | "mach_timebase_info_data_t" | "float" | "double" => true, + "uuid_t" if dragonfly => true, n if n.starts_with("pthread") => true, // windows-isms @@ -321,7 +332,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 || openbsd => true, + "gettimeofday" if linux || android || freebsd || openbsd || dragonfly => true, // not declared in newer android toolchains "getdtablesize" if android => true, diff --git a/src/unix/bsd/freebsdlike/dragonfly.rs b/src/unix/bsd/freebsdlike/dragonfly.rs deleted file mode 100644 index a06d232f..00000000 --- a/src/unix/bsd/freebsdlike/dragonfly.rs +++ /dev/null @@ -1,11 +0,0 @@ -pub type fsblkcnt_t = ::c_uint; -pub type fsfilcnt_t = ::c_uint; - -pub const PTHREAD_STACK_MIN: ::size_t = 1024; -pub const KERN_PROC_PATHNAME: ::c_int = 9; -pub const SIGSTKSZ: ::size_t = 40960; -pub const MADV_INVAL: ::c_int = 10; - -extern { - pub fn __dfly_error() -> *const ::c_int; -} diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs new file mode 100644 index 00000000..b647bc74 --- /dev/null +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -0,0 +1,76 @@ +cfg_if! { + if #[cfg(target_arch = "x86_64")] { + mod x86_64; + pub use self::x86_64::*; + } else { + // ... + } +} + +pub type clock_t = u64; +pub type ino_t = u64; +pub type nlink_t = u32; +pub type blksize_t = i64; + +s! { + pub struct dirent { + pub d_fileno: ::ino_t, + pub d_namlen: u16, + pub d_type: u8, + __unused1: u8, + __unused2: u32, + pub d_name: [::c_char; 256], + } + + pub struct uuid { + time_low: u32, + time_mid: u16, + time_hi_and_version: u16, + clock_seq_hi_and_reserved: u8, + clock_seq_low: u8, + node: [u8; 6], + } + + pub struct statvfs { + pub f_bsize: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_blocks: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_bavail: ::fsblkcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_favail: ::fsfilcnt_t, + pub f_fsid: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_namemax: ::c_ulong, + pub f_owner: ::uid_t, + pub f_type: ::c_uint, + pub f_syncreads: u64, + pub f_syncwrites: u64, + pub f_asyncreads: u64, + pub f_asyncwrites: u64, + pub f_fsid_uuid: ::uuid_t, + pub f_uid_uuid: ::uuid_t, + } +} + +pub type uuid_t = ::uuid; + +pub type fsblkcnt_t = u64; +pub type fsfilcnt_t = u64; + +pub const RAND_MAX: ::c_int = 0x7fff_ffff; +pub const PTHREAD_STACK_MIN: ::size_t = 1024; +pub const KERN_PROC_PATHNAME: ::c_int = 9; +pub const SIGSTKSZ: ::size_t = 40960; +pub const MADV_INVAL: ::c_int = 10; +pub const O_CLOEXEC: ::c_int = 0x00020000; +pub const F_GETLK: ::c_int = 7; +pub const F_SETLK: ::c_int = 8; +pub const F_SETLKW: ::c_int = 9; +pub const ELAST: ::c_int = 99; +pub const RLIMIT_POSIXLOCKS: ::c_int = 11; +pub const RLIM_NLIMITS: ::rlim_t = 12; + +pub const Q_GETQUOTA: ::c_int = 0x300; +pub const Q_SETQUOTA: ::c_int = 0x400; diff --git a/src/unix/bsd/freebsdlike/dragonfly/x86_64.rs b/src/unix/bsd/freebsdlike/dragonfly/x86_64.rs new file mode 100644 index 00000000..2372d2b8 --- /dev/null +++ b/src/unix/bsd/freebsdlike/dragonfly/x86_64.rs @@ -0,0 +1,31 @@ +pub type c_long = i64; +pub type c_ulong = u64; +pub type time_t = i64; +pub type suseconds_t = i64; + +s! { + pub struct stat { + pub st_ino: ::ino_t, + pub st_nlink: ::nlink_t, + pub st_dev: ::dev_t, + pub st_mode: ::mode_t, + pub st_padding1: ::uint16_t, + pub st_uid: ::uid_t, + pub st_gid: ::gid_t, + pub st_rdev: ::dev_t, + pub st_atime: ::time_t, + pub st_atime_nsec: ::c_long, + pub st_mtime: ::time_t, + pub st_mtime_nsec: ::c_long, + pub st_ctime: ::time_t, + pub st_ctime_nsec: ::c_long, + pub st_size: ::off_t, + pub st_blocks: ::int64_t, + pub st_blksize: ::uint32_t, + pub st_flags: ::fflags_t, + pub st_gen: ::uint32_t, + pub st_lspare: ::int32_t, + pub st_qspare1: ::int64_t, + pub st_qspare2: ::int64_t, + } +} diff --git a/src/unix/bsd/freebsdlike/freebsd.rs b/src/unix/bsd/freebsdlike/freebsd.rs deleted file mode 100644 index d6fa96fe..00000000 --- a/src/unix/bsd/freebsdlike/freebsd.rs +++ /dev/null @@ -1,13 +0,0 @@ -pub type fsblkcnt_t = ::uint64_t; -pub type fsfilcnt_t = ::uint64_t; - -pub const PTHREAD_STACK_MIN: ::size_t = 2048; -pub const KERN_PROC_PATHNAME: ::c_int = 12; -pub const SIGSTKSZ: ::size_t = 34816; -pub const SF_NODISKIO: ::c_int = 0x00000001; -pub const SF_MNOWAIT: ::c_int = 0x00000002; -pub const SF_SYNC: ::c_int = 0x00000004; - -extern { - pub fn __error() -> *mut ::c_int; -} diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs new file mode 100644 index 00000000..70fb50c2 --- /dev/null +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -0,0 +1,80 @@ +cfg_if! { + if #[cfg(target_arch = "x86")] { + mod x86; + pub use self::x86::*; + } else if #[cfg(target_arch = "x86_64")] { + mod x86_64; + pub use self::x86_64::*; + } else { + // ... + } +} + +pub type clock_t = i32; +pub type ino_t = u32; +pub type nlink_t = u16; +pub type blksize_t = u32; + +s! { + pub struct dirent { + pub d_fileno: u32, + pub d_reclen: u16, + pub d_type: u8, + pub d_namlen: u8, + pub d_name: [::c_char; 256], + } + + pub struct statvfs { + pub f_bavail: ::fsblkcnt_t, + pub f_bfree: ::fsblkcnt_t, + pub f_blocks: ::fsblkcnt_t, + pub f_favail: ::fsfilcnt_t, + pub f_ffree: ::fsfilcnt_t, + pub f_files: ::fsfilcnt_t, + pub f_bsize: ::c_ulong, + pub f_flag: ::c_ulong, + pub f_frsize: ::c_ulong, + pub f_fsid: ::c_ulong, + pub f_namemax: ::c_ulong, + } +} + +pub type fsblkcnt_t = ::uint64_t; +pub type fsfilcnt_t = ::uint64_t; + +pub const RAND_MAX: ::c_int = 0x7fff_fffd; +pub const PTHREAD_STACK_MIN: ::size_t = 2048; +pub const KERN_PROC_PATHNAME: ::c_int = 12; +pub const SIGSTKSZ: ::size_t = 34816; +pub const SF_NODISKIO: ::c_int = 0x00000001; +pub const SF_MNOWAIT: ::c_int = 0x00000002; +pub const SF_SYNC: ::c_int = 0x00000004; +pub const O_CLOEXEC: ::c_int = 0x00100000; +pub const F_GETLK: ::c_int = 11; +pub const F_SETLK: ::c_int = 12; +pub const F_SETLKW: ::c_int = 13; +pub const ELAST: ::c_int = 96; +pub const RLIMIT_NPTS: ::c_int = 11; +pub const RLIMIT_SWAP: ::c_int = 12; +pub const RLIM_NLIMITS: ::rlim_t = 13; + +pub const Q_GETQUOTA: ::c_int = 0x700; +pub const Q_SETQUOTA: ::c_int = 0x800; + +pub const POSIX_FADV_NORMAL: ::c_int = 0; +pub const POSIX_FADV_RANDOM: ::c_int = 1; +pub const POSIX_FADV_SEQUENTIAL: ::c_int = 2; +pub const POSIX_FADV_WILLNEED: ::c_int = 3; +pub const POSIX_FADV_DONTNEED: ::c_int = 4; +pub const POSIX_FADV_NOREUSE: ::c_int = 5; + +extern { + pub fn __error() -> *mut ::c_int; + + pub fn posix_fallocate(fd: ::c_int, offset: ::off_t, + len: ::off_t) -> ::c_int; + pub fn posix_fadvise(fd: ::c_int, offset: ::off_t, len: ::off_t, + advise: ::c_int) -> ::c_int; + pub fn mkostemp(template: *mut ::c_char, flags: ::c_int) -> ::c_int; + pub fn mkostemps(template: *mut ::c_char, suffixlen: ::c_int, flags: ::c_int) -> ::c_int; +} diff --git a/src/unix/bsd/freebsdlike/x86.rs b/src/unix/bsd/freebsdlike/freebsd/x86.rs similarity index 100% rename from src/unix/bsd/freebsdlike/x86.rs rename to src/unix/bsd/freebsdlike/freebsd/x86.rs diff --git a/src/unix/bsd/freebsdlike/x86_64.rs b/src/unix/bsd/freebsdlike/freebsd/x86_64.rs similarity index 100% rename from src/unix/bsd/freebsdlike/x86_64.rs rename to src/unix/bsd/freebsdlike/freebsd/x86_64.rs diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 011cf867..de60d523 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -1,9 +1,5 @@ -pub type clock_t = i32; pub type dev_t = u32; -pub type ino_t = u32; pub type mode_t = u16; -pub type nlink_t = u16; -pub type blksize_t = u32; pub type fflags_t = u32; pub type pthread_attr_t = *mut ::c_void; pub type rlim_t = i64; @@ -18,14 +14,6 @@ pub type speed_t = ::c_uint; pub enum timezone {} s! { - pub struct dirent { - pub d_fileno: u32, - pub d_reclen: u16, - pub d_type: u8, - pub d_namlen: u8, - pub d_name: [::c_char; 256], - } - pub struct glob_t { pub gl_pathc: ::size_t, __unused1: ::size_t, @@ -88,20 +76,6 @@ s! { pub ss_flags: ::c_int, } - pub struct statvfs { - pub f_bavail: ::fsblkcnt_t, - pub f_bfree: ::fsblkcnt_t, - pub f_blocks: ::fsblkcnt_t, - pub f_favail: ::fsfilcnt_t, - pub f_ffree: ::fsfilcnt_t, - pub f_files: ::fsfilcnt_t, - pub f_bsize: ::c_ulong, - pub f_flag: ::c_ulong, - pub f_frsize: ::c_ulong, - pub f_fsid: ::c_ulong, - pub f_namemax: ::c_ulong, - } - pub struct sched_param { pub sched_priority: ::c_int, } @@ -137,6 +111,7 @@ s! { pub l_pid: ::pid_t, pub l_type: ::c_short, pub l_whence: ::c_short, + #[cfg(not(target_os = "dragonfly"))] pub l_sysid: ::c_int, } @@ -150,7 +125,6 @@ s! { pub const EXIT_FAILURE: ::c_int = 1; pub const EXIT_SUCCESS: ::c_int = 0; -pub const RAND_MAX: ::c_int = 0x7fff_fffd; pub const EOF: ::c_int = -1; pub const SEEK_SET: ::c_int = 0; pub const SEEK_CUR: ::c_int = 1; @@ -173,7 +147,6 @@ pub const O_CREAT: ::c_int = 512; pub const O_EXCL: ::c_int = 2048; pub const O_NOCTTY: ::c_int = 32768; pub const O_TRUNC: ::c_int = 1024; -pub const O_CLOEXEC: ::c_int = 0x00100000; pub const S_IFIFO: mode_t = 4096; pub const S_IFCHR: mode_t = 8192; pub const S_IFBLK: mode_t = 24576; @@ -209,9 +182,6 @@ pub const F_TEST: ::c_int = 3; pub const F_TLOCK: ::c_int = 2; pub const F_ULOCK: ::c_int = 0; pub const F_DUPFD_CLOEXEC: ::c_int = 17; -pub const F_GETLK: ::c_int = 11; -pub const F_SETLK: ::c_int = 12; -pub const F_SETLKW: ::c_int = 13; pub const SIGHUP: ::c_int = 1; pub const SIGINT: ::c_int = 2; pub const SIGQUIT: ::c_int = 3; @@ -337,7 +307,6 @@ pub const EBADMSG: ::c_int = 89; pub const EMULTIHOP: ::c_int = 90; pub const ENOLINK: ::c_int = 91; pub const EPROTO: ::c_int = 92; -pub const ELAST: ::c_int = 96; pub const F_DUPFD: ::c_int = 0; pub const F_GETFD: ::c_int = 1; @@ -365,13 +334,6 @@ pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2; pub const POSIX_MADV_WILLNEED: ::c_int = 3; pub const POSIX_MADV_DONTNEED: ::c_int = 4; -pub const POSIX_FADV_NORMAL: ::c_int = 0; -pub const POSIX_FADV_RANDOM: ::c_int = 1; -pub const POSIX_FADV_SEQUENTIAL: ::c_int = 2; -pub const POSIX_FADV_WILLNEED: ::c_int = 3; -pub const POSIX_FADV_DONTNEED: ::c_int = 4; -pub const POSIX_FADV_NOREUSE: ::c_int = 5; - pub const _SC_IOV_MAX: ::c_int = 56; pub const _SC_GETGR_R_SIZE_MAX: ::c_int = 70; pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 71; @@ -420,14 +382,11 @@ pub const RLIMIT_NOFILE: ::c_int = 8; pub const RLIMIT_SBSIZE: ::c_int = 9; pub const RLIMIT_VMEM: ::c_int = 10; pub const RLIMIT_AS: ::c_int = RLIMIT_VMEM; -pub const RLIMIT_NPTS: ::c_int = 11; -pub const RLIMIT_SWAP: ::c_int = 12; - -pub const RLIM_NLIMITS: rlim_t = 13; pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff; pub const RUSAGE_SELF: ::c_int = 0; pub const RUSAGE_CHILDREN: ::c_int = -1; +#[cfg(not(target_os = "dragonfly"))] pub const RUSAGE_THREAD: ::c_int = 1; pub const MADV_NORMAL: ::c_int = 0; @@ -440,6 +399,7 @@ pub const MADV_NOSYNC: ::c_int = 6; pub const MADV_AUTOSYNC: ::c_int = 7; pub const MADV_NOCORE: ::c_int = 8; pub const MADV_CORE: ::c_int = 9; +#[cfg(not(target_os = "dragonfly"))] pub const MADV_PROTECT: ::c_int = 10; pub const MINCORE_INCORE: ::c_int = 0x1; @@ -584,9 +544,6 @@ pub const ST_NOSUID: ::c_ulong = 2; pub const NI_MAXHOST: ::size_t = 1025; -pub const Q_GETQUOTA: ::c_int = 0x700; -pub const Q_SETQUOTA: ::c_int = 0x800; - pub const RTLD_LOCAL: ::c_int = 0; pub const RTLD_NODELETE: ::c_int = 0x1000; pub const RTLD_NOLOAD: ::c_int = 0x2000; @@ -606,8 +563,12 @@ extern { mibp: *mut ::c_int, sizep: *mut ::size_t) -> ::c_int; + #[cfg(not(target_os = "dragonfly"))] pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int) -> ::c_int; + #[cfg(target_os = "dragonfly")] + pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) + -> ::c_int; pub fn shm_open(name: *const ::c_char, oflag: ::c_int, mode: ::mode_t) -> ::c_int; pub fn sysctl(name: *const ::c_int, @@ -623,10 +584,12 @@ extern { newp: *const ::c_void, newlen: ::size_t) -> ::c_int; + #[cfg(not(target_os = "dragonfly"))] pub fn clock_gettime(clk_id: ::c_int, tp: *mut ::timespec) -> ::c_int; + #[cfg(target_os = "dragonfly")] + pub fn clock_gettime(clk_id: ::uint64_t, tp: *mut ::timespec) -> ::c_int; + pub fn pthread_set_name_np(tid: ::pthread_t, name: *const ::c_char); - pub fn posix_fallocate(fd: ::c_int, offset: ::off_t, - len: ::off_t) -> ::c_int; pub fn sched_setscheduler(pid: ::pid_t, policy: ::c_int, param: *const sched_param) -> ::c_int; pub fn sched_getscheduler(pid: ::pid_t) -> ::c_int; pub fn memrchr(cx: *const ::c_void, c: ::c_int, n: ::size_t) -> *mut ::c_void; @@ -637,23 +600,6 @@ extern { hdtr: *mut ::sf_hdtr, sbytes: *mut ::off_t, flags: ::c_int) -> ::c_int; - - pub fn posix_fadvise(fd: ::c_int, offset: ::off_t, len: ::off_t, - advise: ::c_int) -> ::c_int; - pub fn mkostemp(template: *mut ::c_char, flags: ::c_int) -> ::c_int; - pub fn mkostemps(template: *mut ::c_char, suffixlen: ::c_int, flags: ::c_int) -> ::c_int; -} - -cfg_if! { - if #[cfg(target_arch = "x86")] { - mod x86; - pub use self::x86::*; - } else if #[cfg(target_arch = "x86_64")] { - mod x86_64; - pub use self::x86_64::*; - } else { - // ... - } } cfg_if! { diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index d6752a5f..f9304eaf 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -10,6 +10,11 @@ pub type sa_family_t = u8; pub type pthread_t = ::uintptr_t; pub type nfds_t = ::c_uint; +#[cfg(not(target_os = "dragonfly"))] +macro_rules! utsname_len { () => (256) } +#[cfg(target_os = "dragonfly")] +macro_rules! utsname_len { () => (32) } + s! { pub struct sockaddr { pub sa_len: u8, @@ -63,10 +68,10 @@ s! { pub struct fd_set { #[cfg(all(target_pointer_width = "64", - target_os = "freebsd"))] + any(target_os = "freebsd", target_os = "dragonfly")))] fds_bits: [i64; FD_SETSIZE / 64], #[cfg(not(all(target_pointer_width = "64", - target_os = "freebsd")))] + any(target_os = "freebsd", target_os = "dragonfly"))))] fds_bits: [i32; FD_SETSIZE / 32], } @@ -85,11 +90,11 @@ s! { } pub struct utsname { - pub sysname: [::c_char; 256], - pub nodename: [::c_char; 256], - pub release: [::c_char; 256], - pub version: [::c_char; 256], - pub machine: [::c_char; 256], + pub sysname: [::c_char; utsname_len!()], + pub nodename: [::c_char; utsname_len!()], + pub release: [::c_char; utsname_len!()], + pub version: [::c_char; utsname_len!()], + pub machine: [::c_char; utsname_len!()], } pub struct msghdr {