Skip to content

Commit 2cd820e

Browse files
committed
Fixes tests on Solaris
1 parent 72cb7aa commit 2cd820e

File tree

9 files changed

+291
-141
lines changed

9 files changed

+291
-141
lines changed

libc-test/build.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -795,8 +795,6 @@ fn test_solarish(target: &str) {
795795
"stdlib.h",
796796
"string.h",
797797
"sys/auxv.h",
798-
"sys/epoll.h",
799-
"sys/eventfd.h",
800798
"sys/file.h",
801799
"sys/filio.h",
802800
"sys/ioctl.h",
@@ -836,6 +834,19 @@ fn test_solarish(target: &str) {
836834
"wchar.h",
837835
}
838836

837+
if is_illumos {
838+
headers! { cfg:
839+
"sys/epoll.h",
840+
"sys/eventfd.h",
841+
}
842+
}
843+
844+
if is_solaris {
845+
headers! { cfg:
846+
"sys/lgrp_user_impl.h",
847+
}
848+
}
849+
839850
cfg.skip_type(move |ty| match ty {
840851
"sighandler_t" => true,
841852
_ => false,
@@ -885,7 +896,7 @@ fn test_solarish(target: &str) {
885896
// EPOLLEXCLUSIVE is a relatively recent addition to the epoll interface and may not be
886897
// defined on older systems. It is, however, safe to use on systems which do not
887898
// explicitly support it. (A no-op is an acceptable implementation of EPOLLEXCLUSIVE.)
888-
"EPOLLEXCLUSIVE" => true,
899+
"EPOLLEXCLUSIVE" if is_illumos => true,
889900

890901
_ => false,
891902
});
@@ -977,7 +988,7 @@ fn test_solarish(target: &str) {
977988
// These functions may return int or void depending on the exact
978989
// configuration of the compilation environment, but the return
979990
// value is not useful (always 0) so we can ignore it:
980-
"setservent" | "endservent" if is_illumos => true,
991+
"setservent" | "endservent" => true,
981992

982993
// Following illumos#3729, getifaddrs was changed to a
983994
// redefine_extname symbol in order to preserve compatibility.

libc-test/semver/TODO-unix.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,8 @@
33
getpwuid_r
44
pthread_atfork
55
pthread_sigmask
6+
# * Solaris is missing flock(2)
7+
LOCK_EX
8+
LOCK_NB
9+
LOCK_SH
10+
LOCK_UN

libc-test/semver/unix.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,6 @@ ISTRIP
184184
IXANY
185185
IXOFF
186186
IXON
187-
LOCK_EX
188-
LOCK_NB
189-
LOCK_SH
190-
LOCK_UN
191187
LOG_ALERT
192188
LOG_AUTH
193189
LOG_CONS

src/unix/mod.rs

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -602,10 +602,8 @@ extern "C" {
602602

603603
#[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
604604
#[cfg_attr(target_os = "netbsd", link_name = "__socket30")]
605-
#[cfg_attr(
606-
any(target_os = "illumos", target_os = "solaris"),
607-
link_name = "__xnet_socket"
608-
)]
605+
#[cfg_attr(target_os = "illumos", link_name = "__xnet_socket")]
606+
#[cfg_attr(target_os = "solaris", link_name = "__xnet7_socket")]
609607
#[cfg_attr(target_os = "espidf", link_name = "lwip_socket")]
610608
pub fn socket(domain: ::c_int, ty: ::c_int, protocol: ::c_int) -> ::c_int;
611609
#[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
@@ -891,6 +889,7 @@ extern "C" {
891889
pub fn getppid() -> pid_t;
892890
pub fn getuid() -> uid_t;
893891
pub fn isatty(fd: ::c_int) -> ::c_int;
892+
#[cfg_attr(target_os = "solaris", link_name = "__link_xpg4")]
894893
pub fn link(src: *const c_char, dst: *const c_char) -> ::c_int;
895894
pub fn lseek(fd: ::c_int, offset: off_t, whence: ::c_int) -> off_t;
896895
pub fn pathconf(path: *const c_char, name: ::c_int) -> c_long;
@@ -929,7 +928,10 @@ extern "C" {
929928
all(target_os = "macos", target_arch = "x86"),
930929
link_name = "ttyname_r$UNIX2003"
931930
)]
932-
#[cfg_attr(target_os = "illumos", link_name = "__posix_ttyname_r")]
931+
#[cfg_attr(
932+
any(target_os = "illumos", target_os = "solaris"),
933+
link_name = "__posix_ttyname_r"
934+
)]
933935
pub fn ttyname_r(fd: ::c_int, buf: *mut c_char, buflen: ::size_t) -> ::c_int;
934936
pub fn unlink(c: *const c_char) -> ::c_int;
935937
#[cfg_attr(
@@ -1049,8 +1051,6 @@ extern "C" {
10491051
)]
10501052
pub fn realpath(pathname: *const ::c_char, resolved: *mut ::c_char) -> *mut ::c_char;
10511053

