Skip to content

Commit

Permalink
Merge pull request #3968 from tgross35/backport-asparagus
Browse files Browse the repository at this point in the history
[0.2] Backports
  • Loading branch information
tgross35 authored Oct 15, 2024
2 parents 1447f78 + d607b77 commit e7ef0da
Show file tree
Hide file tree
Showing 17 changed files with 908 additions and 5 deletions.
7 changes: 6 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ const ALLOWED_CFGS: &'static [&'static str] = &[

// Extra values to allow for check-cfg.
const CHECK_CFG_EXTRA: &'static [(&'static str, &'static [&'static str])] = &[
("target_os", &["switch", "aix", "ohos", "hurd", "visionos"]),
(
"target_os",
&[
"switch", "aix", "ohos", "hurd", "rtems", "visionos", "nuttx",
],
),
("target_env", &["illumos", "wasi", "aix", "ohos"]),
(
"target_arch",
Expand Down
26 changes: 26 additions & 0 deletions libc-test/semver/apple.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1116,16 +1116,29 @@ PROC_CSM_TECS
PROC_PIDTASKALLINFO
PROC_PIDTASKINFO
PROC_PIDTHREADINFO
PTHREAD_CANCEL_ASYNCHRONOUS
PTHREAD_CANCEL_DEFERRED
PTHREAD_CANCEL_DISABLE
PTHREAD_CANCEL_ENABLE
PTHREAD_CANCELED
PTHREAD_CREATE_DETACHED
PTHREAD_CREATE_JOINABLE
PTHREAD_EXPLICIT_SCHED
PTHREAD_INHERIT_SCHED
PTHREAD_INTROSPECTION_THREAD_CREATE
PTHREAD_INTROSPECTION_THREAD_DESTROY
PTHREAD_INTROSPECTION_THREAD_START
PTHREAD_INTROSPECTION_THREAD_TERMINATE
PTHREAD_MUTEX_DEFAULT
PTHREAD_MUTEX_ERRORCHECK
PTHREAD_ONCE_INIT
PTHREAD_PRIO_INHERIT
PTHREAD_PRIO_NONE
PTHREAD_PRIO_PROTECT
PTHREAD_PROCESS_PRIVATE
PTHREAD_PROCESS_SHARED
PTHREAD_SCOPE_PROCESS
PTHREAD_SCOPE_SYSTEM
PTHREAD_STACK_MIN
PT_ATTACH
PT_ATTACHEXC
Expand Down Expand Up @@ -1832,6 +1845,7 @@ _WSTOPPED
__PTHREAD_CONDATTR_SIZE__
__PTHREAD_COND_SIZE__
__PTHREAD_MUTEX_SIZE__
__PTHREAD_ONCE_SIZE__
__PTHREAD_RWLOCKATTR_SIZE__
__PTHREAD_RWLOCK_SIZE__
__darwin_mcontext64
Expand Down Expand Up @@ -2142,8 +2156,18 @@ pseudo_AF_KEY
pseudo_AF_PIP
pseudo_AF_RTIP
pseudo_AF_XTP
pthread_atfork
pthread_attr_getdetachstate
pthread_attr_getinheritsched
pthread_attr_getschedparam
pthread_attr_getschedpolicy
pthread_attr_getscope
pthread_attr_getstackaddr
pthread_attr_setinheritsched
pthread_attr_setschedparam
pthread_attr_setschedpolicy
pthread_attr_setscope
pthread_attr_setstackaddr
pthread_cancel
pthread_condattr_getpshared
pthread_condattr_setpshared
Expand All @@ -2167,6 +2191,8 @@ pthread_kill
pthread_main_np
pthread_mutexattr_getpshared
pthread_mutexattr_setpshared
pthread_once
pthread_once_t
pthread_rwlockattr_getpshared
pthread_rwlockattr_setpshared
pthread_setname_np
Expand Down
1 change: 1 addition & 0 deletions libc-test/semver/emscripten.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
AT_EACCESS
getentropy
posix_fallocate64
getpwnam_r
Expand Down
2 changes: 2 additions & 0 deletions libc-test/semver/linux-i686.txt
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ fsblkcnt64_t
fsfilcnt64_t
getcontext
greg_t
ioperm
iopl
makecontext
max_align_t
mcontext_t
Expand Down
9 changes: 9 additions & 0 deletions libc-test/semver/linux-musl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,34 @@ MPOL_DEFAULT
MPOL_INTERLEAVE
MPOL_LOCAL
MPOL_PREFERRED
BOOT_TIME
DEAD_PROCESS
Elf32_Chdr
Elf64_Chdr
EMPTY
INIT_PROCESS
LIO_NOP
LIO_NOWAIT
LIO_READ
LIO_WAIT
LIO_WRITE
LOGIN_PROCESS
NEW_TIME
OLD_TIME
PF_IB
PF_MPLS
PF_XDP
PIDFD_NONBLOCK
PR_SET_VMA
PR_SET_VMA_ANON_NAME
RUN_LVL
RWF_APPEND
RWF_DSYNC
RWF_HIPRI
RWF_NOWAIT
RWF_SYNC
SOL_XDP
USER_PROCESS
XDP_SHARED_UMEM
XDP_COPY
XDP_ZEROCOPY
Expand Down
2 changes: 2 additions & 0 deletions libc-test/semver/linux-x86_64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ TIOCGRS485
TIOCSBRK
TIOCSRS485
greg_t
ioperm
iopl
max_align_t
mcontext_t
ucontext_t
Expand Down
35 changes: 35 additions & 0 deletions src/unix/bsd/apple/b32/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ s_no_extra_traits! {
__sig: c_long,
__opaque: [::c_char; 36]
}

pub struct pthread_once_t {
__sig: c_long,
__opaque: [::c_char; ::__PTHREAD_ONCE_SIZE__],
}
}

cfg_if! {
Expand Down Expand Up @@ -82,6 +87,29 @@ cfg_if! {
self.__opaque.hash(state);
}
}
impl PartialEq for pthread_once_t {
fn eq(&self, other: &pthread_once_t) -> bool {
self.__sig == other.__sig
&& self.__opaque
.iter()
.zip(other.__opaque.iter())
.all(|(a,b)| a == b)
}
}
impl Eq for pthread_once_t {}
impl ::fmt::Debug for pthread_once_t {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("pthread_once_t")
.field("__sig", &self.__sig)
.finish()
}
}
impl ::hash::Hash for pthread_once_t {
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
self.__sig.hash(state);
self.__opaque.hash(state);
}
}
}
}

