Skip to content

Commit

Permalink
Fixes tests on Solaris
Browse files Browse the repository at this point in the history
  • Loading branch information
psumbera committed Aug 22, 2024
1 parent 72cb7aa commit 2cd820e
Show file tree
Hide file tree
Showing 9 changed files with 291 additions and 141 deletions.
19 changes: 15 additions & 4 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -795,8 +795,6 @@ fn test_solarish(target: &str) {
"stdlib.h",
"string.h",
"sys/auxv.h",
"sys/epoll.h",
"sys/eventfd.h",
"sys/file.h",
"sys/filio.h",
"sys/ioctl.h",
Expand Down Expand Up @@ -836,6 +834,19 @@ fn test_solarish(target: &str) {
"wchar.h",
}

if is_illumos {
headers! { cfg:
"sys/epoll.h",
"sys/eventfd.h",
}
}

if is_solaris {
headers! { cfg:
"sys/lgrp_user_impl.h",
}
}

cfg.skip_type(move |ty| match ty {
"sighandler_t" => true,
_ => false,
Expand Down Expand Up @@ -885,7 +896,7 @@ fn test_solarish(target: &str) {
// EPOLLEXCLUSIVE is a relatively recent addition to the epoll interface and may not be
// defined on older systems. It is, however, safe to use on systems which do not
// explicitly support it. (A no-op is an acceptable implementation of EPOLLEXCLUSIVE.)
"EPOLLEXCLUSIVE" => true,
"EPOLLEXCLUSIVE" if is_illumos => true,

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

// Following illumos#3729, getifaddrs was changed to a
// redefine_extname symbol in order to preserve compatibility.
Expand Down
5 changes: 5 additions & 0 deletions libc-test/semver/TODO-unix.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@
getpwuid_r
pthread_atfork
pthread_sigmask
# * Solaris is missing flock(2)
LOCK_EX
LOCK_NB
LOCK_SH
LOCK_UN
4 changes: 0 additions & 4 deletions libc-test/semver/unix.txt
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,6 @@ ISTRIP
IXANY
IXOFF
IXON
LOCK_EX
LOCK_NB
LOCK_SH
LOCK_UN
LOG_ALERT
LOG_AUTH
LOG_CONS
Expand Down
33 changes: 25 additions & 8 deletions src/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -602,10 +602,8 @@ extern "C" {

#[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
#[cfg_attr(target_os = "netbsd", link_name = "__socket30")]
#[cfg_attr(
any(target_os = "illumos", target_os = "solaris"),
link_name = "__xnet_socket"
)]
#[cfg_attr(target_os = "illumos", link_name = "__xnet_socket")]
#[cfg_attr(target_os = "solaris", link_name = "__xnet7_socket")]
#[cfg_attr(target_os = "espidf", link_name = "lwip_socket")]
pub fn socket(domain: ::c_int, ty: ::c_int, protocol: ::c_int) -> ::c_int;
#[cfg(not(all(target_arch = "powerpc", target_vendor = "nintendo")))]
Expand Down Expand Up @@ -891,6 +889,7 @@ extern "C" {
pub fn getppid() -> pid_t;
pub fn getuid() -> uid_t;
pub fn isatty(fd: ::c_int) -> ::c_int;
#[cfg_attr(target_os = "solaris", link_name = "__link_xpg4")]
pub fn link(src: *const c_char, dst: *const c_char) -> ::c_int;
pub fn lseek(fd: ::c_int, offset: off_t, whence: ::c_int) -> off_t;
pub fn pathconf(path: *const c_char, name: ::c_int) -> c_long;
Expand Down Expand Up @@ -929,7 +928,10 @@ extern "C" {
all(target_os = "macos", target_arch = "x86"),
link_name = "ttyname_r$UNIX2003"
)]
#[cfg_attr(target_os = "illumos", link_name = "__posix_ttyname_r")]
#[cfg_attr(
any(target_os = "illumos", target_os = "solaris"),
link_name = "__posix_ttyname_r"
)]
pub fn ttyname_r(fd: ::c_int, buf: *mut c_char, buflen: ::size_t) -> ::c_int;
pub fn unlink(c: *const c_char) -> ::c_int;
#[cfg_attr(
Expand Down Expand Up @@ -1049,8 +1051,6 @@ extern "C" {
)]
pub fn realpath(pathname: *const ::c_char, resolved: *mut ::c_char) -> *mut ::c_char;