1052-
pub fn flock(fd: ::c_int, operation: ::c_int) -> ::c_int;
1053-
10541054
#[cfg_attr(target_os = "netbsd", link_name = "__times13")]
10551055
pub fn times(buf: *mut ::tms) -> ::clock_t;
10561056

@@ -1350,6 +1350,7 @@ extern "C" {
13501350
#[cfg_attr(target_os = "netbsd", link_name = "__sigpending14")]
13511351
pub fn sigpending(set: *mut sigset_t) -> ::c_int;
13521352

1353+
#[cfg_attr(target_os = "solaris", link_name = "__sysconf_xpg7")]
13531354
pub fn sysconf(name: ::c_int) -> ::c_long;
13541355

13551356
pub fn mkfifo(path: *const c_char, mode: mode_t) -> ::c_int;
@@ -1420,12 +1421,20 @@ cfg_if! {
14201421
if #[cfg(not(any(target_os = "emscripten",
14211422
target_os = "android",
14221423
target_os = "haiku",
1423-
target_os = "nto")))] {
1424+
target_os = "nto",
1425+
target_os = "solaris")))] {
14241426
extern "C" {
14251427
pub fn adjtime(delta: *const timeval, olddelta: *mut timeval) -> ::c_int;
14261428
}
14271429
}
14281430
}
1431+
cfg_if! {
1432+
if #[cfg(target_os = "solaris")] {
1433+
extern "C" {
1434+
pub fn adjtime(delta: *mut timeval, olddelta: *mut timeval) -> ::c_int;
1435+
}
1436+
}
1437+
}
14291438

14301439
cfg_if! {
14311440
if #[cfg(not(any(target_os = "emscripten",
@@ -1445,6 +1454,14 @@ cfg_if! {
14451454
}
14461455
}
14471456

1457+
cfg_if! {
1458+
if #[cfg(not(target_os = "solaris"))] {
1459+
extern "C" {
1460+
pub fn flock(fd: ::c_int, operation: ::c_int) -> ::c_int;
1461+
}
1462+
}
1463+
}
1464+
14481465
cfg_if! {
14491466
if #[cfg(not(any(target_env = "uclibc", target_os = "nto")))] {
14501467
extern "C" {

src/unix/solarish/illumos.rs

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
use exit_status;
2+
use NET_MAC_AWARE;
3+
use NET_MAC_AWARE_INHERIT;
4+
use PRIV_AWARE_RESET;
5+
use PRIV_DEBUG;
6+
use PRIV_PFEXEC;
7+
use PRIV_XPOLICY;
8+
9+
pub type lgrp_rsrc_t = ::c_int;
10+
pub type lgrp_affinity_t = ::c_int;
11+
112
s! {
213
pub struct shmid_ds {
314
pub shm_perm: ::ipc_perm,
@@ -21,6 +32,37 @@ s! {
2132
}
2233
}
2334

35+
s_no_extra_traits! {
36+
#[cfg_attr(any(
37+
target_arch = "x86", target_arch = "x86_64"),
38+
repr(packed(4))
39+
)]
40+
pub struct epoll_event {
41+
pub events: u32,
42+
pub u64: u64,
43+
}
44+
45+
pub struct utmpx {
46+
pub ut_user: [::c_char; _UTX_USERSIZE],
47+
pub ut_id: [::c_char; _UTX_IDSIZE],
48+
pub ut_line: [::c_char; _UTX_LINESIZE],
49+
pub ut_pid: ::pid_t,
50+
pub ut_type: ::c_short,
51+
pub ut_exit: exit_status,
52+
pub ut_tv: ::timeval,
53+
pub ut_session: ::c_int,
54+
pub ut_pad: [::c_int; _UTX_PADSIZE],
55+
pub ut_syslen: ::c_short,
56+
pub ut_host: [::c_char; _UTX_HOSTSIZE],
57+
}
58+
}
59+
60+
pub const _UTX_USERSIZE: usize = 32;
61+
pub const _UTX_LINESIZE: usize = 32;
62+
pub const _UTX_PADSIZE: usize = 5;
63+
pub const _UTX_IDSIZE: usize = 4;
64+
pub const _UTX_HOSTSIZE: usize = 257;
65+
2466
pub const AF_LOCAL: ::c_int = 1; // AF_UNIX
2567
pub const AF_FILE: ::c_int = 1; // AF_UNIX
2668

@@ -56,6 +98,69 @@ pub const SOL_FILTER: ::c_int = 0xfffc;
5698

5799
pub const MADV_PURGE: ::c_int = 9;
58100