Expand All @@ -92,6 +120,7 @@ pub const NET_RT_MAXID: ::c_int = 10;
pub const __PTHREAD_MUTEX_SIZE__: usize = 40;
pub const __PTHREAD_COND_SIZE__: usize = 24;
pub const __PTHREAD_CONDATTR_SIZE__: usize = 4;
pub const __PTHREAD_ONCE_SIZE__: usize = 4;
pub const __PTHREAD_RWLOCK_SIZE__: usize = 124;
pub const __PTHREAD_RWLOCKATTR_SIZE__: usize = 12;

Expand All @@ -103,6 +132,12 @@ pub const BIOCSRTIMEOUT: ::c_ulong = 0x8008426d;
pub const BIOCGRTIMEOUT: ::c_ulong = 0x4008426e;
pub const BIOCSETFNR: ::c_ulong = 0x8008427e;

const _PTHREAD_ONCE_SIG_INIT: c_long = 0x30B1BCBA;
pub const PTHREAD_ONCE_INIT: ::pthread_once_t = ::pthread_once_t {
__sig: _PTHREAD_ONCE_SIG_INIT,
__opaque: [0; 4],
};

extern "C" {
pub fn exchangedata(
path1: *const ::c_char,
Expand Down
35 changes: 35 additions & 0 deletions src/unix/bsd/apple/b64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ s_no_extra_traits! {
__sig: c_long,
__opaque: [::c_char; 56]
}

pub struct pthread_once_t {
__sig: c_long,
__opaque: [::c_char; __PTHREAD_ONCE_SIZE__],
}
}

cfg_if! {
Expand Down Expand Up @@ -82,6 +87,29 @@ cfg_if! {
self.__opaque.hash(state);
}
}
impl PartialEq for pthread_once_t {
fn eq(&self, other: &pthread_once_t) -> bool {
self.__sig == other.__sig
&& self.__opaque
.iter()
.zip(other.__opaque.iter())
.all(|(a,b)| a == b)
}
}
impl Eq for pthread_once_t {}
impl ::fmt::Debug for pthread_once_t {
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
f.debug_struct("pthread_once_t")
.field("__sig", &self.__sig)
.finish()
}
}
impl ::hash::Hash for pthread_once_t {
fn hash<H: ::hash::Hasher>(&self, state: &mut H) {
self.__sig.hash(state);
self.__opaque.hash(state);
}
}
}
}

