Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[0.2] Backports #4017

Merged
merged 3 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -886,8 +886,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 @@ -927,6 +925,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 @@ -976,7 +987,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 @@ -1068,7 +1079,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
8 changes: 8 additions & 0 deletions libc-test/semver/illumos.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
FD_CLOFORK
F_DUP2FD_CLOEXEC
F_DUP2FD_CLOFORK
F_DUP3FD
F_DUPFD_CLOFORK
MSG_CMSG_CLOEXEC
MSG_CMSG_CLOFORK
O_CLOFORK
O_RSYNC
POLLRDHUP
POSIX_FADV_DONTNEED
Expand Down
4 changes: 0 additions & 4 deletions libc-test/semver/unix.txt
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,6 @@ ISTRIP
IXANY
IXOFF
IXON
LOCK_EX
LOCK_NB
LOCK_SH
LOCK_UN
LOG_ALERT
LOG_AUTH
LOG_CONS
Expand Down
42 changes: 33 additions & 9 deletions src/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,19 @@ pub const ATF_PUBL: ::c_int = 0x08;
pub const ATF_USETRAILERS: ::c_int = 0x10;

pub const FNM_PERIOD: c_int = 1 << 2;
pub const FNM_CASEFOLD: c_int = 1 << 4;
pub const FNM_NOMATCH: c_int = 1;

cfg_if! {
if #[cfg(any(
target_os = "illumos",
target_os = "solaris",
))] {
pub const FNM_CASEFOLD: c_int = 1 << 3;
} else {
pub const FNM_CASEFOLD: c_int = 1 << 4;
}
}

cfg_if! {
if #[cfg(any(
target_os = "macos",
Expand Down Expand Up @@ -622,10 +632,8 @@ extern "C" {
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(
Expand Down Expand Up @@ -931,6 +939,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 @@ -968,7 +977,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 @@ -1089,8 +1101,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 @@ -1399,6 +1409,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 @@ -1452,10 +1463,15 @@ 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;
}
} else if #[cfg(target_os = "solaris")] {
extern "C" {
pub fn adjtime(delta: *mut timeval, olddelta: *mut timeval) -> ::c_int;
}
}
}

Expand All @@ -1477,6 +1493,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