Skip to content

Commit 614199a

Browse files
committed
Auto merge of #853 - bgermann:master, r=alexcrichton
Prerequisites to build libc-test on Solaris These changes are required as a first step to Solaris CI.
2 parents 5054b3c + 9e70e60 commit 614199a

File tree

2 files changed

+53
-32
lines changed

2 files changed

+53
-32
lines changed

libc-test/build.rs

+37-5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ fn main() {
2424
let netbsd = target.contains("netbsd");
2525
let openbsd = target.contains("openbsd");
2626
let rumprun = target.contains("rumprun");
27+
let solaris = target.contains("solaris");
2728
let bsdlike = freebsd || apple || netbsd || openbsd || dragonfly;
2829
let mut cfg = ctest::TestGenerator::new();
2930

@@ -34,6 +35,10 @@ fn main() {
3435
cfg.define("_NETBSD_SOURCE", Some("1"));
3536
} else if windows {
3637
cfg.define("_WIN32_WINNT", Some("0x8000"));
38+
} else if solaris {
39+
cfg.define("_XOPEN_SOURCE", Some("700"));
40+
cfg.define("__EXTENSIONS__", None);
41+
cfg.define("_LCONV_C99", None);
3742
}
3843

3944
// Android doesn't actually have in_port_t but it's much easier if we
@@ -103,7 +108,9 @@ fn main() {
103108
cfg.header("pwd.h");
104109
cfg.header("grp.h");
105110
cfg.header("sys/utsname.h");
106-
cfg.header("sys/ptrace.h");
111+
if !solaris {
112+
cfg.header("sys/ptrace.h");
113+
}
107114
cfg.header("sys/mount.h");
108115
cfg.header("sys/uio.h");
109116
cfg.header("sched.h");
@@ -132,11 +139,11 @@ fn main() {
132139
cfg.header("ifaddrs.h");
133140
cfg.header("langinfo.h");
134141

135-
if !openbsd && !freebsd && !dragonfly {
142+
if !openbsd && !freebsd && !dragonfly && !solaris {
136143
cfg.header("sys/quota.h");
137144
}
138145

139-
if !musl && !x32 {
146+
if !musl && !x32 && !solaris {
140147
cfg.header("sys/sysctl.h");
141148
}
142149

@@ -291,6 +298,13 @@ fn main() {
291298
cfg.header("sys/ioctl_compat.h");
292299
}
293300

301+
if solaris {
302+
cfg.header("port.h");
303+
cfg.header("ucontext.h");
304+
cfg.header("sys/filio.h");
305+
cfg.header("sys/loadavg.h");
306+
}
307+
294308
if linux || freebsd || dragonfly || netbsd || apple || emscripten {
295309
if !uclibc {
296310
cfg.header("aio.h");
@@ -428,6 +442,8 @@ fn main() {
428442
"FILE_ATTRIBUTE_INTEGRITY_STREAM" |
429443
"ERROR_NOTHING_TO_TERMINATE" if mingw => true,
430444

445+
"SIG_DFL" |
446+
"SIG_ERR" |
431447
"SIG_IGN" => true, // sighandler_t weirdness
432448
"SIGUNUSED" => true, // removed in glibc 2.26
433449

@@ -515,6 +531,14 @@ fn main() {
515531
"BOTHER" => true,
516532

517533
"MFD_CLOEXEC" | "MFD_ALLOW_SEALING" if !mips && musl => true,
534+
535+
"DT_FIFO" | "DT_CHR" | "DT_DIR" | "DT_BLK" | "DT_REG" | "DT_LNK" | "DT_SOCK" if solaris => true,
536+
"USRQUOTA" | "GRPQUOTA" if solaris => true,
537+
"PRIO_MIN" | "PRIO_MAX" if solaris => true,
538+
539+
// These are defined for Solaris 11, but the crate is tested on illumos, where they are currently not defined
540+
"EADI" | "PORT_SOURCE_POSTWAIT" | "PORT_SOURCE_SIGNAL" | "PTHREAD_STACK_MIN" => true,
541+
518542
_ => false,
519543
}
520544
});
@@ -545,7 +569,7 @@ fn main() {
545569
"getdtablesize" if android => true,
546570

547571
"dlerror" if android => true, // const-ness is added
548-
"dladdr" if musl => true, // const-ness only added recently
572+
"dladdr" if musl || solaris => true, // const-ness only added recently
549573

550574
// OSX has 'struct tm *const' which we can't actually represent in
551575
// Rust, but is close enough to *mut
@@ -631,11 +655,19 @@ fn main() {
631655
// We can wait for the next major release to be compliant with the new API.
632656
// FIXME: unskip these for next major release
633657
"strerror_r" | "madvise" | "msync" | "mprotect" | "recvfrom" | "getpriority" |
634-
"setpriority" | "personality" if android => true,
658+
"setpriority" | "personality" if android || solaris => true,
635659
// In Android 64 bits, these functions have been fixed since unified headers.
636660
// Ignore these until next major version.
637661
"bind" | "writev" | "readv" | "sendmsg" | "recvmsg" if android && (aarch64 || x86_64) => true,
638662

663+
// signal is defined with sighandler_t, so ignore
664+
"signal" if solaris => true,
665+
666+
"cfmakeraw" | "cfsetspeed" if solaris => true,
667+
668+
// FIXME: mincore is defined with caddr_t on Solaris.
669+
"mincore" if solaris => true,
670+
639671
_ => false,
640672
}
641673
});

src/unix/solaris/mod.rs

+16-27
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ pub type sa_family_t = u16;
3232
pub type pthread_t = ::c_uint;
3333
pub type pthread_key_t = ::c_uint;
3434
pub type blksize_t = ::c_int;
35-
pub type fflags_t = ::c_int;
3635
pub type nl_item = ::c_int;
3736
pub type id_t = ::c_int;
3837
pub type idtype_t = ::c_uint;
@@ -119,7 +118,7 @@ s! {
119118
}
120119

121120
pub struct cmsghdr {
122-
pub cmsg_len: ::size_t,
121+
pub cmsg_len: ::socklen_t,
123122
pub cmsg_level: ::c_int,
124123
pub cmsg_type: ::c_int,
125124
}
@@ -177,7 +176,7 @@ s! {
177176
pub d_ino: ::ino_t,
178177
pub d_off: ::off_t,
179178
pub d_reclen: u16,
180-
pub d_name: [::c_char; 1]
179+
pub d_name: [::c_char; 3]
181180
}
182181

183182
pub struct glob_t {
@@ -352,7 +351,7 @@ s! {
352351
pub portev_source: ::c_ushort,
353352
pub portev_pad: ::c_ushort,
354353
pub portev_object: ::uintptr_t,
355-
pub portev_user: ::uintptr_t,
354+
pub portev_user: *mut ::c_void,
356355
}
357356
}
358357

@@ -902,13 +901,13 @@ pub const IFF_STANDBY: ::c_int = 0x0020000000; // Interface is a hot-spare
902901
pub const IFF_INACTIVE: ::c_int = 0x0040000000; // Functioning but not used
903902
pub const IFF_OFFLINE: ::c_int = 0x0080000000; // Interface is offline
904903
// If CoS marking is supported
905-
pub const IFF_COS_ENABLED: ::c_int = 0x0200000000;
906-
pub const IFF_PREFERRED: ::c_int = 0x0400000000; // Prefer as source address
907-
pub const IFF_TEMPORARY: ::c_int = 0x0800000000; // RFC3041
908-
pub const IFF_FIXEDMTU: ::c_int = 0x1000000000; // MTU set with SIOCSLIFMTU
909-
pub const IFF_VIRTUAL: ::c_int = 0x2000000000; // Cannot send/receive pkts
910-
pub const IFF_DUPLICATE: ::c_int = 0x4000000000; // Local address in use
911-
pub const IFF_IPMP: ::c_int = 0x8000000000; // IPMP IP interface
904+
pub const IFF_COS_ENABLED: ::c_longlong = 0x0200000000;
905+
pub const IFF_PREFERRED: ::c_longlong = 0x0400000000; // Prefer as source addr.
906+
pub const IFF_TEMPORARY: ::c_longlong = 0x0800000000; // RFC3041
907+
pub const IFF_FIXEDMTU: ::c_longlong = 0x1000000000; // MTU set with SIOCSLIFMTU
908+
pub const IFF_VIRTUAL: ::c_longlong = 0x2000000000; // Cannot send/receive pkts
909+
pub const IFF_DUPLICATE: ::c_longlong = 0x4000000000; // Local address in use
910+
pub const IFF_IPMP: ::c_longlong = 0x8000000000; // IPMP IP interface
912911

913912
pub const SHUT_RD: ::c_int = 0;
914913
pub const SHUT_WR: ::c_int = 1;
@@ -1262,7 +1261,7 @@ extern {
12621261
mode: ::mode_t, dev: dev_t) -> ::c_int;
12631262
pub fn mkfifoat(dirfd: ::c_int, pathname: *const ::c_char,
12641263
mode: ::mode_t) -> ::c_int;
1265-
pub fn sethostname(name: *const ::c_char, len: ::size_t) -> ::c_int;
1264+
pub fn sethostname(name: *mut ::c_char, len: ::c_int) -> ::c_int;
12661265
pub fn if_nameindex() -> *mut if_nameindex;
12671266
pub fn if_freenameindex(ptr: *mut if_nameindex);
12681267
pub fn pthread_create(native: *mut ::pthread_t,
@@ -1307,7 +1306,8 @@ extern {
13071306
flags: ::c_int, addr: *mut ::sockaddr,
13081307
addrlen: *mut ::socklen_t) -> ::ssize_t;
13091308
pub fn mkstemps(template: *mut ::c_char, suffixlen: ::c_int) -> ::c_int;
1310-
pub fn futimes(fd: ::c_int, times: *const ::timeval) -> ::c_int;
1309+
pub fn futimesat(fd: ::c_int, path: *const ::c_char,
1310+
times: *const ::timeval) -> ::c_int;
13111311
pub fn utimensat(dirfd: ::c_int, path: *const ::c_char,
13121312
times: *const ::timespec, flag: ::c_int) -> ::c_int;
13131313
pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char;
@@ -1330,13 +1330,13 @@ extern {
13301330

13311331
pub fn port_create() -> ::c_int;
13321332
pub fn port_associate(port: ::c_int, source: ::c_int, object: ::uintptr_t,
1333-
events: ::c_int, user: ::uintptr_t) -> ::c_int;
1333+
events: ::c_int, user: *mut ::c_void) -> ::c_int;
13341334
pub fn port_dissociate(port: ::c_int, source: ::c_int, object: ::uintptr_t)
13351335
-> ::c_int;
13361336
pub fn port_get(port: ::c_int, pe: *mut port_event,
1337-
timeout: *const ::timespec) -> ::c_int;
1337+
timeout: *mut ::timespec) -> ::c_int;
13381338
pub fn port_getn(port: ::c_int, pe_list: *mut port_event, max: ::c_uint,
1339-
nget: *mut ::c_uint, timeout: *const ::timespec)
1339+
nget: *mut ::c_uint, timeout: *mut ::timespec)
13401340
-> ::c_int;
13411341
pub fn fexecve(fd: ::c_int, argv: *const *const ::c_char,
13421342
envp: *const *const ::c_char)
@@ -1347,9 +1347,6 @@ extern {
13471347
buf: *mut ::c_char,
13481348
buflen: ::size_t,
13491349
result: *mut *mut ::group) -> ::c_int;
1350-
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
1351-
link_name = "sigaltstack$UNIX2003")]
1352-
#[cfg_attr(target_os = "netbsd", link_name = "__sigaltstack14")]
13531350
pub fn sigaltstack(ss: *const stack_t,
13541351
oss: *mut stack_t) -> ::c_int;
13551352
pub fn sem_close(sem: *mut sem_t) -> ::c_int;
@@ -1360,40 +1357,32 @@ extern {
13601357
buf: *mut ::c_char,
13611358
buflen: ::size_t,
13621359
result: *mut *mut ::group) -> ::c_int;
1363-
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
1364-
link_name = "pthread_sigmask$UNIX2003")]
13651360
pub fn pthread_sigmask(how: ::c_int, set: *const sigset_t,
13661361
oldset: *mut sigset_t) -> ::c_int;
13671362
pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t;
13681363
pub fn getgrnam(name: *const ::c_char) -> *mut ::group;
13691364
pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int;
13701365
pub fn sem_unlink(name: *const ::c_char) -> ::c_int;
13711366
pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int;
1372-
#[cfg_attr(target_os = "netbsd", link_name = "__getpwnam_r50")]
13731367
#[cfg_attr(target_os = "solaris", link_name = "__posix_getpwnam_r")]
13741368
pub fn getpwnam_r(name: *const ::c_char,
13751369
pwd: *mut passwd,
13761370
buf: *mut ::c_char,
13771371
buflen: ::size_t,
13781372
result: *mut *mut passwd) -> ::c_int;
1379-
#[cfg_attr(target_os = "netbsd", link_name = "__getpwuid_r50")]
13801373
#[cfg_attr(target_os = "solaris", link_name = "__posix_getpwuid_r")]
13811374
pub fn getpwuid_r(uid: ::uid_t,
13821375
pwd: *mut passwd,
13831376
buf: *mut ::c_char,
13841377
buflen: ::size_t,
13851378
result: *mut *mut passwd) -> ::c_int;
1386-
#[cfg_attr(all(target_os = "macos", target_arch ="x86"),
1387-
link_name = "sigwait$UNIX2003")]
13881379
#[cfg_attr(target_os = "solaris", link_name = "__posix_sigwait")]
13891380
pub fn sigwait(set: *const sigset_t,
13901381
sig: *mut ::c_int) -> ::c_int;
13911382
pub fn pthread_atfork(prepare: Option<unsafe extern fn()>,
13921383
parent: Option<unsafe extern fn()>,
13931384
child: Option<unsafe extern fn()>) -> ::c_int;
13941385
pub fn getgrgid(gid: ::gid_t) -> *mut ::group;
1395-
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
1396-
link_name = "popen$UNIX2003")]
13971386
pub fn popen(command: *const c_char,
13981387
mode: *const c_char) -> *mut ::FILE;
13991388
}

0 commit comments

Comments
 (0)