Skip to content

Commit 3da4674

Browse files
committed
Fixes tests on Solaris
1 parent cdf6896 commit 3da4674

File tree

9 files changed

+489
-277
lines changed

9 files changed

+489
-277
lines changed

libc-test/build.rs

+15-4
Original file line numberDiff line numberDiff line change
@@ -822,8 +822,6 @@ fn test_solarish(target: &str) {
822822
"stdlib.h",
823823
"string.h",
824824
"sys/auxv.h",
825-
"sys/epoll.h",
826-
"sys/eventfd.h",
827825
"sys/file.h",
828826
"sys/filio.h",
829827
"sys/ioctl.h",
@@ -863,6 +861,19 @@ fn test_solarish(target: &str) {
863861
"wchar.h",
864862
}
865863

864+
if is_illumos {
865+
headers! { cfg:
866+
"sys/epoll.h",
867+
"sys/eventfd.h",
868+
}
869+
}
870+
871+
if is_solaris {
872+
headers! { cfg:
873+
"sys/lgrp_user_impl.h",
874+
}
875+
}
876+
866877
cfg.skip_type(move |ty| match ty {
867878
"sighandler_t" => true,
868879
_ => false,
@@ -912,7 +923,7 @@ fn test_solarish(target: &str) {
912923
// EPOLLEXCLUSIVE is a relatively recent addition to the epoll interface and may not be
913924
// defined on older systems. It is, however, safe to use on systems which do not
914925
// explicitly support it. (A no-op is an acceptable implementation of EPOLLEXCLUSIVE.)
915-
"EPOLLEXCLUSIVE" => true,
926+
"EPOLLEXCLUSIVE" if is_illumos => true,
916927

917928
_ => false,
918929
});
@@ -1004,7 +1015,7 @@ fn test_solarish(target: &str) {
10041015
// These functions may return int or void depending on the exact
10051016
// configuration of the compilation environment, but the return
10061017
// value is not useful (always 0) so we can ignore it:
1007-
"setservent" | "endservent" if is_illumos => true,
1018+
"setservent" | "endservent" => true,
10081019

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

libc-test/semver/TODO-unix.txt

+5
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

-4
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

+22-8
Original file line numberDiff line numberDiff line change
@@ -603,10 +603,8 @@ extern "C" {
603603

604604
#[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
605605
#[cfg_attr(target_os = "netbsd", link_name = "__socket30")]
606-
#[cfg_attr(
607-
any(target_os = "illumos", target_os = "solaris"),
608-
link_name = "__xnet_socket"
609-
)]
606+
#[cfg_attr(target_os = "illumos", link_name = "__xnet_socket")]
607+
#[cfg_attr(target_os = "solaris", link_name = "__xnet7_socket")]
610608
#[cfg_attr(target_os = "espidf", link_name = "lwip_socket")]
611609
pub fn socket(domain: ::c_int, ty: ::c_int, protocol: ::c_int) -> ::c_int;
612610
#[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
@@ -892,6 +890,7 @@ extern "C" {
892890
pub fn getppid() -> pid_t;
893891
pub fn getuid() -> uid_t;
894892
pub fn isatty(fd: ::c_int) -> ::c_int;
893+
#[cfg_attr(target_os = "solaris", link_name = "__link_xpg4")]
895894
pub fn link(src: *const c_char, dst: *const c_char) -> ::c_int;
896895
pub fn lseek(fd: ::c_int, offset: off_t, whence: ::c_int) -> off_t;
897896
pub fn pathconf(path: *const c_char, name: ::c_int) -> c_long;
@@ -930,7 +929,10 @@ extern "C" {
930929
all(target_os = "macos", target_arch = "x86"),
931930
link_name = "ttyname_r$UNIX2003"
932931
)]
933-
#[cfg_attr(target_os = "illumos", link_name = "__posix_ttyname_r")]
932+
#[cfg_attr(
933+
any(target_os = "illumos", target_os = "solaris"),
934+
link_name = "__posix_ttyname_r"
935+
)]
934936
pub fn ttyname_r(fd: ::c_int, buf: *mut c_char, buflen: ::size_t) -> ::c_int;
935937
pub fn unlink(c: *const c_char) -> ::c_int;
936938
#[cfg_attr(
@@ -1051,8 +1053,6 @@ extern "C" {
10511053
)]
10521054
pub fn realpath(pathname: *const ::c_char, resolved: *mut ::c_char) -> *mut ::c_char;
10531055

1054-
pub fn flock(fd: ::c_int, operation: ::c_int) -> ::c_int;
1055-
10561056
#[cfg_attr(target_os = "netbsd", link_name = "__times13")]
10571057
pub fn times(buf: *mut ::tms) -> ::clock_t;
10581058

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

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

