Skip to content

Commit 411cafc

Browse files
committed
Auto merge of rust-lang#464 - mneumann:dragonfly-fixes-2016-12, r=alexcrichton
Dragonfly fixes 2016-12 This fixes libc again for DragonFly.
2 parents 3274c92 + 51cc3b7 commit 411cafc

File tree

4 files changed

+115
-53
lines changed

4 files changed

+115
-53
lines changed

libc-test/build.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ fn main() {
216216
cfg.header("sys/ioctl_compat.h");
217217
}
218218

219-
if linux || freebsd || netbsd || apple {
219+
if linux || freebsd || dragonfly || netbsd || apple {
220220
cfg.header("aio.h");
221221
}
222222

@@ -315,7 +315,7 @@ fn main() {
315315
"uuid_t" if dragonfly => true,
316316
n if n.starts_with("pthread") => true,
317317
// sem_t is a struct or pointer
318-
"sem_t" if openbsd || freebsd || rumprun => true,
318+
"sem_t" if openbsd || freebsd || dragonfly || rumprun => true,
319319

320320
// windows-isms
321321
n if n.starts_with("P") => true,

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

Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,34 @@ pub type uuid_t = ::uuid;
1414
pub type fsblkcnt_t = u64;
1515
pub type fsfilcnt_t = u64;
1616

17+
pub type sem_t = *mut sem;
18+
19+
pub enum sem {}
20+
1721
s! {
22+
23+
pub struct exit_status {
24+
pub e_termination: u16,
25+
pub e_exit: u16
26+
}
27+
28+
pub struct utmpx {
29+
pub ut_name: [::c_char; 32],
30+
pub ut_id: [::c_char; 4],
31+
32+
pub ut_line: [::c_char; 32],
33+
pub ut_host: [::c_char; 256],
34+
35+
pub ut_unused: [u8; 16],
36+
pub ut_session: u16,
37+
pub ut_type: u16,
38+
pub ut_pid: ::pid_t,
39+
ut_exit: exit_status,
40+
ut_ss: ::sockaddr_storage,
41+
pub ut_tv: ::timeval,
42+
pub ut_unused2: [u8; 16],
43+
}
44+
1845
pub struct aiocb {
1946
pub aio_fildes: ::c_int,
2047
pub aio_offset: ::off_t,
@@ -47,11 +74,15 @@ s! {
4774

4875
pub struct sigevent {
4976
pub sigev_notify: ::c_int,
50-
pub sigev_signo: ::c_int, //actually a union
77+
// The union is 8-byte in size, so it is aligned at a 8-byte offset.
5178
#[cfg(target_pointer_width = "64")]
5279
__unused1: ::c_int,
80+
pub sigev_signo: ::c_int, //actually a union
81+
// pad the union
82+
#[cfg(target_pointer_width = "64")]
83+
__unused2: ::c_int,
5384
pub sigev_value: ::sigval,
54-
__unused2: *mut ::c_void //actually a function pointer
85+
__unused3: *mut ::c_void //actually a function pointer
5586
}
5687

5788
pub struct statvfs {
@@ -271,7 +302,6 @@ pub const EVFILT_VNODE: ::int16_t = -4;
271302
pub const EVFILT_PROC: ::int16_t = -5;
272303
pub const EVFILT_SIGNAL: ::int16_t = -6;
273304
pub const EVFILT_TIMER: ::int16_t = -7;
274-
pub const EVFILT_PROCDESC: ::int16_t = -8;
275305
pub const EVFILT_USER: ::int16_t = -9;
276306
pub const EVFILT_FS: ::int16_t = -10;
277307

@@ -314,11 +344,41 @@ pub const NOTE_TRACK: ::uint32_t = 0x00000001;
314344
pub const NOTE_TRACKERR: ::uint32_t = 0x00000002;
315345
pub const NOTE_CHILD: ::uint32_t = 0x00000004;
316346

317-
pub const MSG_NOSIGNAL: ::uint32_t = 0x400;
347+
pub const MSG_NOSIGNAL: ::c_int = 0x400;
348+
349+
pub const EMPTY: ::c_short = 0;
350+
pub const RUN_LVL: ::c_short = 1;
351+
pub const BOOT_TIME: ::c_short = 2;
352+
pub const OLD_TIME: ::c_short = 3;
353+
pub const NEW_TIME: ::c_short = 4;
354+
pub const INIT_PROCESS: ::c_short = 5;
355+
pub const LOGIN_PROCESS: ::c_short = 6;
356+
pub const USER_PROCESS: ::c_short = 7;
357+
pub const DEAD_PROCESS: ::c_short = 8;
358+
359+
pub const LC_COLLATE_MASK: ::c_int = (1 << 0);
360+
pub const LC_CTYPE_MASK: ::c_int = (1 << 1);
361+
pub const LC_MONETARY_MASK: ::c_int = (1 << 2);
362+
pub const LC_NUMERIC_MASK: ::c_int = (1 << 3);
363+
pub const LC_TIME_MASK: ::c_int = (1 << 4);
364+
pub const LC_MESSAGES_MASK: ::c_int = (1 << 5);
365+
pub const LC_ALL_MASK: ::c_int = LC_COLLATE_MASK
366+
| LC_CTYPE_MASK
367+
| LC_MESSAGES_MASK
368+
| LC_MONETARY_MASK
369+
| LC_NUMERIC_MASK
370+
| LC_TIME_MASK;
318371

319372
extern {
320373
pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int)
321374
-> ::c_int;
322375
pub fn clock_getres(clk_id: clockid_t, tp: *mut ::timespec) -> ::c_int;
323376
pub fn clock_gettime(clk_id: clockid_t, tp: *mut ::timespec) -> ::c_int;
377+
378+
pub fn setutxdb(_type: ::c_uint, file: *mut ::c_char) -> ::c_int;
379+
380+
pub fn aio_waitcomplete(iocbp: *mut *mut aiocb,
381+
timeout: *mut ::timespec) -> ::c_int;
382+
383+
pub fn freelocale(loc: ::locale_t);
324384
}

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

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,23 @@ pub type lwpid_t = i32;
55
pub type nlink_t = u16;
66
pub type blksize_t = u32;
77
pub type clockid_t = ::c_int;
8+
pub type sem_t = _sem;
89

910
pub type fsblkcnt_t = ::uint64_t;
1011
pub type fsfilcnt_t = ::uint64_t;
1112

1213
s! {
14+
pub struct utmpx {
15+
pub ut_type: ::c_short,
16+
pub ut_tv: ::timeval,
17+
pub ut_id: [::c_char; 8],
18+
pub ut_pid: ::pid_t,
19+
pub ut_user: [::c_char; 32],
20+
pub ut_line: [::c_char; 16],
21+
pub ut_host: [::c_char; 128],
22+
pub __ut_spare: [::c_char; 64],
23+
}
24+
1325
pub struct aiocb {
1426
pub aio_fildes: ::c_int,
1527
pub aio_offset: ::off_t,
@@ -59,12 +71,18 @@ s! {
5971
pub f_fsid: ::c_ulong,
6072
pub f_namemax: ::c_ulong,
6173
}
74+
75+
// internal structure has changed over time
76+
pub struct _sem {
77+
data: [u32; 4],
78+
}
6279
}
6380

6481
pub const SIGEV_THREAD_ID: ::c_int = 4;
6582

6683
pub const RAND_MAX: ::c_int = 0x7fff_fffd;
6784
pub const PTHREAD_STACK_MIN: ::size_t = 2048;
85+
pub const PTHREAD_MUTEX_ADAPTIVE_NP: ::c_int = 4;
6886
pub const SIGSTKSZ: ::size_t = 34816;
6987
pub const SF_NODISKIO: ::c_int = 0x00000001;
7088
pub const SF_MNOWAIT: ::c_int = 0x00000002;
@@ -315,6 +333,29 @@ pub const CTL_P1003_1B_MAXID: ::c_int = 26;
315333

316334
pub const MSG_NOSIGNAL: ::c_int = 0x20000;
317335

336+
pub const EMPTY: ::c_short = 0;
337+
pub const BOOT_TIME: ::c_short = 1;
338+
pub const OLD_TIME: ::c_short = 2;
339+
pub const NEW_TIME: ::c_short = 3;
340+
pub const USER_PROCESS: ::c_short = 4;
341+
pub const INIT_PROCESS: ::c_short = 5;
342+
pub const LOGIN_PROCESS: ::c_short = 6;
343+
pub const DEAD_PROCESS: ::c_short = 7;
344+
pub const SHUTDOWN_TIME: ::c_short = 8;
345+
346+
pub const LC_COLLATE_MASK: ::c_int = (1 << 0);
347+
pub const LC_CTYPE_MASK: ::c_int = (1 << 1);
348+
pub const LC_MESSAGES_MASK: ::c_int = (1 << 2);
349+
pub const LC_MONETARY_MASK: ::c_int = (1 << 3);
350+
pub const LC_NUMERIC_MASK: ::c_int = (1 << 4);
351+
pub const LC_TIME_MASK: ::c_int = (1 << 5);
352+
pub const LC_ALL_MASK: ::c_int = LC_COLLATE_MASK
353+
| LC_CTYPE_MASK
354+
| LC_MESSAGES_MASK
355+
| LC_MONETARY_MASK
356+
| LC_NUMERIC_MASK
357+
| LC_TIME_MASK;
358+
318359
extern {
319360
pub fn __error() -> *mut ::c_int;
320361

@@ -332,6 +373,14 @@ extern {
332373
pub fn mkostemps(template: *mut ::c_char,
333374
suffixlen: ::c_int,
334375
flags: ::c_int) -> ::c_int;
376+
377+
pub fn getutxuser(user: *const ::c_char) -> *mut utmpx;
378+
pub fn setutxdb(_type: ::c_int, file: *const ::c_char) -> ::c_int;
379+
380+
pub fn aio_waitcomplete(iocbp: *mut *mut aiocb,
381+
timeout: *mut ::timespec) -> ::ssize_t;
382+
383+
pub fn freelocale(loc: ::locale_t) -> ::c_int;
335384
}
336385

337386
cfg_if! {

src/unix/bsd/freebsdlike/mod.rs

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,10 @@ pub type tcflag_t = ::c_uint;
1212
pub type speed_t = ::c_uint;
1313
pub type nl_item = ::c_int;
1414
pub type id_t = i64;
15-
pub type sem_t = _sem;
1615

1716
pub enum timezone {}
1817

1918
s! {
20-
pub struct utmpx {
21-
pub ut_type: ::c_short,
22-
pub ut_tv: ::timeval,
23-
pub ut_id: [::c_char; 8],
24-
pub ut_pid: ::pid_t,
25-
pub ut_user: [::c_char; 32],
26-
pub ut_line: [::c_char; 16],
27-
pub ut_host: [::c_char; 128],
28-
pub __ut_spare: [::c_char; 64],
29-
}
30-
3119
pub struct glob_t {
3220
pub gl_pathc: ::size_t,
3321
pub gl_matchc: ::size_t,
@@ -170,11 +158,6 @@ s! {
170158
pub int_p_sign_posn: ::c_char,
171159
pub int_n_sign_posn: ::c_char,
172160
}
173-
174-
// internal structure has changed over time
175-
pub struct _sem {
176-
data: [u32; 4],
177-
}
178161
}
179162

180163
pub const AIO_LISTIO_MAX: ::c_int = 16;
@@ -192,29 +175,6 @@ pub const SIGEV_SIGNAL: ::c_int = 1;
192175
pub const SIGEV_THREAD: ::c_int = 2;
193176
pub const SIGEV_KEVENT: ::c_int = 3;
194177

195-
pub const EMPTY: ::c_short = 0;
196-
pub const BOOT_TIME: ::c_short = 1;
197-
pub const OLD_TIME: ::c_short = 2;
198-
pub const NEW_TIME: ::c_short = 3;
199-
pub const USER_PROCESS: ::c_short = 4;
200-
pub const INIT_PROCESS: ::c_short = 5;
201-
pub const LOGIN_PROCESS: ::c_short = 6;
202-
pub const DEAD_PROCESS: ::c_short = 7;
203-
pub const SHUTDOWN_TIME: ::c_short = 8;
204-
205-
pub const LC_COLLATE_MASK: ::c_int = (1 << 0);
206-
pub const LC_CTYPE_MASK: ::c_int = (1 << 1);
207-
pub const LC_MESSAGES_MASK: ::c_int = (1 << 2);
208-
pub const LC_MONETARY_MASK: ::c_int = (1 << 3);
209-
pub const LC_NUMERIC_MASK: ::c_int = (1 << 4);
210-
pub const LC_TIME_MASK: ::c_int = (1 << 5);
211-
pub const LC_ALL_MASK: ::c_int = LC_COLLATE_MASK
212-
| LC_CTYPE_MASK
213-
| LC_MESSAGES_MASK
214-
| LC_MONETARY_MASK
215-
| LC_NUMERIC_MASK
216-
| LC_TIME_MASK;
217-
218178
pub const CODESET: ::nl_item = 0;
219179
pub const D_T_FMT: ::nl_item = 1;
220180
pub const D_FMT: ::nl_item = 2;
@@ -706,7 +666,6 @@ pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = 0 as *mut _;
706666
pub const PTHREAD_MUTEX_ERRORCHECK: ::c_int = 1;
707667
pub const PTHREAD_MUTEX_RECURSIVE: ::c_int = 2;
708668
pub const PTHREAD_MUTEX_NORMAL: ::c_int = 3;
709-
pub const PTHREAD_MUTEX_ADAPTIVE_NP: ::c_int = 4;
710669
pub const PTHREAD_MUTEX_DEFAULT: ::c_int = PTHREAD_MUTEX_ERRORCHECK;
711670

712671
pub const SCHED_FIFO: ::c_int = 1;
@@ -756,8 +715,6 @@ extern {
756715
pub fn getutxline(ut: *const utmpx) -> *mut utmpx;
757716
pub fn pututxline(ut: *const utmpx) -> *mut utmpx;
758717
pub fn setutxent();
759-
pub fn getutxuser(user: *const ::c_char) -> *mut utmpx;
760-
pub fn setutxdb(_type: ::c_int, file: *const ::c_char) -> ::c_int;
761718
}
762719

763720
#[link(name = "util")]
@@ -772,9 +729,6 @@ extern {
772729
pub fn aio_cancel(fd: ::c_int, aiocbp: *mut aiocb) -> ::c_int;
773730
pub fn lio_listio(mode: ::c_int, aiocb_list: *const *mut aiocb,
774731
nitems: ::c_int, sevp: *mut sigevent) -> ::c_int;
775-
pub fn aio_waitcomplete(iocbp: *mut *mut aiocb,
776-
timeout: *mut ::timespec) -> ::ssize_t;
777-
778732
pub fn getnameinfo(sa: *const ::sockaddr,
779733
salen: ::socklen_t,
780734
host: *mut ::c_char,
@@ -839,7 +793,6 @@ extern {
839793
winp: *mut ::winsize) -> ::pid_t;
840794
pub fn nl_langinfo_l(item: ::nl_item, locale: ::locale_t) -> *mut ::c_char;
841795
pub fn duplocale(base: ::locale_t) -> ::locale_t;
842-
pub fn freelocale(loc: ::locale_t) -> ::c_int;
843796
pub fn newlocale(mask: ::c_int,
844797
locale: *const ::c_char,
845798
base: ::locale_t) -> ::locale_t;

0 commit comments

Comments
 (0)