Skip to content

Commit a15e027

Browse files
committed
Fix all remaining issues on DragonFly
Missing functions and missing constats.
1 parent 3966e4f commit a15e027

File tree

3 files changed

+37
-8
lines changed

3 files changed

+37
-8
lines changed

libc-test/build.rs

Lines changed: 13 additions & 3 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
@@ -192,6 +199,9 @@ fn main() {
192199
// OSX calls this something else
193200
"sighandler_t" if bsdlike => "sig_t".to_string(),
194201

202+
// does not exist on DragonFly
203+
"fflags_t" if dragonfly => "uint32_t".to_string(),
204+
195205
t if t.ends_with("_t") => t.to_string(),
196206

197207
// Windows uppercase structs don't have `struct` in front, there's a
@@ -321,7 +331,7 @@ fn main() {
321331
"strerror_r" if linux => true, // actually xpg-something-or-other
322332

323333
// typed 2nd arg on linux and android
324-
"gettimeofday" if linux || android || freebsd || openbsd => true,
334+
"gettimeofday" if linux || android || freebsd || openbsd || dragonfly => true,
325335

326336
// not declared in newer android toolchains
327337
"getdtablesize" if android => true,

src/unix/bsd/freebsdlike/dragonfly/mod.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub type blksize_t = u64;
1515
s! {
1616
pub struct dirent {
1717
pub d_fileno: ::ino_t,
18-
pub d_namelen: u16,
18+
pub d_namlen: u16,
1919
pub d_type: u8,
2020
__unused1: u8,
2121
__unused2: u32,
@@ -30,7 +30,3 @@ pub const PTHREAD_STACK_MIN: ::size_t = 1024;
3030
pub const KERN_PROC_PATHNAME: ::c_int = 9;
3131
pub const SIGSTKSZ: ::size_t = 40960;
3232
pub const MADV_INVAL: ::c_int = 10;
33-
34-
extern {
35-
pub fn __dfly_error() -> *const ::c_int;
36-
}

src/unix/bsd/freebsdlike/mod.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ s! {
125125
pub l_pid: ::pid_t,
126126
pub l_type: ::c_short,
127127
pub l_whence: ::c_short,
128+
#[cfg(not(target_os = "dragonfly"))]
128129
pub l_sysid: ::c_int,
129130
}
130131

@@ -353,11 +354,17 @@ pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2;
353354
pub const POSIX_MADV_WILLNEED: ::c_int = 3;
354355
pub const POSIX_MADV_DONTNEED: ::c_int = 4;
355356

357+
#[cfg(not(target_os = "dragonfly"))]
356358
pub const POSIX_FADV_NORMAL: ::c_int = 0;
359+
#[cfg(not(target_os = "dragonfly"))]
357360
pub const POSIX_FADV_RANDOM: ::c_int = 1;
361+
#[cfg(not(target_os = "dragonfly"))]
358362
pub const POSIX_FADV_SEQUENTIAL: ::c_int = 2;
363+
#[cfg(not(target_os = "dragonfly"))]
359364
pub const POSIX_FADV_WILLNEED: ::c_int = 3;
365+
#[cfg(not(target_os = "dragonfly"))]
360366
pub const POSIX_FADV_DONTNEED: ::c_int = 4;
367+
#[cfg(not(target_os = "dragonfly"))]
361368
pub const POSIX_FADV_NOREUSE: ::c_int = 5;
362369

363370
pub const _SC_IOV_MAX: ::c_int = 56;
@@ -408,14 +415,17 @@ pub const RLIMIT_NOFILE: ::c_int = 8;
408415
pub const RLIMIT_SBSIZE: ::c_int = 9;
409416
pub const RLIMIT_VMEM: ::c_int = 10;
410417
pub const RLIMIT_AS: ::c_int = RLIMIT_VMEM;
418+
#[cfg(not(target_os = "dragonfly"))]
411419
pub const RLIMIT_NPTS: ::c_int = 11;
420+
#[cfg(not(target_os = "dragonfly"))]
412421
pub const RLIMIT_SWAP: ::c_int = 12;
413422

414423
pub const RLIM_NLIMITS: rlim_t = 13;
415424
pub const RLIM_INFINITY: rlim_t = 0x7fff_ffff_ffff_ffff;
416425

417426
pub const RUSAGE_SELF: ::c_int = 0;
418427
pub const RUSAGE_CHILDREN: ::c_int = -1;
428+
#[cfg(not(target_os = "dragonfly"))]
419429
pub const RUSAGE_THREAD: ::c_int = 1;
420430

421431
pub const MADV_NORMAL: ::c_int = 0;
@@ -428,6 +438,7 @@ pub const MADV_NOSYNC: ::c_int = 6;
428438
pub const MADV_AUTOSYNC: ::c_int = 7;
429439
pub const MADV_NOCORE: ::c_int = 8;
430440
pub const MADV_CORE: ::c_int = 9;
441+
#[cfg(not(target_os = "dragonfly"))]
431442
pub const MADV_PROTECT: ::c_int = 10;
432443

433444
pub const MINCORE_INCORE: ::c_int = 0x1;
@@ -594,8 +605,12 @@ extern {
594605
mibp: *mut ::c_int,
595606
sizep: *mut ::size_t)
596607
-> ::c_int;
608+
#[cfg(not(target_os = "dragonfly"))]
597609
pub fn mprotect(addr: *const ::c_void, len: ::size_t, prot: ::c_int)
598610
-> ::c_int;
611+
#[cfg(target_os = "dragonfly")]
612+
pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int)
613+
-> ::c_int;
599614
pub fn shm_open(name: *const ::c_char, oflag: ::c_int, mode: ::mode_t)
600615
-> ::c_int;
601616
pub fn sysctl(name: *const ::c_int,
@@ -611,8 +626,13 @@ extern {
611626
newp: *const ::c_void,
612627
newlen: ::size_t)
613628
-> ::c_int;
629+
#[cfg(not(target_os = "dragonfly"))]
614630
pub fn clock_gettime(clk_id: ::c_int, tp: *mut ::timespec) -> ::c_int;
631+
#[cfg(target_os = "dragonfly")]
632+
pub fn clock_gettime(clk_id: ::uint64_t, tp: *mut ::timespec) -> ::c_int;
633+
615634
pub fn pthread_set_name_np(tid: ::pthread_t, name: *const ::c_char);
635+
#[cfg(not(target_os = "dragonfly"))]
616636
pub fn posix_fallocate(fd: ::c_int, offset: ::off_t,
617637
len: ::off_t) -> ::c_int;
618638
pub fn sched_setscheduler(pid: ::pid_t, policy: ::c_int, param: *const sched_param) -> ::c_int;
@@ -626,9 +646,12 @@ extern {
626646
sbytes: *mut ::off_t,
627647
flags: ::c_int) -> ::c_int;
628648

649+
#[cfg(not(target_os = "dragonfly"))]
629650
pub fn posix_fadvise(fd: ::c_int, offset: ::off_t, len: ::off_t,
630651
advise: ::c_int) -> ::c_int;
652+
#[cfg(not(target_os = "dragonfly"))]
631653
pub fn mkostemp(template: *mut ::c_char, flags: ::c_int) -> ::c_int;
654+
#[cfg(not(target_os = "dragonfly"))]
632655
pub fn mkostemps(template: *mut ::c_char, suffixlen: ::c_int, flags: ::c_int) -> ::c_int;
633656
}
634657

0 commit comments

Comments
 (0)