13581359
pub fn mkfifo(path: *const c_char, mode: mode_t) -> ::c_int;
@@ -1423,10 +1424,15 @@ cfg_if! {
14231424
if #[cfg(not(any(target_os = "emscripten",
14241425
target_os = "android",
14251426
target_os = "haiku",
1426-
target_os = "nto")))] {
1427+
target_os = "nto",
1428+
target_os = "solaris")))] {
14271429
extern "C" {
14281430
pub fn adjtime(delta: *const timeval, olddelta: *mut timeval) -> ::c_int;
14291431
}
1432+
} else if #[cfg(target_os = "solaris")] {
1433+
extern "C" {
1434+
pub fn adjtime(delta: *mut timeval, olddelta: *mut timeval) -> ::c_int;
1435+
}
14301436
}
14311437
}
14321438

@@ -1448,6 +1454,14 @@ cfg_if! {
14481454
}
14491455
}
14501456

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+
14511465
cfg_if! {
14521466
if #[cfg(not(any(target_env = "uclibc", target_os = "nto")))] {
14531467
extern "C" {

src/unix/solarish/illumos.rs

+217
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,123 @@ 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+
cfg_if! {
61+
if #[cfg(feature = "extra_traits")] {
62+
impl PartialEq for utmpx {
63+
fn eq(&self, other: &utmpx) -> bool {
64+
self.ut_type == other.ut_type
65+
&& self.ut_pid == other.ut_pid
66+
&& self.ut_user == other.ut_user
67+
&& self.ut_line == other.ut_line
68+
&& self.ut_id == other.ut_id
69+
&& self.ut_exit == other.ut_exit
70+
&& self.ut_session == other.ut_session
71+
&& self.ut_tv == other.ut_tv
72+
&& self.ut_syslen == other.ut_syslen
73+
&& self.ut_pad == other.ut_pad
74+
&& self
75+
.ut_host
76+
.iter()
77+
.zip(other.ut_host.iter())
78+
.all(|(a,b)| a == b)
79+
}
80+
}
81+
82+
impl Eq for utmpx {}
83+
84+
impl ::fmt::Debug for utmpx {
85+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
86+
f.debug_struct("utmpx")
87+
.field("ut_user", &self.ut_user)
88+
.field("ut_id", &self.ut_id)
89+
.field("ut_line", &self.ut_line)
90+
.field("ut_pid", &self.ut_pid)
91+
.field("ut_type", &self.ut_type)
92+
.field("ut_exit", &self.ut_exit)
93+
.field("ut_tv", &self.ut_tv)
94+
.field("ut_session", &self.ut_session)
95+
.field("ut_pad", &self.ut_pad)
96+
.field("ut_syslen", &self.ut_syslen)
97+
.field("ut_host", &&self.ut_host[..])
98+
.finish()
99+
}
100+
}
101+
102+
impl ::hash::Hash for utmpx {
103+
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
104+
self.ut_user.hash(state);
105+
self.ut_type.hash(state);
106+
self.ut_pid.hash(state);
107+
self.ut_line.hash(state);
108+
self.ut_id.hash(state);
109+
self.ut_host.hash(state);
110+
self.ut_exit.hash(state);
111+
self.ut_session.hash(state);
112+
self.ut_tv.hash(state);
113+
self.ut_syslen.hash(state);
114+
self.ut_pad.hash(state);
115+
}
116+
}
117+
118+
impl PartialEq for epoll_event {
119+
fn eq(&self, other: &epoll_event) -> bool {
120+
self.events == other.events
121+
&& self.u64 == other.u64
122+
}
123+
}
124+
impl Eq for epoll_event {}
125+
impl ::fmt::Debug for epoll_event {
126+
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
127+
let events = self.events;
128+
let u64 = self.u64;
129+
f.debug_struct("epoll_event")
130+
.field("events", &events)
131+
.field("u64", &u64)
132+
.finish()
133+
}
134+
}
135+
impl ::hash::Hash for epoll_event {
136+
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
137+
let events = self.events;
138+
let u64 = self.u64;
139+
events.hash(state);
140+
u64.hash(state);
141+
}
142+
}
143+
}
144+
}
145+
146+
pub const _UTX_USERSIZE: usize = 32;
147+
pub const _UTX_LINESIZE: usize = 32;
148+
pub const _UTX_PADSIZE: usize = 5;
149+
pub const _UTX_IDSIZE: usize = 4;
150+
pub const _UTX_HOSTSIZE: usize = 257;
151+
24152
pub const AF_LOCAL: ::c_int = 1; // AF_UNIX
25153
pub const AF_FILE: ::c_int = 1; // AF_UNIX
26154

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

57185
pub const MADV_PURGE: ::c_int = 9;
58186