101+
pub const SIGINFO: ::c_int = 41;
102+
103+
pub const O_DIRECT: ::c_int = 0x2000000;
104+
105+
pub const PBIND_HARD: ::processorid_t = -3;
106+
pub const PBIND_SOFT: ::processorid_t = -4;
107+
108+
pub const PS_SYSTEM: ::c_int = 1;
109+
110+
pub const MAP_FILE: ::c_int = 0;
111+
112+
pub const MAP_32BIT: ::c_int = 0x80;
113+
114+
pub const AF_NCA: ::c_int = 28;
115+
116+
pub const PF_NCA: ::c_int = AF_NCA;
117+
118+
pub const LOCK_SH: ::c_int = 1;
119+
pub const LOCK_EX: ::c_int = 2;
120+
pub const LOCK_NB: ::c_int = 4;
121+
pub const LOCK_UN: ::c_int = 8;
122+
123+
pub const _PC_LAST: ::c_int = 101;
124+
125+
pub const VSTATUS: usize = 16;
126+
pub const VERASE2: usize = 17;
127+
128+
pub const EPOLLIN: ::c_int = 0x1;
129+
pub const EPOLLPRI: ::c_int = 0x2;
130+
pub const EPOLLOUT: ::c_int = 0x4;
131+
pub const EPOLLRDNORM: ::c_int = 0x40;
132+
pub const EPOLLRDBAND: ::c_int = 0x80;
133+
pub const EPOLLWRNORM: ::c_int = 0x100;
134+
pub const EPOLLWRBAND: ::c_int = 0x200;
135+
pub const EPOLLMSG: ::c_int = 0x400;
136+
pub const EPOLLERR: ::c_int = 0x8;
137+
pub const EPOLLHUP: ::c_int = 0x10;
138+
pub const EPOLLET: ::c_int = 0x80000000;
139+
pub const EPOLLRDHUP: ::c_int = 0x2000;
140+
pub const EPOLLONESHOT: ::c_int = 0x40000000;
141+
pub const EPOLLWAKEUP: ::c_int = 0x20000000;
142+
pub const EPOLLEXCLUSIVE: ::c_int = 0x10000000;
143+
pub const EPOLL_CLOEXEC: ::c_int = 0x80000;
144+
pub const EPOLL_CTL_ADD: ::c_int = 1;
145+
pub const EPOLL_CTL_MOD: ::c_int = 3;
146+
pub const EPOLL_CTL_DEL: ::c_int = 2;
147+
148+
pub const PRIV_USER: ::c_uint = PRIV_DEBUG
149+
| NET_MAC_AWARE
150+
| NET_MAC_AWARE_INHERIT
151+
| PRIV_XPOLICY
152+
| PRIV_AWARE_RESET
153+
| PRIV_PFEXEC;
154+
155+
pub const LGRP_RSRC_COUNT: ::lgrp_rsrc_t = 2;
156+
pub const LGRP_RSRC_CPU: ::lgrp_rsrc_t = 0;
157+
pub const LGRP_RSRC_MEM: ::lgrp_rsrc_t = 1;
158+
159+
pub const P_DISABLED: ::c_int = 0x008;
160+
161+
pub const AT_SUN_HWCAP2: ::c_uint = 2023;
162+
pub const AT_SUN_FPTYPE: ::c_uint = 2027;
163+
59164
pub const B1000000: ::speed_t = 24;
60165
pub const B1152000: ::speed_t = 25;
61166
pub const B1500000: ::speed_t = 26;
@@ -71,6 +176,24 @@ pub const SI_ADDRESS_WIDTH: ::c_int = 520;
71176
extern "C" {
72177
pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int;
73178

179+
pub fn epoll_pwait(
180+
epfd: ::c_int,
181+
events: *mut ::epoll_event,
182+
maxevents: ::c_int,
183+
timeout: ::c_int,
184+
sigmask: *const ::sigset_t,
185+
) -> ::c_int;
186+
pub fn epoll_create(size: ::c_int) -> ::c_int;
187+
pub fn epoll_create1(flags: ::c_int) -> ::c_int;
188+
pub fn epoll_wait(
189+
epfd: ::c_int,
190+
events: *mut ::epoll_event,
191+
maxevents: ::c_int,
192+
timeout: ::c_int,
193+
) -> ::c_int;
194+
pub fn epoll_ctl(epfd: ::c_int, op: ::c_int, fd: ::c_int, event: *mut ::epoll_event)
195+
-> ::c_int;
196+
74197
pub fn mincore(addr: ::caddr_t, len: ::size_t, vec: *mut ::c_char) -> ::c_int;
75198

76199
pub fn pset_bind_lwp(
@@ -100,4 +223,12 @@ extern "C" {
100223
pub fn pwritev(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int, offset: ::off_t)
101224
-> ::ssize_t;
102225
pub fn getpagesizes2(pagesize: *mut ::size_t, nelem: ::c_int) -> ::c_int;
226+
227+
pub fn strcasecmp_l(s1: *const ::c_char, s2: *const ::c_char, loc: ::locale_t) -> ::c_int;
228+
pub fn strncasecmp_l(
229+
s1: *const ::c_char,
230+
s2: *const ::c_char,
231+
n: ::size_t,
232+
loc: ::locale_t,
233+
) -> ::c_int;
103234
}

0 commit comments

Comments
 (0)