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 Sep 2, 2024
1 parent cdf6896 commit 0283661
Show file tree
Hide file tree
Showing 9 changed files with 437 additions and 223 deletions.
19 changes: 15 additions & 4 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -822,8 +822,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 @@ -863,6 +861,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 @@ -912,7 +923,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 @@ -1004,7 +1015,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 @@ -603,10 +603,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 @@ -892,6 +890,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 @@ -930,7 +929,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 @@ -1051,8 +1053,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 @@ -1353,6 +1353,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 @@ -1423,12 +1424,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 @@ -1448,6 +1457,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
Loading

0 comments on commit 0283661

Please sign in to comment.