187+
pub const SIGINFO: ::c_int = 41;
188+
189+
pub const O_DIRECT: ::c_int = 0x2000000;
190+
191+
pub const PBIND_HARD: ::processorid_t = -3;
192+
pub const PBIND_SOFT: ::processorid_t = -4;
193+
194+
pub const PS_SYSTEM: ::c_int = 1;
195+
196+
pub const MAP_FILE: ::c_int = 0;
197+
198+
pub const MAP_32BIT: ::c_int = 0x80;
199+
200+
pub const AF_NCA: ::c_int = 28;
201+
202+
pub const PF_NCA: ::c_int = AF_NCA;
203+
204+
pub const LOCK_SH: ::c_int = 1;
205+
pub const LOCK_EX: ::c_int = 2;
206+
pub const LOCK_NB: ::c_int = 4;
207+
pub const LOCK_UN: ::c_int = 8;
208+
209+
pub const _PC_LAST: ::c_int = 101;
210+
211+
pub const VSTATUS: usize = 16;
212+
pub const VERASE2: usize = 17;
213+
214+
pub const EPOLLIN: ::c_int = 0x1;
215+
pub const EPOLLPRI: ::c_int = 0x2;
216+
pub const EPOLLOUT: ::c_int = 0x4;
217+
pub const EPOLLRDNORM: ::c_int = 0x40;
218+
pub const EPOLLRDBAND: ::c_int = 0x80;
219+
pub const EPOLLWRNORM: ::c_int = 0x100;
220+
pub const EPOLLWRBAND: ::c_int = 0x200;
221+
pub const EPOLLMSG: ::c_int = 0x400;
222+
pub const EPOLLERR: ::c_int = 0x8;
223+
pub const EPOLLHUP: ::c_int = 0x10;
224+
pub const EPOLLET: ::c_int = 0x80000000;
225+
pub const EPOLLRDHUP: ::c_int = 0x2000;
226+
pub const EPOLLONESHOT: ::c_int = 0x40000000;
227+
pub const EPOLLWAKEUP: ::c_int = 0x20000000;
228+
pub const EPOLLEXCLUSIVE: ::c_int = 0x10000000;
229+
pub const EPOLL_CLOEXEC: ::c_int = 0x80000;
230+
pub const EPOLL_CTL_ADD: ::c_int = 1;
231+
pub const EPOLL_CTL_MOD: ::c_int = 3;
232+
pub const EPOLL_CTL_DEL: ::c_int = 2;
233+
234+
pub const PRIV_USER: ::c_uint = PRIV_DEBUG
235+
| NET_MAC_AWARE
236+
| NET_MAC_AWARE_INHERIT
237+
| PRIV_XPOLICY
238+
| PRIV_AWARE_RESET
239+
| PRIV_PFEXEC;
240+
241+
pub const LGRP_RSRC_COUNT: ::lgrp_rsrc_t = 2;
242+
pub const LGRP_RSRC_CPU: ::lgrp_rsrc_t = 0;
243+
pub const LGRP_RSRC_MEM: ::lgrp_rsrc_t = 1;
244+
245+
pub const P_DISABLED: ::c_int = 0x008;
246+
247+
pub const AT_SUN_HWCAP2: ::c_uint = 2023;
248+
pub const AT_SUN_FPTYPE: ::c_uint = 2027;
249+
59250
pub const B1000000: ::speed_t = 24;
60251
pub const B1152000: ::speed_t = 25;
61252
pub const B1500000: ::speed_t = 26;
@@ -71,6 +262,24 @@ pub const SI_ADDRESS_WIDTH: ::c_int = 520;
71262
extern "C" {
72263
pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int;
73264

265+
pub fn epoll_pwait(
266+
epfd: ::c_int,
267+
events: *mut ::epoll_event,
268+
maxevents: ::c_int,
269+
timeout: ::c_int,
270+
sigmask: *const ::sigset_t,
271+
) -> ::c_int;
272+
pub fn epoll_create(size: ::c_int) -> ::c_int;
273+
pub fn epoll_create1(flags: ::c_int) -> ::c_int;
274+
pub fn epoll_wait(
275+
epfd: ::c_int,
276+
events: *mut ::epoll_event,
277+
maxevents: ::c_int,
278+
timeout: ::c_int,
279+
) -> ::c_int;
280+
pub fn epoll_ctl(epfd: ::c_int, op: ::c_int, fd: ::c_int, event: *mut ::epoll_event)
281+
-> ::c_int;
282+
74283
pub fn mincore(addr: ::caddr_t, len: ::size_t, vec: *mut ::c_char) -> ::c_int;
75284

76285
pub fn pset_bind_lwp(
@@ -100,4 +309,12 @@ extern "C" {
100309
pub fn pwritev(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int, offset: ::off_t)
101310
-> ::ssize_t;
102311
pub fn getpagesizes2(pagesize: *mut ::size_t, nelem: ::c_int) -> ::c_int;
312+
313+
pub fn strcasecmp_l(s1: *const ::c_char, s2: *const ::c_char, loc: ::locale_t) -> ::c_int;
314+
pub fn strncasecmp_l(
315+
s1: *const ::c_char,
316+
s2: *const ::c_char,
317+
n: ::size_t,
318+
loc: ::locale_t,
319+
) -> ::c_int;
103320
}

0 commit comments

Comments
 (0)