pub fn flock(fd: ::c_int, operation: ::c_int) -> ::c_int;

#[cfg_attr(target_os = "netbsd", link_name = "__times13")]
pub fn times(buf: *mut ::tms) -> ::clock_t;

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

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

pub fn mkfifo(path: *const c_char, mode: mode_t) -> ::c_int;
Expand Down Expand Up @@ -1420,12 +1421,20 @@ cfg_if! {
if #[cfg(not(any(target_os = "emscripten",
target_os = "android",
target_os = "haiku",
target_os = "nto")))] {
target_os = "nto",
target_os = "solaris")))] {
extern "C" {
pub fn adjtime(delta: *const timeval, olddelta: *mut timeval) -> ::c_int;
}
}
}
cfg_if! {
if #[cfg(target_os = "solaris")] {
extern "C" {
pub fn adjtime(delta: *mut timeval, olddelta: *mut timeval) -> ::c_int;
}
}
}

cfg_if! {
if #[cfg(not(any(target_os = "emscripten",
Expand All @@ -1445,6 +1454,14 @@ cfg_if! {
}
}

cfg_if! {
if #[cfg(not(target_os = "solaris"))] {
extern "C" {
pub fn flock(fd: ::c_int, operation: ::c_int) -> ::c_int;
}
}
}

cfg_if! {
if #[cfg(not(any(target_env = "uclibc", target_os = "nto")))] {
extern "C" {
Expand Down
131 changes: 131 additions & 0 deletions src/unix/solarish/illumos.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
use exit_status;
use NET_MAC_AWARE;
use NET_MAC_AWARE_INHERIT;
use PRIV_AWARE_RESET;
use PRIV_DEBUG;
use PRIV_PFEXEC;
use PRIV_XPOLICY;

pub type lgrp_rsrc_t = ::c_int;
pub type lgrp_affinity_t = ::c_int;

s! {
pub struct shmid_ds {
pub shm_perm: ::ipc_perm,
Expand All @@ -21,6 +32,37 @@ s! {
}
}

s_no_extra_traits! {
#[cfg_attr(any(
target_arch = "x86", target_arch = "x86_64"),
repr(packed(4))
)]
pub struct epoll_event {
pub events: u32,
pub u64: u64,
}

pub struct utmpx {
pub ut_user: [::c_char; _UTX_USERSIZE],
pub ut_id: [::c_char; _UTX_IDSIZE],
pub ut_line: [::c_char; _UTX_LINESIZE],
pub ut_pid: ::pid_t,
pub ut_type: ::c_short,
pub ut_exit: exit_status,
pub ut_tv: ::timeval,
pub ut_session: ::c_int,
pub ut_pad: [::c_int; _UTX_PADSIZE],
pub ut_syslen: ::c_short,
pub ut_host: [::c_char; _UTX_HOSTSIZE],
}
}

pub const _UTX_USERSIZE: usize = 32;
pub const _UTX_LINESIZE: usize = 32;
pub const _UTX_PADSIZE: usize = 5;
pub const _UTX_IDSIZE: usize = 4;
pub const _UTX_HOSTSIZE: usize = 257;

pub const AF_LOCAL: ::c_int = 1; // AF_UNIX
pub const AF_FILE: ::c_int = 1; // AF_UNIX

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

pub const MADV_PURGE: ::c_int = 9;

pub const SIGINFO: ::c_int = 41;

pub const O_DIRECT: ::c_int = 0x2000000;

pub const PBIND_HARD: ::processorid_t = -3;
pub const PBIND_SOFT: ::processorid_t = -4;

pub const PS_SYSTEM: ::c_int = 1;

pub const MAP_FILE: ::c_int = 0;

pub const MAP_32BIT: ::c_int = 0x80;

pub const AF_NCA: ::c_int = 28;

pub const PF_NCA: ::c_int = AF_NCA;

