From cf144d16e9cf4ce56affbbf82ae1e6b60c62a0ef Mon Sep 17 00:00:00 2001 From: Ali Clark Date: Wed, 17 Feb 2016 14:09:22 +0000 Subject: [PATCH 1/4] remove unused import from dragonfly os raw --- src/libstd/os/dragonfly/raw.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/libstd/os/dragonfly/raw.rs b/src/libstd/os/dragonfly/raw.rs index f3bde9cd1f31..56d69775a317 100644 --- a/src/libstd/os/dragonfly/raw.rs +++ b/src/libstd/os/dragonfly/raw.rs @@ -18,9 +18,6 @@ definitions")] #![allow(deprecated)] -use os::raw::c_long; -use os::unix::raw::{uid_t, gid_t}; - #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64; #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64; #[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = u64; From c99409f7932a21b0d465fab465302769f70a9686 Mon Sep 17 00:00:00 2001 From: Ali Clark Date: Wed, 17 Feb 2016 14:10:02 +0000 Subject: [PATCH 2/4] unfork freebsd stat definitions, fixes x86 --- src/libstd/os/freebsd/raw.rs | 168 ++++++++++------------------------- 1 file changed, 48 insertions(+), 120 deletions(-) diff --git a/src/libstd/os/freebsd/raw.rs b/src/libstd/os/freebsd/raw.rs index 073ddf10d1cc..ba8f57c415cf 100644 --- a/src/libstd/os/freebsd/raw.rs +++ b/src/libstd/os/freebsd/raw.rs @@ -18,134 +18,62 @@ definitions")] #![allow(deprecated)] -#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64; +#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64; +#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64; #[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = u64; +#[stable(feature = "raw_ext", since = "1.1.0")] pub type fflags_t = u32; #[stable(feature = "raw_ext", since = "1.1.0")] pub type ino_t = u64; #[stable(feature = "raw_ext", since = "1.1.0")] pub type mode_t = u32; #[stable(feature = "raw_ext", since = "1.1.0")] pub type nlink_t = u64; -#[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64; -#[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64; -#[stable(feature = "raw_ext", since = "1.1.0")] pub type fflags_t = u32; +#[stable(feature = "raw_ext", since = "1.1.0")] pub type off_t = u64; +#[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64; #[unstable(feature = "pthread_t", issue = "29791")] pub type pthread_t = usize; -#[doc(inline)] +#[repr(C)] +#[derive(Clone)] #[stable(feature = "raw_ext", since = "1.1.0")] -pub use self::arch::{stat, time_t}; - -#[cfg(target_arch = "x86")] -mod arch { - use super::{off_t, dev_t, ino_t, mode_t, nlink_t, blksize_t, blkcnt_t, fflags_t}; - use os::raw::c_long; - use os::unix::raw::{uid_t, gid_t}; - - #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64; - - #[repr(C)] - #[derive(Clone)] +pub struct stat { #[stable(feature = "raw_ext", since = "1.1.0")] - pub struct stat { - #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_dev: dev_t, - #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_ino: ino_t, - #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_mode: mode_t, - #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_nlink: nlink_t, - #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_uid: uid_t, - #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_gid: gid_t, - #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_rdev: dev_t, - #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_atime: time_t, - #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_atime_nsec: c_long, - #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_mtime: time_t, - #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_mtime_nsec: c_long, - #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_ctime: time_t, - #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_ctime_nsec: c_long, - #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_size: off_t, - #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_blocks: blkcnt_t, - #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_blksize: blksize_t, - #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_flags: fflags_t, - #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_gen: u32, - #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_lspare: i32, - #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_birthtime: time_t, - #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_birthtime_nsec: c_long, - #[stable(feature = "raw_ext", since = "1.1.0")] - pub __unused: [u8; 8], - } -} - -#[cfg(target_arch = "x86_64")] -mod arch { - use super::{off_t, dev_t, ino_t, mode_t, nlink_t, blksize_t, blkcnt_t, fflags_t}; - use os::raw::c_long; - use os::unix::raw::{uid_t, gid_t}; - - #[stable(feature = "raw_ext", since = "1.1.0")] pub type time_t = i64; - - #[repr(C)] - #[derive(Clone)] + pub st_dev: u32, #[stable(feature = "raw_ext", since = "1.1.0")] - pub struct stat { - #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_dev: u32, - #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_ino: u32, - #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_mode: u16, - #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_nlink: u16, - #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_uid: u32, - #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_gid: u32, - #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_rdev: u32, - #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_atime: i64, - #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_atime_nsec: i64, - #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_mtime: i64, - #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_mtime_nsec: i64, - #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_ctime: i64, - #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_ctime_nsec: i64, - #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_size: i64, - #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_blocks: i64, - #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_blksize: u32, - #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_flags: u32, - #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_gen: u32, - #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_lspare: i32, - #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_birthtime: i64, - #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_birthtime_nsec: i64, - } + pub st_ino: u32, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_mode: u16, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_nlink: u16, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_uid: u32, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_gid: u32, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_rdev: u32, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_atime: i64, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_atime_nsec: i64, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_mtime: i64, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_mtime_nsec: i64, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_ctime: i64, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_ctime_nsec: i64, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_size: i64, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_blocks: i64, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_blksize: u32, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_flags: u32, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_gen: u32, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_lspare: i32, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_birthtime: i64, + #[stable(feature = "raw_ext", since = "1.1.0")] + pub st_birthtime_nsec: i64, } - From 3c534188f0875f5881cfa66c2daf64ec49d79af9 Mon Sep 17 00:00:00 2001 From: Ali Clark Date: Wed, 17 Feb 2016 16:55:43 +0000 Subject: [PATCH 3/4] time_t is long on freebsd and dragonfly (and nsec should be long) This becomes less relevant for dragonfly a i686 support is dropped since release 40, but using long allows some compatibility for older versions. --- src/libstd/os/dragonfly/raw.rs | 18 ++++++++++-------- src/libstd/os/freebsd/raw.rs | 18 ++++++++++-------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/libstd/os/dragonfly/raw.rs b/src/libstd/os/dragonfly/raw.rs index 56d69775a317..83e0be0d158e 100644 --- a/src/libstd/os/dragonfly/raw.rs +++ b/src/libstd/os/dragonfly/raw.rs @@ -18,6 +18,8 @@ definitions")] #![allow(deprecated)] +use os::raw::c_long; + #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64; #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64; #[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = u64; @@ -49,17 +51,17 @@ pub struct stat { #[stable(feature = "raw_ext", since = "1.1.0")] pub st_rdev: u32, #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_atime: i64, + pub st_atime: c_long, #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_atime_nsec: i64, + pub st_atime_nsec: c_long, #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_mtime: i64, + pub st_mtime: c_long, #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_mtime_nsec: i64, + pub st_mtime_nsec: c_long, #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_ctime: i64, + pub st_ctime: c_long, #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_ctime_nsec: i64, + pub st_ctime_nsec: c_long, #[stable(feature = "raw_ext", since = "1.1.0")] pub st_size: i64, #[stable(feature = "raw_ext", since = "1.1.0")] @@ -73,7 +75,7 @@ pub struct stat { #[stable(feature = "raw_ext", since = "1.1.0")] pub st_lspare: i32, #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_birthtime: i64, + pub st_birthtime: c_long, #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_birthtime_nsec: i64, + pub st_birthtime_nsec: c_long, } diff --git a/src/libstd/os/freebsd/raw.rs b/src/libstd/os/freebsd/raw.rs index ba8f57c415cf..b16eab017e4f 100644 --- a/src/libstd/os/freebsd/raw.rs +++ b/src/libstd/os/freebsd/raw.rs @@ -18,6 +18,8 @@ definitions")] #![allow(deprecated)] +use os::raw::c_long; + #[stable(feature = "raw_ext", since = "1.1.0")] pub type blkcnt_t = u64; #[stable(feature = "raw_ext", since = "1.1.0")] pub type blksize_t = u64; #[stable(feature = "raw_ext", since = "1.1.0")] pub type dev_t = u64; @@ -49,17 +51,17 @@ pub struct stat { #[stable(feature = "raw_ext", since = "1.1.0")] pub st_rdev: u32, #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_atime: i64, + pub st_atime: c_long, #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_atime_nsec: i64, + pub st_atime_nsec: c_long, #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_mtime: i64, + pub st_mtime: c_long, #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_mtime_nsec: i64, + pub st_mtime_nsec: c_long, #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_ctime: i64, + pub st_ctime: c_long, #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_ctime_nsec: i64, + pub st_ctime_nsec: c_long, #[stable(feature = "raw_ext", since = "1.1.0")] pub st_size: i64, #[stable(feature = "raw_ext", since = "1.1.0")] @@ -73,7 +75,7 @@ pub struct stat { #[stable(feature = "raw_ext", since = "1.1.0")] pub st_lspare: i32, #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_birthtime: i64, + pub st_birthtime: c_long, #[stable(feature = "raw_ext", since = "1.1.0")] - pub st_birthtime_nsec: i64, + pub st_birthtime_nsec: c_long, } From 90afb85a0c6c51a82933094f79ab0027915148c2 Mon Sep 17 00:00:00 2001 From: Ali Clark Date: Wed, 17 Feb 2016 16:59:03 +0000 Subject: [PATCH 4/4] re-add freebsd padding reproduces the padding found here: https://svnweb.freebsd.org/base/release/10.1.0/sys/sys/stat.h?view=markup#l139 --- src/libstd/os/freebsd/raw.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libstd/os/freebsd/raw.rs b/src/libstd/os/freebsd/raw.rs index b16eab017e4f..989eef63d82c 100644 --- a/src/libstd/os/freebsd/raw.rs +++ b/src/libstd/os/freebsd/raw.rs @@ -78,4 +78,7 @@ pub struct stat { pub st_birthtime: c_long, #[stable(feature = "raw_ext", since = "1.1.0")] pub st_birthtime_nsec: c_long, + #[cfg(target_arch = "x86")] + #[stable(feature = "raw_ext", since = "1.1.0")] + pub __unused: [u8; 8], }