Skip to content

Commit b57e312

Browse files
committed
Merge pull request #194 from mneumann/dragonfly_fixes_2016_squashed
Fixed for DragonFly
2 parents 054147a + a09fe71 commit b57e312

File tree

9 files changed

+222
-99
lines changed

9 files changed

+222
-99
lines changed

libc-test/build.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ fn main() {
1414
let apple = target.contains("apple");
1515
let musl = target.contains("musl");
1616
let freebsd = target.contains("freebsd");
17+
let dragonfly = target.contains("dragonfly");
1718
let mips = target.contains("mips");
1819
let netbsd = target.contains("netbsd");
1920
let openbsd = target.contains("openbsd");
2021
let rumprun = target.contains("rumprun");
21-
let bsdlike = freebsd || apple || netbsd || openbsd;
22+
let bsdlike = freebsd || apple || netbsd || openbsd || dragonfly;
2223
let mut cfg = ctest::TestGenerator::new();
2324

2425
// Pull in extra goodies on linux/mingw
@@ -103,7 +104,7 @@ fn main() {
103104
cfg.header("ifaddrs.h");
104105
cfg.header("sys/statvfs.h");
105106

106-
if !openbsd && !freebsd {
107+
if !openbsd && !freebsd && !dragonfly {
107108
cfg.header("sys/quota.h");
108109
}
109110

@@ -177,6 +178,12 @@ fn main() {
177178
cfg.header("sys/syscall.h");
178179
}
179180

181+
if dragonfly {
182+
cfg.header("ufs/ufs/quota.h");
183+
cfg.header("pthread_np.h");
184+
cfg.header("sys/ioctl_compat.h");
185+
}
186+
180187
cfg.type_name(move |ty, is_struct| {
181188
match ty {
182189
// Just pass all these through, no need for a "struct" prefix
@@ -254,12 +261,14 @@ fn main() {
254261
}
255262
});
256263

257-
cfg.skip_signededness(|c| {
264+
cfg.skip_signededness(move |c| {
258265
match c {
259266
"LARGE_INTEGER" |
260267
"mach_timebase_info_data_t" |
261268
"float" |
262269
"double" => true,
270+
// uuid_t is a struct, not an integer.
271+
"uuid_t" if dragonfly => true,
263272
n if n.starts_with("pthread") => true,
264273

265274
// windows-isms
@@ -321,7 +330,7 @@ fn main() {
321330
"strerror_r" if linux => true, // actually xpg-something-or-other
322331

323332
// typed 2nd arg on linux and android
324-
"gettimeofday" if linux || android || freebsd || openbsd => true,
333+
"gettimeofday" if linux || android || freebsd || openbsd || dragonfly => true,
325334

326335
// not declared in newer android toolchains
327336
"getdtablesize" if android => true,

src/unix/bsd/freebsdlike/dragonfly.rs

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
pub type clock_t = u64;
2+
pub type ino_t = u64;
3+
pub type nlink_t = u32;
4+
pub type blksize_t = i64;
5+
6+
pub type c_long = i64;
7+
pub type c_ulong = u64;
8+
pub type time_t = i64;
9+
pub type suseconds_t = i64;
10+
11+
s! {
12+
pub struct dirent {
13+
pub d_fileno: ::ino_t,
14+
pub d_namlen: u16,
15+
pub d_type: u8,
16+
__unused1: u8,
17+
__unused2: u32,
18+
pub d_name: [::c_char; 256],
19+
}
20+
21+
pub struct uuid {
22+
pub time_low: u32,
23+
pub time_mid: u16,
24+
pub time_hi_and_version: u16,
25+
pub clock_seq_hi_and_reserved: u8,
26+
pub clock_seq_low: u8,
27+
pub node: [u8; 6],
28+
}
29+
30+
pub struct statvfs {
31+
pub f_bsize: ::c_ulong,
32+
pub f_frsize: ::c_ulong,
33+
pub f_blocks: ::fsblkcnt_t,
34+
pub f_bfree: ::fsblkcnt_t,
35+
pub f_bavail: ::fsblkcnt_t,
36+
pub f_files: ::fsfilcnt_t,
37+
pub f_ffree: ::fsfilcnt_t,
38+
pub f_favail: ::fsfilcnt_t,
39+
pub f_fsid: ::c_ulong,
40+
pub f_flag: ::c_ulong,
41+
pub f_namemax: ::c_ulong,
42+
pub f_owner: ::uid_t,
43+
pub f_type: ::c_uint,
44+
pub f_syncreads: u64,
45+
pub f_syncwrites: u64,
46+
pub f_asyncreads: u64,
47+
pub f_asyncwrites: u64,
48+
pub f_fsid_uuid: ::uuid_t,
49+
pub f_uid_uuid: ::uuid_t,
50+
}
51+
52+
pub struct stat {
53+
pub st_ino: ::ino_t,
54+
pub st_nlink: ::nlink_t,
55+
pub st_dev: ::dev_t,
56+
pub st_mode: ::mode_t,
57+
pub st_padding1: ::uint16_t,
58+
pub st_uid: ::uid_t,
59+
pub st_gid: ::gid_t,
60+
pub st_rdev: ::dev_t,
61+
pub st_atime: ::time_t,
62+
pub st_atime_nsec: ::c_long,
63+
pub st_mtime: ::time_t,
64+
pub st_mtime_nsec: ::c_long,
65+
pub st_ctime: ::time_t,
66+
pub st_ctime_nsec: ::c_long,
67+
pub st_size: ::off_t,
68+
pub st_blocks: ::int64_t,
69+
pub st_blksize: ::uint32_t,
70+
pub st_flags: ::uint32_t,
71+
pub st_gen: ::uint32_t,
72+
pub st_lspare: ::int32_t,
73+
pub st_qspare1: ::int64_t,
74+
pub st_qspare2: ::int64_t,
75+
}
76+
}
77+
78+
pub type uuid_t = ::uuid;
79+
80+
pub type fsblkcnt_t = u64;
81+
pub type fsfilcnt_t = u64;
82+
83+
pub const RAND_MAX: ::c_int = 0x7fff_ffff;
84+
pub const PTHREAD_STACK_MIN: ::size_t = 1024;
85+
pub const KERN_PROC_PATHNAME: ::c_int = 9;
86+
pub const SIGSTKSZ: ::size_t = 40960;
87+
pub const MADV_INVAL: ::c_int = 10;
88+
pub const O_CLOEXEC: ::c_int = 0x00020000;
89+
pub const F_GETLK: ::c_int = 7;
90+
pub const F_SETLK: ::c_int = 8;
91+
pub const F_SETLKW: ::c_int = 9;
92+
pub const ELAST: ::c_int = 99;
93+
pub const RLIMIT_POSIXLOCKS: ::c_int = 11;
94+
pub const RLIM_NLIMITS: ::rlim_t = 12;
95+
96+
pub const Q_GETQUOTA: ::c_int = 0x300;
97+
pub const Q_SETQUOTA: ::c_int = 0x400;
98+
99+
extern {
100+
pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int)
101+
-> ::c_int;
102+
pub fn clock_gettime(clk_id: ::c_ulong, tp: *mut ::timespec) -> ::c_int;
103+
}

src/unix/bsd/freebsdlike/freebsd.rs

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
pub type fflags_t = u32;
2+
pub type clock_t = i32;
3+
pub type ino_t = u32;
4+
pub type nlink_t = u16;
5+
pub type blksize_t = u32;
6+
7+
s! {
8+
pub struct dirent {
9+
pub d_fileno: u32,
10+
pub d_reclen: u16,
11+
pub d_type: u8,
12+
pub d_namlen: u8,
13+
pub d_name: [::c_char; 256],
14+
}
15+
16+
pub struct statvfs {
17+
pub f_bavail: ::fsblkcnt_t,
18+
pub f_bfree: ::fsblkcnt_t,
19+
pub f_blocks: ::fsblkcnt_t,
20+
pub f_favail: ::fsfilcnt_t,
21+
pub f_ffree: ::fsfilcnt_t,
22+
pub f_files: ::fsfilcnt_t,
23+
pub f_bsize: ::c_ulong,
24+
pub f_flag: ::c_ulong,
25+
pub f_frsize: ::c_ulong,
26+
pub f_fsid: ::c_ulong,
27+
pub f_namemax: ::c_ulong,
28+
}
29+
}
30+
31+
pub type fsblkcnt_t = ::uint64_t;
32+
pub type fsfilcnt_t = ::uint64_t;
33+
34+
pub const RAND_MAX: ::c_int = 0x7fff_fffd;
35+
pub const PTHREAD_STACK_MIN: ::size_t = 2048;
36+
pub const KERN_PROC_PATHNAME: ::c_int = 12;
37+
pub const SIGSTKSZ: ::size_t = 34816;
38+
pub const SF_NODISKIO: ::c_int = 0x00000001;
39+
pub const SF_MNOWAIT: ::c_int = 0x00000002;
40+
pub const SF_SYNC: ::c_int = 0x00000004;
41+
pub const O_CLOEXEC: ::c_int = 0x00100000;
42+
pub const F_GETLK: ::c_int = 11;
43+
pub const F_SETLK: ::c_int = 12;
44+
pub const F_SETLKW: ::c_int = 13;
45+
pub const ELAST: ::c_int = 96;
46+
pub const RLIMIT_NPTS: ::c_int = 11;
47+
pub const RLIMIT_SWAP: ::c_int = 12;
48+
pub const RLIM_NLIMITS: ::rlim_t = 13;
49+
50+
pub const Q_GETQUOTA: ::c_int = 0x700;
51+
pub const Q_SETQUOTA: ::c_int = 0x800;
52+
53+
pub const POSIX_FADV_NORMAL: ::c_int = 0;
54+
pub const POSIX_FADV_RANDOM: ::c_int = 1;
55+
pub const POSIX_FADV_SEQUENTIAL: ::c_int = 2;
56+
pub const POSIX_FADV_WILLNEED: ::c_int = 3;
57+
pub const POSIX_FADV_DONTNEED: ::c_int = 4;
58+
pub const POSIX_FADV_NOREUSE: ::c_int = 5;
59+
60+
extern {
61+
pub fn __error() -> *mut ::c_int;
62+
63+
pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int)
64+
-> ::c_int;
65+
66+
pub fn clock_gettime(clk_id: ::c_int, tp: *mut ::timespec) -> ::c_int;
67+
68+
pub fn posix_fallocate(fd: ::c_int, offset: ::off_t,
69+
len: ::off_t) -> ::c_int;
70+
pub fn posix_fadvise(fd: ::c_int, offset: ::off_t, len: ::off_t,
71+
advise: ::c_int) -> ::c_int;
72+
pub fn mkostemp(template: *mut ::c_char, flags: ::c_int) -> ::c_int;
73+
pub fn mkostemps(template: *mut ::c_char, suffixlen: ::c_int, flags: ::c_int) -> ::c_int;
74+
}
75+
76+
cfg_if! {
77+
if #[cfg(target_arch = "x86")] {
78+
mod x86;
79+
pub use self::x86::*;
80+
} else if #[cfg(target_arch = "x86_64")] {
81+
mod x86_64;
82+
pub use self::x86_64::*;
83+
} else {
84+
// ...
85+
}
86+
}

0 commit comments

Comments
 (0)