pub const LOCK_SH: ::c_int = 1;
pub const LOCK_EX: ::c_int = 2;
pub const LOCK_NB: ::c_int = 4;
pub const LOCK_UN: ::c_int = 8;

pub const _PC_LAST: ::c_int = 101;

pub const VSTATUS: usize = 16;
pub const VERASE2: usize = 17;

pub const EPOLLIN: ::c_int = 0x1;
pub const EPOLLPRI: ::c_int = 0x2;
pub const EPOLLOUT: ::c_int = 0x4;
pub const EPOLLRDNORM: ::c_int = 0x40;
pub const EPOLLRDBAND: ::c_int = 0x80;
pub const EPOLLWRNORM: ::c_int = 0x100;
pub const EPOLLWRBAND: ::c_int = 0x200;
pub const EPOLLMSG: ::c_int = 0x400;
pub const EPOLLERR: ::c_int = 0x8;
pub const EPOLLHUP: ::c_int = 0x10;
pub const EPOLLET: ::c_int = 0x80000000;
pub const EPOLLRDHUP: ::c_int = 0x2000;
pub const EPOLLONESHOT: ::c_int = 0x40000000;
pub const EPOLLWAKEUP: ::c_int = 0x20000000;
pub const EPOLLEXCLUSIVE: ::c_int = 0x10000000;
pub const EPOLL_CLOEXEC: ::c_int = 0x80000;
pub const EPOLL_CTL_ADD: ::c_int = 1;
pub const EPOLL_CTL_MOD: ::c_int = 3;
pub const EPOLL_CTL_DEL: ::c_int = 2;

pub const PRIV_USER: ::c_uint = PRIV_DEBUG
| NET_MAC_AWARE
| NET_MAC_AWARE_INHERIT
| PRIV_XPOLICY
| PRIV_AWARE_RESET
| PRIV_PFEXEC;

pub const LGRP_RSRC_COUNT: ::lgrp_rsrc_t = 2;
pub const LGRP_RSRC_CPU: ::lgrp_rsrc_t = 0;
pub const LGRP_RSRC_MEM: ::lgrp_rsrc_t = 1;

pub const P_DISABLED: ::c_int = 0x008;

pub const AT_SUN_HWCAP2: ::c_uint = 2023;
pub const AT_SUN_FPTYPE: ::c_uint = 2027;

pub const B1000000: ::speed_t = 24;
pub const B1152000: ::speed_t = 25;
pub const B1500000: ::speed_t = 26;
Expand All @@ -71,6 +176,24 @@ pub const SI_ADDRESS_WIDTH: ::c_int = 520;
extern "C" {
pub fn eventfd(init: ::c_uint, flags: ::c_int) -> ::c_int;

pub fn epoll_pwait(
epfd: ::c_int,
events: *mut ::epoll_event,
maxevents: ::c_int,
timeout: ::c_int,
sigmask: *const ::sigset_t,
) -> ::c_int;
pub fn epoll_create(size: ::c_int) -> ::c_int;
pub fn epoll_create1(flags: ::c_int) -> ::c_int;
pub fn epoll_wait(
epfd: ::c_int,
events: *mut ::epoll_event,
maxevents: ::c_int,
timeout: ::c_int,
) -> ::c_int;
pub fn epoll_ctl(epfd: ::c_int, op: ::c_int, fd: ::c_int, event: *mut ::epoll_event)
-> ::c_int;

pub fn mincore(addr: ::caddr_t, len: ::size_t, vec: *mut ::c_char) -> ::c_int;

pub fn pset_bind_lwp(
Expand Down Expand Up @@ -100,4 +223,12 @@ extern "C" {
pub fn pwritev(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int, offset: ::off_t)
-> ::ssize_t;
pub fn getpagesizes2(pagesize: *mut ::size_t, nelem: ::c_int) -> ::c_int;

pub fn strcasecmp_l(s1: *const ::c_char, s2: *const ::c_char, loc: ::locale_t) -> ::c_int;
pub fn strncasecmp_l(
s1: *const ::c_char,
s2: *const ::c_char,
n: ::size_t,
loc: ::locale_t,
) -> ::c_int;
}
Loading

0 comments on commit 2cd820e

Please sign in to comment.