Skip to content

Commit 60c988e

Browse files
committed
Fix libstd on DragonFly
Following changes: * birthtime does not exist on DragonFly * errno: __dfly_error is no more. Use #[thread_local] static errno. * clock_gettime expects a c_ulong (use a type alias) These changes are required to build DragonFly snapshots again.
1 parent a9f34c8 commit 60c988e

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

src/libstd/os/dragonfly/fs.rs

-10
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@ pub trait MetadataExt {
6363
#[stable(feature = "metadata_ext2", since = "1.8.0")]
6464
fn st_ctime_nsec(&self) -> i64;
6565
#[stable(feature = "metadata_ext2", since = "1.8.0")]
66-
fn st_birthtime(&self) -> i64;
67-
#[stable(feature = "metadata_ext2", since = "1.8.0")]
68-
fn st_birthtime_nsec(&self) -> i64;
69-
#[stable(feature = "metadata_ext2", since = "1.8.0")]
7066
fn st_blksize(&self) -> u64;
7167
#[stable(feature = "metadata_ext2", since = "1.8.0")]
7268
fn st_blocks(&self) -> u64;
@@ -129,12 +125,6 @@ impl MetadataExt for Metadata {
129125
fn st_ctime_nsec(&self) -> i64 {
130126
self.as_inner().as_inner().st_ctime_nsec as i64
131127
}
132-
fn st_birthtime(&self) -> i64 {
133-
self.as_inner().as_inner().st_birthtime as i64
134-
}
135-
fn st_birthtime_nsec(&self) -> i64 {
136-
self.as_inner().as_inner().st_birthtime_nsec as i64
137-
}
138128
fn st_blksize(&self) -> u64 {
139129
self.as_inner().as_inner().st_blksize as u64
140130
}

src/libstd/sys/unix/os.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const TMPBUF_SZ: usize = 128;
3636
static ENV_LOCK: StaticMutex = StaticMutex::new();
3737

3838
/// Returns the platform-specific value of errno
39+
#[cfg(not(target_os = "dragonfly"))]
3940
pub fn errno() -> i32 {
4041
extern {
4142
#[cfg_attr(any(target_os = "linux", target_os = "emscripten"),
@@ -47,7 +48,6 @@ pub fn errno() -> i32 {
4748
target_env = "newlib"),
4849
link_name = "__errno")]
4950
#[cfg_attr(target_os = "solaris", link_name = "___errno")]
50-
#[cfg_attr(target_os = "dragonfly", link_name = "__dfly_error")]
5151
#[cfg_attr(any(target_os = "macos",
5252
target_os = "ios",
5353
target_os = "freebsd"),
@@ -60,6 +60,16 @@ pub fn errno() -> i32 {
6060
}
6161
}
6262

63+
#[cfg(target_os = "dragonfly")]
64+
pub fn errno() -> i32 {
65+
extern {
66+
#[thread_local]
67+
static errno: c_int;
68+
}
69+
70+
errno as i32
71+
}
72+
6373
/// Gets a detailed string description for the given error number.
6474
pub fn error_string(errno: i32) -> String {
6575
extern {

src/libstd/sys/unix/time.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,13 @@ mod inner {
303303
}
304304
}
305305

306+
#[cfg(not(target_os = "dragonfly"))]
307+
pub type clock_t = libc::c_int;
308+
#[cfg(target_os = "dragonfly")]
309+
pub type clock_t = libc::c_ulong;
310+
306311
impl Timespec {
307-
pub fn now(clock: libc::c_int) -> Timespec {
312+
pub fn now(clock: clock_t) -> Timespec {
308313
let mut t = Timespec {
309314
t: libc::timespec {
310315
tv_sec: 0,

0 commit comments

Comments
 (0)