From 9064522f1d0f7f603107ecb1fd87a818d9a3d675 Mon Sep 17 00:00:00 2001 From: Michael Neumann Date: Tue, 29 Dec 2015 00:53:46 +0100 Subject: [PATCH 1/3] DragonFly has different stat, dirent, clock_t, ino_t, nlink_t, blksize_t Move FreeBSD's stat into freebsd_{x86,x86_64}.rs. --- src/unix/bsd/freebsdlike/dragonfly.rs | 41 ++++++++++++++++++++++ src/unix/bsd/freebsdlike/freebsd.rs | 15 ++++++++ src/unix/bsd/freebsdlike/freebsd_x86.rs | 26 ++++++++++++++ src/unix/bsd/freebsdlike/freebsd_x86_64.rs | 25 +++++++++++++ src/unix/bsd/freebsdlike/mod.rs | 24 ++++++------- src/unix/bsd/freebsdlike/x86.rs | 27 -------------- src/unix/bsd/freebsdlike/x86_64.rs | 26 -------------- 7 files changed, 119 insertions(+), 65 deletions(-) create mode 100644 src/unix/bsd/freebsdlike/freebsd_x86.rs create mode 100644 src/unix/bsd/freebsdlike/freebsd_x86_64.rs diff --git a/src/unix/bsd/freebsdlike/dragonfly.rs b/src/unix/bsd/freebsdlike/dragonfly.rs index 6b874f0b1f67d..b2a44b82d1975 100644 --- a/src/unix/bsd/freebsdlike/dragonfly.rs +++ b/src/unix/bsd/freebsdlike/dragonfly.rs @@ -1,8 +1,49 @@ +pub type clock_t = u64; +pub type ino_t = u64; +pub type nlink_t = u32; +pub type blksize_t = u64; + 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; +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: ::uint32_t, + pub st_gen: ::uint32_t, + pub st_lspare: ::int32_t, + pub st_qspare1: ::int64_t, + pub st_qspare2: ::int64_t, + } + + pub struct dirent { + pub d_fileno: ::ino_t, + pub d_namelen: u16, + pub d_type: u8, + __unused1: u8, + __unused2: u32, + pub d_name: [::c_char; 256], + } +} + 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 9e6d985f9d7c0..fee52d75006e5 100644 --- a/src/unix/bsd/freebsdlike/freebsd.rs +++ b/src/unix/bsd/freebsdlike/freebsd.rs @@ -1,7 +1,22 @@ +pub type clock_t = i32; +pub type ino_t = u32; +pub type nlink_t = u16; +pub type blksize_t = u32; + pub const PTHREAD_STACK_MIN: ::size_t = 2048; pub const KERN_PROC_PATHNAME: ::c_int = 12; pub const SIGSTKSZ: ::size_t = 34816; +s! { + pub struct dirent { + pub d_fileno: u32, + pub d_reclen: u16, + pub d_type: u8, + pub d_namelen: u8, + pub d_name: [::c_char; 256], + } +} + extern { pub fn __error() -> *mut ::c_int; } diff --git a/src/unix/bsd/freebsdlike/freebsd_x86.rs b/src/unix/bsd/freebsdlike/freebsd_x86.rs new file mode 100644 index 0000000000000..947dd62611605 --- /dev/null +++ b/src/unix/bsd/freebsdlike/freebsd_x86.rs @@ -0,0 +1,26 @@ +s! { + pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_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: ::blkcnt_t, + pub st_blksize: ::blksize_t, + pub st_flags: ::fflags_t, + pub st_gen: ::uint32_t, + pub st_lspare: ::int32_t, + pub st_birthtime: ::time_t, + pub st_birthtime_nsec: ::c_long, + __unused: [u8; 8], + } +} diff --git a/src/unix/bsd/freebsdlike/freebsd_x86_64.rs b/src/unix/bsd/freebsdlike/freebsd_x86_64.rs new file mode 100644 index 0000000000000..a152913d61dff --- /dev/null +++ b/src/unix/bsd/freebsdlike/freebsd_x86_64.rs @@ -0,0 +1,25 @@ +s! { + pub struct stat { + pub st_dev: ::dev_t, + pub st_ino: ::ino_t, + pub st_mode: ::mode_t, + pub st_nlink: ::nlink_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: ::blkcnt_t, + pub st_blksize: ::blksize_t, + pub st_flags: ::fflags_t, + pub st_gen: ::uint32_t, + pub st_lspare: ::int32_t, + pub st_birthtime: ::time_t, + pub st_birthtime_nsec: ::c_long, + } +} diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 508fc6b72ce5e..1f29e6a7901dd 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; @@ -20,14 +16,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_namelen: u8, - pub d_name: [::c_char; 256], - } - pub struct glob_t { pub gl_pathc: ::size_t, __unused1: ::size_t, @@ -602,6 +590,18 @@ cfg_if! { } } +cfg_if! { + if #[cfg(all(target_arch = "x86", target_os = "freebsd"))] { + mod freebsd_x86; + pub use self::freebsd_x86::*; + } else if #[cfg(all(target_arch = "x86_64", target_os = "freebsd"))] { + mod freebsd_x86_64; + pub use self::freebsd_x86_64::*; + } else { + // ... + } +} + cfg_if! { if #[cfg(target_os = "freebsd")] { mod freebsd; diff --git a/src/unix/bsd/freebsdlike/x86.rs b/src/unix/bsd/freebsdlike/x86.rs index 8a5e5f9fb8d28..619cbbd9751e2 100644 --- a/src/unix/bsd/freebsdlike/x86.rs +++ b/src/unix/bsd/freebsdlike/x86.rs @@ -2,30 +2,3 @@ pub type c_long = i32; pub type c_ulong = u32; pub type time_t = i32; pub type suseconds_t = i32; - -s! { - pub struct stat { - pub st_dev: ::dev_t, - pub st_ino: ::ino_t, - pub st_mode: ::mode_t, - pub st_nlink: ::nlink_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: ::blkcnt_t, - pub st_blksize: ::blksize_t, - pub st_flags: ::fflags_t, - pub st_gen: ::uint32_t, - pub st_lspare: ::int32_t, - pub st_birthtime: ::time_t, - pub st_birthtime_nsec: ::c_long, - __unused: [u8; 8], - } -} diff --git a/src/unix/bsd/freebsdlike/x86_64.rs b/src/unix/bsd/freebsdlike/x86_64.rs index a2da8452c4d34..48a590eb377de 100644 --- a/src/unix/bsd/freebsdlike/x86_64.rs +++ b/src/unix/bsd/freebsdlike/x86_64.rs @@ -2,29 +2,3 @@ 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_dev: ::dev_t, - pub st_ino: ::ino_t, - pub st_mode: ::mode_t, - pub st_nlink: ::nlink_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: ::blkcnt_t, - pub st_blksize: ::blksize_t, - pub st_flags: ::fflags_t, - pub st_gen: ::uint32_t, - pub st_lspare: ::int32_t, - pub st_birthtime: ::time_t, - pub st_birthtime_nsec: ::c_long, - } -} From 9d9d0c54f9d8ce24adf8e11e7aa9254edcf11eef Mon Sep 17 00:00:00 2001 From: Michael Neumann Date: Tue, 29 Dec 2015 02:32:05 +0100 Subject: [PATCH 2/3] Fix libc-test on DragonFly. I had to duplicate utsname as DragonFly uses 32 bytes instead of 256. --- libc-test/build.rs | 35 ++++++++++++++++++++++++--- src/unix/bsd/apple/mod.rs | 8 ++++++ src/unix/bsd/freebsdlike/dragonfly.rs | 21 +++++++++++++++- src/unix/bsd/freebsdlike/freebsd.rs | 20 +++++++++++++++ src/unix/bsd/freebsdlike/mod.rs | 12 --------- src/unix/bsd/mod.rs | 8 ------ src/unix/bsd/openbsdlike/mod.rs | 8 ++++++ 7 files changed, 88 insertions(+), 24 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index f94f7051faf29..b1f8673075983 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -14,10 +14,11 @@ 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 rumprun = target.contains("rumprun"); - let bsdlike = freebsd || apple || netbsd; + let bsdlike = freebsd || apple || netbsd || dragonfly; let mut cfg = ctest::TestGenerator::new(); // Pull in extra goodies on linux/mingw @@ -96,7 +97,9 @@ fn main() { } else if !windows { cfg.header("glob.h"); cfg.header("ifaddrs.h"); - cfg.header("sys/quota.h"); + if !dragonfly { + cfg.header("sys/quota.h"); + } cfg.header("sys/statvfs.h"); if !musl { @@ -161,6 +164,11 @@ fn main() { cfg.header("sys/ioctl_compat.h"); } + if dragonfly { + 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 @@ -221,6 +229,9 @@ fn main() { // sighandler_t is crazy across platforms "sighandler_t" => true, + // does not exists on DragonFly + "fflags_t" if dragonfly => true, + _ => false } }); @@ -286,6 +297,18 @@ fn main() { "QFMT_VFS_OLD" | "QFMT_VFS_V0" if mips && linux => true, + "USRQUOTA" | + "GRPQUOTA" | + "Q_SYNC" | + "Q_QUOTAON" | + "Q_QUOTAOFF" | + "Q_GETQUOTA" | + "Q_SETQUOTA" | + "RLIMIT_NPTS" | + "RLIMIT_SWAP" | + "RUSAGE_THREAD" | + "MADV_PROTECT" if dragonfly => true, + _ => false, } }); @@ -303,7 +326,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 | dragonfly => true, // not declared in newer android toolchains "getdtablesize" if android => true, @@ -333,6 +356,12 @@ fn main() { "ptrace" | "sigaltstack" if rumprun => true, + // uses size_t instead of socklen_t + "getnameinfo" if dragonfly => true, + + // is defined elsewhere + "__dfly_error" if dragonfly => true, + _ => false, } }); diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 378fc4b771b55..b0d1d12c79c04 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -242,6 +242,14 @@ s! { pub c_ispeed: ::speed_t, pub c_ospeed: ::speed_t, } + + 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 const EXIT_FAILURE: ::c_int = 1; diff --git a/src/unix/bsd/freebsdlike/dragonfly.rs b/src/unix/bsd/freebsdlike/dragonfly.rs index b2a44b82d1975..cd9bcf9ea317a 100644 --- a/src/unix/bsd/freebsdlike/dragonfly.rs +++ b/src/unix/bsd/freebsdlike/dragonfly.rs @@ -36,14 +36,33 @@ s!{ pub struct dirent { pub d_fileno: ::ino_t, - pub d_namelen: u16, + pub d_namlen: u16, pub d_type: u8, __unused1: u8, __unused2: u32, pub d_name: [::c_char; 256], } + + pub struct utsname { + pub sysname: [::c_char; 32], + pub nodename: [::c_char; 32], + pub release: [::c_char; 32], + pub version: [::c_char; 32], + pub machine: [::c_char; 32], + } + + pub struct stack_t { + pub ss_sp: *mut ::c_char, + pub ss_size: ::size_t, + pub ss_flags: ::c_int, + } + } extern { + pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int) + -> ::c_int; + pub fn clock_gettime(clk_id: ::uint64_t, tp: *mut ::timespec) -> ::c_int; + pub fn __dfly_error() -> *const ::c_int; } diff --git a/src/unix/bsd/freebsdlike/freebsd.rs b/src/unix/bsd/freebsdlike/freebsd.rs index fee52d75006e5..2d3bbd5605cf0 100644 --- a/src/unix/bsd/freebsdlike/freebsd.rs +++ b/src/unix/bsd/freebsdlike/freebsd.rs @@ -6,6 +6,7 @@ pub type blksize_t = u32; pub const PTHREAD_STACK_MIN: ::size_t = 2048; pub const KERN_PROC_PATHNAME: ::c_int = 12; pub const SIGSTKSZ: ::size_t = 34816; +pub const HW_AVAILCPU: ::c_int = 25; s! { pub struct dirent { @@ -15,8 +16,27 @@ s! { pub d_namelen: u8, pub d_name: [::c_char; 256], } + + 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 struct stack_t { + pub ss_sp: *mut ::c_void, + pub ss_size: ::size_t, + pub ss_flags: ::c_int, + } } extern { + pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int) + -> ::c_int; + pub fn clock_gettime(clk_id: ::c_int, tp: *mut ::timespec) -> ::c_int; + pub fn posix_fallocate(fd: ::c_int, offset: ::off_t, + len: ::off_t) -> ::c_int; pub fn __error() -> *mut ::c_int; } diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 1f29e6a7901dd..fdcce76df2a28 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -72,12 +72,6 @@ s! { pub sa_mask: sigset_t, } - pub struct stack_t { - pub ss_sp: *mut ::c_void, - pub ss_size: ::size_t, - pub ss_flags: ::c_int, - } - pub struct statvfs { pub f_bavail: ::fsblkcnt_t, pub f_bfree: ::fsblkcnt_t, @@ -543,7 +537,6 @@ pub const FD_SETSIZE: usize = 1024; pub const ST_NOSUID: ::c_ulong = 2; -pub const HW_AVAILCPU: ::c_int = 25; extern { pub fn mincore(addr: *const ::c_void, len: ::size_t, @@ -552,8 +545,6 @@ extern { mibp: *mut ::c_int, sizep: *mut ::size_t) -> ::c_int; - pub fn mprotect(addr: *const ::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, @@ -569,10 +560,7 @@ 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); - 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; diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 144240d42397c..a0e7af5ec2313 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -75,14 +75,6 @@ s! { pub tm_zone: *mut ::c_char, } - 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 struct msghdr { pub msg_name: *mut ::c_void, pub msg_namelen: ::socklen_t, diff --git a/src/unix/bsd/openbsdlike/mod.rs b/src/unix/bsd/openbsdlike/mod.rs index 85a77dc96c56d..bbec673b27fa8 100644 --- a/src/unix/bsd/openbsdlike/mod.rs +++ b/src/unix/bsd/openbsdlike/mod.rs @@ -48,6 +48,14 @@ s! { pub c_ispeed: ::c_int, pub c_ospeed: ::c_int, } + + 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 const EXIT_FAILURE : ::c_int = 1; From 673a3f48f436ec9fd6daaa96499ec73699c4c90c Mon Sep 17 00:00:00 2001 From: Michael Neumann Date: Mon, 11 Jan 2016 00:42:44 +0100 Subject: [PATCH 3/3] Reorganize the FreeBSD/DragonFly code. There is no shared x86 and x86_64 code between the two anymore. Instead these 4 lines of code were duplicated. We now only share architecture-independet code between FreeBSD and DragonFly. --- src/unix/bsd/freebsdlike/dragonfly/mod.rs | 8 +++++++ .../{dragonfly.rs => dragonfly/x86_64.rs} | 6 ++++- .../{freebsd.rs => freebsd/mod.rs} | 12 ++++++++++ .../{freebsd_x86.rs => freebsd/x86.rs} | 5 ++++ .../{freebsd_x86_64.rs => freebsd/x86_64.rs} | 5 ++++ src/unix/bsd/freebsdlike/mod.rs | 24 ------------------- src/unix/bsd/freebsdlike/x86.rs | 4 ---- src/unix/bsd/freebsdlike/x86_64.rs | 4 ---- 8 files changed, 35 insertions(+), 33 deletions(-) create mode 100644 src/unix/bsd/freebsdlike/dragonfly/mod.rs rename src/unix/bsd/freebsdlike/{dragonfly.rs => dragonfly/x86_64.rs} (94%) rename src/unix/bsd/freebsdlike/{freebsd.rs => freebsd/mod.rs} (83%) rename src/unix/bsd/freebsdlike/{freebsd_x86.rs => freebsd/x86.rs} (88%) rename src/unix/bsd/freebsdlike/{freebsd_x86_64.rs => freebsd/x86_64.rs} (88%) delete mode 100644 src/unix/bsd/freebsdlike/x86.rs delete mode 100644 src/unix/bsd/freebsdlike/x86_64.rs diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs new file mode 100644 index 0000000000000..2071b8d8fb07c --- /dev/null +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -0,0 +1,8 @@ +cfg_if! { + if #[cfg(target_arch = "x86_64")] { + mod x86_64; + pub use self::x86_64::*; + } else { + // ... + } +} diff --git a/src/unix/bsd/freebsdlike/dragonfly.rs b/src/unix/bsd/freebsdlike/dragonfly/x86_64.rs similarity index 94% rename from src/unix/bsd/freebsdlike/dragonfly.rs rename to src/unix/bsd/freebsdlike/dragonfly/x86_64.rs index cd9bcf9ea317a..21995cfc4b986 100644 --- a/src/unix/bsd/freebsdlike/dragonfly.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/x86_64.rs @@ -1,3 +1,8 @@ +pub type c_long = i64; +pub type c_ulong = u64; +pub type time_t = i64; +pub type suseconds_t = i64; + pub type clock_t = u64; pub type ino_t = u64; pub type nlink_t = u32; @@ -56,7 +61,6 @@ s!{ pub ss_size: ::size_t, pub ss_flags: ::c_int, } - } extern { diff --git a/src/unix/bsd/freebsdlike/freebsd.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs similarity index 83% rename from src/unix/bsd/freebsdlike/freebsd.rs rename to src/unix/bsd/freebsdlike/freebsd/mod.rs index 2d3bbd5605cf0..453c09f63f79e 100644 --- a/src/unix/bsd/freebsdlike/freebsd.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -40,3 +40,15 @@ extern { len: ::off_t) -> ::c_int; pub fn __error() -> *mut ::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 { + // ... + } +} diff --git a/src/unix/bsd/freebsdlike/freebsd_x86.rs b/src/unix/bsd/freebsdlike/freebsd/x86.rs similarity index 88% rename from src/unix/bsd/freebsdlike/freebsd_x86.rs rename to src/unix/bsd/freebsdlike/freebsd/x86.rs index 947dd62611605..8a5e5f9fb8d28 100644 --- a/src/unix/bsd/freebsdlike/freebsd_x86.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86.rs @@ -1,3 +1,8 @@ +pub type c_long = i32; +pub type c_ulong = u32; +pub type time_t = i32; +pub type suseconds_t = i32; + s! { pub struct stat { pub st_dev: ::dev_t, diff --git a/src/unix/bsd/freebsdlike/freebsd_x86_64.rs b/src/unix/bsd/freebsdlike/freebsd/x86_64.rs similarity index 88% rename from src/unix/bsd/freebsdlike/freebsd_x86_64.rs rename to src/unix/bsd/freebsdlike/freebsd/x86_64.rs index a152913d61dff..a2da8452c4d34 100644 --- a/src/unix/bsd/freebsdlike/freebsd_x86_64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/x86_64.rs @@ -1,3 +1,8 @@ +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_dev: ::dev_t, diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index fdcce76df2a28..efb985d9544bb 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -566,30 +566,6 @@ extern { pub fn memrchr(cx: *const ::c_void, c: ::c_int, n: ::size_t) -> *mut ::c_void; } -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! { - if #[cfg(all(target_arch = "x86", target_os = "freebsd"))] { - mod freebsd_x86; - pub use self::freebsd_x86::*; - } else if #[cfg(all(target_arch = "x86_64", target_os = "freebsd"))] { - mod freebsd_x86_64; - pub use self::freebsd_x86_64::*; - } else { - // ... - } -} - cfg_if! { if #[cfg(target_os = "freebsd")] { mod freebsd; diff --git a/src/unix/bsd/freebsdlike/x86.rs b/src/unix/bsd/freebsdlike/x86.rs deleted file mode 100644 index 619cbbd9751e2..0000000000000 --- a/src/unix/bsd/freebsdlike/x86.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub type c_long = i32; -pub type c_ulong = u32; -pub type time_t = i32; -pub type suseconds_t = i32; diff --git a/src/unix/bsd/freebsdlike/x86_64.rs b/src/unix/bsd/freebsdlike/x86_64.rs deleted file mode 100644 index 48a590eb377de..0000000000000 --- a/src/unix/bsd/freebsdlike/x86_64.rs +++ /dev/null @@ -1,4 +0,0 @@ -pub type c_long = i64; -pub type c_ulong = u64; -pub type time_t = i64; -pub type suseconds_t = i64;