Expand All @@ -92,6 +120,7 @@ pub const NET_RT_MAXID: ::c_int = 11;
pub const __PTHREAD_MUTEX_SIZE__: usize = 56;
pub const __PTHREAD_COND_SIZE__: usize = 40;
pub const __PTHREAD_CONDATTR_SIZE__: usize = 8;
pub const __PTHREAD_ONCE_SIZE__: usize = 8;
pub const __PTHREAD_RWLOCK_SIZE__: usize = 192;
pub const __PTHREAD_RWLOCKATTR_SIZE__: usize = 16;

Expand All @@ -103,6 +132,12 @@ pub const BIOCSRTIMEOUT: ::c_ulong = 0x8010426d;
pub const BIOCGRTIMEOUT: ::c_ulong = 0x4010426e;
pub const BIOCSETFNR: ::c_ulong = 0x8010427e;

const _PTHREAD_ONCE_SIG_INIT: c_long = 0x30B1BCBA;
pub const PTHREAD_ONCE_INIT: ::pthread_once_t = ::pthread_once_t {
__sig: _PTHREAD_ONCE_SIG_INIT,
__opaque: [0; 8],
};

extern "C" {
pub fn exchangedata(
path1: *const ::c_char,
Expand Down
47 changes: 47 additions & 0 deletions src/unix/bsd/apple/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3787,6 +3787,19 @@ pub const PTHREAD_PROCESS_PRIVATE: ::c_int = 2;
pub const PTHREAD_PROCESS_SHARED: ::c_int = 1;
pub const PTHREAD_CREATE_JOINABLE: ::c_int = 1;
pub const PTHREAD_CREATE_DETACHED: ::c_int = 2;
pub const PTHREAD_INHERIT_SCHED: ::c_int = 1;
pub const PTHREAD_EXPLICIT_SCHED: ::c_int = 2;
pub const PTHREAD_CANCEL_ENABLE: ::c_int = 0x01;
pub const PTHREAD_CANCEL_DISABLE: ::c_int = 0x00;
pub const PTHREAD_CANCEL_DEFERRED: ::c_int = 0x02;
pub const PTHREAD_CANCEL_ASYNCHRONOUS: ::c_int = 0x00;
pub const PTHREAD_CANCELED: *mut ::c_void = 1 as *mut ::c_void;
pub const PTHREAD_SCOPE_SYSTEM: ::c_int = 1;
pub const PTHREAD_SCOPE_PROCESS: ::c_int = 2;
pub const PTHREAD_PRIO_NONE: ::c_int = 0;
pub const PTHREAD_PRIO_INHERIT: ::c_int = 1;
pub const PTHREAD_PRIO_PROTECT: ::c_int = 2;

#[cfg(target_arch = "aarch64")]
pub const PTHREAD_STACK_MIN: ::size_t = 16384;
#[cfg(not(target_arch = "aarch64"))]
Expand Down Expand Up @@ -5757,6 +5770,40 @@ extern "C" {
pub fn mach_timebase_info(info: *mut ::mach_timebase_info) -> ::c_int;
pub fn mach_host_self() -> mach_port_t;
pub fn mach_thread_self() -> mach_port_t;
pub fn pthread_once(
once_control: *mut ::pthread_once_t,
init_routine: ::Option<unsafe extern "C" fn()>,
) -> ::c_int;
pub fn pthread_attr_getinheritsched(
attr: *const ::pthread_attr_t,
inheritsched: *mut ::c_int,
) -> ::c_int;
pub fn pthread_attr_getschedpolicy(
attr: *const ::pthread_attr_t,
policy: *mut ::c_int,
) -> ::c_int;
pub fn pthread_attr_getscope(
attr: *const ::pthread_attr_t,
contentionscope: *mut ::c_int,
) -> ::c_int;
pub fn pthread_attr_getstackaddr(
attr: *const ::pthread_attr_t,
stackaddr: *mut *mut ::c_void,
) -> ::c_int;
pub fn pthread_attr_getdetachstate(
attr: *const ::pthread_attr_t,
detachstate: *mut ::c_int,
) -> ::c_int;
pub fn pthread_attr_setinheritsched(
attr: *mut ::pthread_attr_t,
inheritsched: ::c_int,
) -> ::c_int;
pub fn pthread_attr_setschedpolicy(attr: *mut ::pthread_attr_t, policy: ::c_int) -> ::c_int;
pub fn pthread_attr_setscope(attr: *mut ::pthread_attr_t, contentionscope: ::c_int) -> ::c_int;
pub fn pthread_attr_setstackaddr(
attr: *mut ::pthread_attr_t,
stackaddr: *mut ::c_void,
) -> ::c_int;
pub fn pthread_setname_np(name: *const ::c_char) -> ::c_int;
pub fn pthread_getname_np(thread: ::pthread_t, name: *mut ::c_char, len: ::size_t) -> ::c_int;
pub fn pthread_mach_thread_np(thread: ::pthread_t) -> ::mach_port_t;
Expand Down
2 changes: 2 additions & 0 deletions src/unix/linux_like/emscripten/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,8 @@ pub const POSIX_MADV_RANDOM: ::c_int = 1;
pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2;
pub const POSIX_MADV_WILLNEED: ::c_int = 3;

pub const AT_EACCESS: ::c_int = 0x200;

pub const S_IEXEC: mode_t = 64;
pub const S_IWRITE: mode_t = 128;
pub const S_IREAD: mode_t = 256;
Expand Down
2 changes: 0 additions & 2 deletions src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -802,8 +802,6 @@ extern "C" {
pub fn setcontext(ucp: *const ucontext_t) -> ::c_int;
pub fn makecontext(ucp: *mut ucontext_t, func: extern "C" fn(), argc: ::c_int, ...);
pub fn swapcontext(uocp: *mut ucontext_t, ucp: *const ucontext_t) -> ::c_int;
pub fn iopl(level: ::c_int) -> ::c_int;
pub fn ioperm(from: ::c_ulong, num: ::c_ulong, turn_on: ::c_int) -> ::c_int;
}

cfg_if! {
Expand Down
10 changes: 10 additions & 0 deletions src/unix/linux_like/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1556,6 +1556,16 @@ cfg_if! {
}
}

cfg_if! {
if #[cfg(all(any(target_env = "gnu", target_env = "musl", target_env = "ohos"),
any(target_arch = "x86_64", target_arch = "x86")))] {
extern "C" {
pub fn iopl(level: ::c_int) -> ::c_int;
pub fn ioperm(from: ::c_ulong, num: ::c_ulong, turn_on: ::c_int) -> ::c_int;
}
}
}

cfg_if! {
if #[cfg(any(target_env = "gnu", target_env = "musl", target_env = "ohos"))] {
pub const ABDAY_1: ::nl_item = 0x20000;
Expand Down
12 changes: 12 additions & 0 deletions src/unix/linux_like/linux/musl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,18 @@ pub const MAP_HUGE_16GB: ::c_int = 34 << MAP_HUGE_SHIFT;

pub const MS_RMT_MASK: ::c_ulong = 0x02800051;

// include/utmpx.h
pub const EMPTY: ::c_short = 0;
pub const RUN_LVL: ::c_short = 1;
pub const BOOT_TIME: ::c_short = 2;
pub const NEW_TIME: ::c_short = 3;
pub const OLD_TIME: ::c_short = 4;
pub const INIT_PROCESS: ::c_short = 5;
pub const LOGIN_PROCESS: ::c_short = 6;
pub const USER_PROCESS: ::c_short = 7;
pub const DEAD_PROCESS: ::c_short = 8;
// musl does not define ACCOUNTING

pub const SFD_CLOEXEC: ::c_int = 0x080000;

pub const NCCS: usize = 32;
Expand Down
Loading

0 comments on commit e7ef0da

Please sign in to comment.