-
Notifications
You must be signed in to change notification settings - Fork 1.1k
DragonFly has different stat, dirent, clock_t, ino_t, nlink_t, blksize_t #117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How come these are ignored? Are they not defined on dragonfly? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The quota's exist. The others not. I will add those that exist. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah ok, feel free to just delete any constants from the libc crate on dragonfly that aren't actually present in the dragonfly libc |
||
|
||
_ => 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, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm this seems worrisome, shouldn't this be fixed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have to check this. DragonFly uses socklen_t, which probably is the same as size_t. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it is already addressed by #110. OpenBSD had same problem and I splitted |
||
|
||
// is defined elsewhere | ||
"__dfly_error" if dragonfly => true, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh wow, there's no C header file that returns this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or wait, wasn't this part of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. exactly :). I am working on a patch to support thread-local externs, so that we don't need that anymore. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah ok, in that case this function should actually be removed from libc |
||
|
||
_ => false, | ||
} | ||
}); | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cfg_if! { | ||
if #[cfg(target_arch = "x86_64")] { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can feel free to inline everything in this file if there's only one definition, but either way works for me |
||
mod x86_64; | ||
pub use self::x86_64::*; | ||
} else { | ||
// ... | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
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; | ||
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_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; | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
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; | ||
pub const HW_AVAILCPU: ::c_int = 25; | ||
|
||
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 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; | ||
} | ||
|
||
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 { | ||
// ... | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps this could just be removed from the dragonfly definitions? It should be fine to push the typedef down lower into each respective module.