Skip to content

Fixed for DragonFly #194

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

Merged
merged 2 commits into from
Feb 21, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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");
}

Expand Down Expand Up @@ -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
Expand All @@ -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(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably best if the dragonfly bindings avoid fflags_t entirely if it doesn't exist on dragonfly


t if t.ends_with("_t") => t.to_string(),

// Windows uppercase structs don't have `struct` in front, there's a
Expand Down Expand Up @@ -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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you add a comment here that this isn't an integer?

n if n.starts_with("pthread") => true,

// windows-isms
Expand Down Expand Up @@ -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,
Expand Down
11 changes: 0 additions & 11 deletions src/unix/bsd/freebsdlike/dragonfly.rs

This file was deleted.

76 changes: 76 additions & 0 deletions src/unix/bsd/freebsdlike/dragonfly/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
cfg_if! {
if #[cfg(target_arch = "x86_64")] {
mod x86_64;
pub use self::x86_64::*;
} else {
// ...
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you put this at the end of the file? Stylistically that tends to be its current location


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],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you you mean for these fields to be pub?

}

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;
31 changes: 31 additions & 0 deletions src/unix/bsd/freebsdlike/dragonfly/x86_64.rs
Original file line number Diff line number Diff line change
@@ -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,
}
}
13 changes: 0 additions & 13 deletions src/unix/bsd/freebsdlike/freebsd.rs

This file was deleted.

80 changes: 80 additions & 0 deletions src/unix/bsd/freebsdlike/freebsd/mod.rs
Original file line number Diff line number Diff line change
@@ -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;
}
Loading