summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libc-test/build.rs37
-rw-r--r--libc-test/semver/android.txt1
-rw-r--r--libc-test/semver/apple.txt10
-rw-r--r--libc-test/semver/dragonfly.txt1
-rw-r--r--libc-test/semver/linux-gnu.txt17
-rw-r--r--libc-test/semver/linux.txt5
-rw-r--r--src/unix/bsd/apple/mod.rs12
-rw-r--r--src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs19
-rw-r--r--src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs53
-rw-r--r--src/unix/bsd/freebsdlike/freebsd/mod.rs37
-rw-r--r--src/unix/bsd/freebsdlike/mod.rs5
-rw-r--r--src/unix/linux_like/android/mod.rs36
-rw-r--r--src/unix/linux_like/linux/gnu/mod.rs19
-rw-r--r--src/unix/linux_like/linux/mod.rs8
-rw-r--r--src/unix/linux_like/linux/uclibc/x86_64/mod.rs8
-rw-r--r--src/unix/redox/mod.rs2
16 files changed, 209 insertions, 61 deletions
diff --git a/libc-test/build.rs b/libc-test/build.rs
index e712646449..d2737d0e34 100644
--- a/libc-test/build.rs
+++ b/libc-test/build.rs
@@ -1336,7 +1336,7 @@ fn test_dragonflybsd(target: &str) {
// skip those that are manually verified
match name {
// FIXME: https://github.com/rust-lang/libc/issues/1272
- "execv" | "execve" | "execvp" => true,
+ "execv" | "execve" | "execvp" | "fexecve" => true,
"getrlimit" | "getrlimit64" | // non-int in 1st arg
"setrlimit" | "setrlimit64" | // non-int in 1st arg
@@ -1814,6 +1814,7 @@ fn test_freebsd(target: &str) {
"sys/capsicum.h",
[freebsdlast]:"sys/auxv.h",
"sys/cpuset.h",
+ [freebsdlast]:"sys/domainset.h",
"sys/event.h",
"sys/extattr.h",
"sys/file.h",
@@ -1899,10 +1900,10 @@ fn test_freebsd(target: &str) {
cfg.skip_const(move |name| {
match name {
- // These constants are to be introduced in yet-unreleased FreeBSD 12.2.
+ // These constants were introduced in FreeBSD 13:
"F_ADD_SEALS" | "F_GET_SEALS" | "F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW"
| "F_SEAL_WRITE"
- if Some(12) <= freebsd_ver =>
+ if Some(13) > freebsd_ver =>
{
true
}
@@ -1916,6 +1917,7 @@ fn test_freebsd(target: &str) {
| "IPV6_ORIGDSTADDR"
| "IPV6_RECVORIGDSTADDR"
| "NI_NUMERICSCOPE"
+ | "SO_DOMAIN"
if Some(11) == freebsd_ver =>
{
true
@@ -1986,11 +1988,32 @@ fn test_freebsd(target: &str) {
// commit/06b00ceaa914a3907e4e27bad924f44612bae1d7
"MINCORE_SUPER" if Some(13) == freebsd_ver => true,
+ // Added in FreeBSD 12.0
+ "EINTEGRITY" if Some(11) == freebsd_ver => true,
+
// This was increased to 97 in FreeBSD 12.2 and 13.
// https://github.com/freebsd/freebsd/
// commit/72a21ba0f62da5e86a1c0b462aeb3f5ff849a1b7
"ELAST" if Some(12) == freebsd_ver => true,
+ // Added in FreeBSD 12.0 (r331279)
+ "GRND_NONBLOCK" | "GRND_RANDOM" if Some(11) == freebsd_ver => true,
+ // Added in FreeBSD 13.0 (r356667)
+ "GRND_INSECURE" if Some(13) > freebsd_ver => true,
+
+ // Added in FreeBSD 12.1 (r343964 and r345228)
+ "PROC_ASLR_CTL" | "PROC_ASLR_STATUS" | "PROC_PROCCTL_MD_MIN"
+ if Some(11) == freebsd_ver =>
+ {
+ true
+ }
+
+ // Added in FreeBSD 13.0 (r349609)
+ "PROC_PROTMAX_CTL" | "PROC_PROTMAX_STATUS" if Some(13) > freebsd_ver => true,
+
+ // Added in in FreeBSD 13.0 (r367776 and r367287)
+ "SCM_CREDS2" | "LOCAL_CREDS_PERSISTENT" if Some(13) > freebsd_ver => true,
+
_ => false,
}
});
@@ -2632,6 +2655,7 @@ fn test_linux(target: &str) {
"linux/random.h",
"linux/reboot.h",
"linux/rtnetlink.h",
+ "linux/sched.h",
"linux/seccomp.h",
"linux/sockios.h",
"linux/uinput.h",
@@ -2902,6 +2926,13 @@ fn test_linux(target: &str) {
| "SW_CNT"
if mips || ppc64 || riscv64 || sparc64 => true,
+ // FIXME: Requires more recent kernel headers (5.9 / 5.11):
+ | "CLOSE_RANGE_UNSHARE"
+ | "CLOSE_RANGE_CLOEXEC" => true,
+
+ // FIXME: Not currently available in headers on ARM, MIPS and musl.
+ "NETLINK_GET_STRICT_CHK" if arm || mips || musl => true,
+
// kernel constants not available in uclibc 1.0.34
| "ADDR_COMPAT_LAYOUT"
| "ADDR_LIMIT_3GB"
diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt
index 9bbe6b10e1..9e70cabfec 100644
--- a/libc-test/semver/android.txt
+++ b/libc-test/semver/android.txt
@@ -212,6 +212,7 @@ CLONE_NEWUSER
CLONE_NEWUTS
CLONE_PARENT
CLONE_PARENT_SETTID
+CLONE_PIDFD
CLONE_PTRACE
CLONE_SETTLS
CLONE_SIGHAND
diff --git a/libc-test/semver/apple.txt b/libc-test/semver/apple.txt
index 8592469ddb..b80ae26568 100644
--- a/libc-test/semver/apple.txt
+++ b/libc-test/semver/apple.txt
@@ -937,6 +937,9 @@ PRIO_DARWIN_BG
PRIO_DARWIN_NONUI
PRIO_DARWIN_PROCESS
PRIO_DARWIN_THREAD
+PROC_CSM_ALL
+PROC_CSM_NOSMT
+PROC_CSM_TECS
PROC_PIDTASKALLINFO
PROC_PIDTASKINFO
PROC_PIDTHREADINFO
@@ -1818,6 +1821,10 @@ proc_pidfdinfo
proc_pidfileportinfo
proc_pidpath
proc_regionfilename
+proc_set_no_smt
+proc_setthread_no_smt
+proc_set_csm
+proc_setthread_csm
proc_taskallinfo
proc_taskinfo
proc_threadinfo
@@ -1828,12 +1835,15 @@ pseudo_AF_RTIP
pseudo_AF_XTP
pthread_attr_getschedparam
pthread_attr_setschedparam
+pthread_cpu_number_np
pthread_create_from_mach_thread
pthread_getschedparam
pthread_introspection_getspecific_np
pthread_introspection_hook_t
pthread_introspection_hook_install
pthread_introspection_setspecific_np
+pthread_jit_write_protect_np
+pthread_jit_write_protect_supported_np
pthread_setschedparam
pthread_cancel
pthread_condattr_getpshared
diff --git a/libc-test/semver/dragonfly.txt b/libc-test/semver/dragonfly.txt
index 2258270261..36e3589c78 100644
--- a/libc-test/semver/dragonfly.txt
+++ b/libc-test/semver/dragonfly.txt
@@ -1227,6 +1227,7 @@ faccessat
fchdir
fchflags
fdopendir
+fexecve
fmemopen
forkpty
fparseln
diff --git a/libc-test/semver/linux-gnu.txt b/libc-test/semver/linux-gnu.txt
index 9eac72d3c5..440863c248 100644
--- a/libc-test/semver/linux-gnu.txt
+++ b/libc-test/semver/linux-gnu.txt
@@ -319,6 +319,23 @@ NFT_USERDATA_MAXLEN
NF_NETDEV_INGRESS
NF_NETDEV_NUMHOOKS
NILFS_SUPER_MAGIC
+NT_PRSTATUS
+NT_PRFPREG
+NT_FPREGSET
+NT_PRPSINFO
+NT_PRXREG
+NT_TASKSTRUCT
+NT_PLATFORM
+NT_AUXV
+NT_GWINDOWS
+NT_ASRS
+NT_PSTATUS
+NT_PSINFO
+NT_PRCRED
+NT_UTSNAME
+NT_LWPSTATUS
+NT_LWPSINFO
+NT_PRFPXREG
NTF_EXT_LEARNED
NTF_MASTER
NTF_OFFLOADED
diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt
index ccfc2fb202..beb9d07656 100644
--- a/libc-test/semver/linux.txt
+++ b/libc-test/semver/linux.txt
@@ -257,6 +257,7 @@ CLONE_NEWUSER
CLONE_NEWUTS
CLONE_PARENT
CLONE_PARENT_SETTID
+CLONE_PIDFD
CLONE_PTRACE
CLONE_SETTLS
CLONE_SIGHAND
@@ -265,6 +266,8 @@ CLONE_THREAD
CLONE_UNTRACED
CLONE_VFORK
CLONE_VM
+CLOSE_RANGE_CLOEXEC
+CLOSE_RANGE_UNSHARE
CMSG_DATA
CMSG_FIRSTHDR
CMSG_LEN
@@ -1198,9 +1201,11 @@ NETLINK_CRYPTO
NETLINK_DNRTMSG
NETLINK_DROP_MEMBERSHIP
NETLINK_ECRYPTFS
+NETLINK_EXT_ACK
NETLINK_FIB_LOOKUP
NETLINK_FIREWALL
NETLINK_GENERIC
+NETLINK_GET_STRICT_CHK
NETLINK_INET_DIAG
NETLINK_IP6_FW
NETLINK_ISCSI
diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs
index ce82585bfd..876039119b 100644
--- a/src/unix/bsd/apple/mod.rs
+++ b/src/unix/bsd/apple/mod.rs
@@ -4302,6 +4302,9 @@ pub const PROC_PIDTASKINFO: ::c_int = 4;
pub const PROC_PIDTHREADINFO: ::c_int = 5;
pub const PROC_PIDVNODEPATHINFO: ::c_int = 9;
pub const PROC_PIDPATHINFO_MAXSIZE: ::c_int = 4096;
+pub const PROC_CSM_ALL: ::c_uint = 0x0001;
+pub const PROC_CSM_NOSMT: ::c_uint = 0x0002;
+pub const PROC_CSM_TECS: ::c_uint = 0x0004;
pub const MAXCOMLEN: usize = 16;
pub const MAXTHREADNAMESIZE: usize = 64;
@@ -4873,6 +4876,9 @@ extern "C" {
thread: ::pthread_t,
key: ::pthread_key_t,
) -> *mut ::c_void;
+ pub fn pthread_jit_write_protect_np(enabled: ::c_int);
+ pub fn pthread_jit_write_protect_supported_np() -> ::c_int;
+ pub fn pthread_cpu_number_np(cpu_number_out: *mut ::size_t) -> ::c_int;
pub fn thread_policy_set(
thread: thread_t,
@@ -5246,6 +5252,12 @@ extern "C" {
pub fn proc_kmsgbuf(buffer: *mut ::c_void, buffersize: u32) -> ::c_int;
pub fn proc_libversion(major: *mut ::c_int, mintor: *mut ::c_int) -> ::c_int;
pub fn proc_pid_rusage(pid: ::c_int, flavor: ::c_int, buffer: *mut rusage_info_t) -> ::c_int;
+
+ // Available from Big Sur
+ pub fn proc_set_no_smt() -> ::c_int;
+ pub fn proc_setthread_no_smt() -> ::c_int;
+ pub fn proc_set_csm(flags: u32) -> ::c_int;
+ pub fn proc_setthread_csm(flags: u32) -> ::c_int;
/// # Notes
///
/// `id` is of type [`uuid_t`].
diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs
index a58354b3db..e7b44b3eb0 100644
--- a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs
@@ -200,26 +200,7 @@ cfg_if! {
}
}
-pub const F_ADD_SEALS: ::c_int = 19;
-pub const F_GET_SEALS: ::c_int = 20;
-pub const F_SEAL_SEAL: ::c_int = 0x0001;
-pub const F_SEAL_SHRINK: ::c_int = 0x0002;
-pub const F_SEAL_GROW: ::c_int = 0x0004;
-pub const F_SEAL_WRITE: ::c_int = 0x0008;
-
-pub const GRND_NONBLOCK: ::c_uint = 0x1;
-pub const GRND_RANDOM: ::c_uint = 0x2;
-
pub const RAND_MAX: ::c_int = 0x7fff_fffd;
-
-pub const PROC_ASLR_CTL: ::c_int = 13;
-pub const PROC_ASLR_STATUS: ::c_int = 14;
-
-pub const PROC_PROCCTL_MD_MIN: ::c_int = 0x10000000;
-
-pub const SO_DOMAIN: ::c_int = 0x1019;
-
-pub const EINTEGRITY: ::c_int = 97;
pub const ELAST: ::c_int = 97;
/// max length of devicename
diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs
index 944f620fc3..92ea7f5aa2 100644
--- a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs
@@ -6,6 +6,7 @@ pub type ino_t = ::c_ulong;
pub type shmatt_t = ::c_uint;
pub type kpaddr_t = u64;
pub type kssize_t = i64;
+pub type domainset_t = __c_anonymous_domainset;
s! {
pub struct shmid_ds {
@@ -49,6 +50,10 @@ s! {
pub kp_offset: ::off_t,
pub kp_len: ::size_t,
}
+
+ pub struct __c_anonymous_domainset {
+ _priv: [::uintptr_t; 4],
+ }
}
s_no_extra_traits! {
@@ -213,32 +218,8 @@ cfg_if! {
}
}
-pub const F_ADD_SEALS: ::c_int = 19;
-pub const F_GET_SEALS: ::c_int = 20;
-pub const F_SEAL_SEAL: ::c_int = 0x0001;
-pub const F_SEAL_SHRINK: ::c_int = 0x0002;
-pub const F_SEAL_GROW: ::c_int = 0x0004;
-pub const F_SEAL_WRITE: ::c_int = 0x0008;
-
-pub const GRND_NONBLOCK: ::c_uint = 0x1;
-pub const GRND_RANDOM: ::c_uint = 0x2;
-
pub const RAND_MAX: ::c_int = 0x7fff_ffff;
-
-pub const SO_DOMAIN: ::c_int = 0x1019;
-
-pub const EINTEGRITY: ::c_int = 97;
pub const ELAST: ::c_int = 97;
-pub const GRND_INSECURE: ::c_uint = 0x4;
-
-pub const PROC_ASLR_CTL: ::c_int = 13;
-pub const PROC_ASLR_STATUS: ::c_int = 14;
-pub const PROC_PROTMAX_CTL: ::c_int = 15;
-pub const PROC_PROTMAX_STATUS: ::c_int = 16;
-pub const PROC_PROCCTL_MD_MIN: ::c_int = 0x10000000;
-
-pub const LOCAL_CREDS_PERSISTENT: ::c_int = 3;
-pub const SCM_CREDS2: ::c_int = 0x08;
pub const KF_TYPE_EVENTFD: ::c_int = 13;
@@ -246,6 +227,13 @@ pub const KF_TYPE_EVENTFD: ::c_int = 13;
pub const SPECNAMELEN: ::c_int = 255;
pub const KI_NSPARE_PTR: usize = 5;
+/// domainset policies
+pub const DOMAINSET_POLICY_INVALID: ::c_int = 0;
+pub const DOMAINSET_POLICY_ROUNDROBIN: ::c_int = 1;
+pub const DOMAINSET_POLICY_FIRSTTOUCH: ::c_int = 2;
+pub const DOMAINSET_POLICY_PREFER: ::c_int = 3;
+pub const DOMAINSET_POLICY_INTERLEAVE: ::c_int = 4;
+
f! {
pub fn SOCKCRED2SIZE(ngrps: usize) -> usize {
let ngrps = if ngrps > 0 {
@@ -285,6 +273,23 @@ extern "C" {
pub fn setproctitle_fast(fmt: *const ::c_char, ...);
pub fn timingsafe_bcmp(a: *const ::c_void, b: *const ::c_void, len: ::size_t) -> ::c_int;
pub fn timingsafe_memcmp(a: *const ::c_void, b: *const ::c_void, len: ::size_t) -> ::c_int;
+
+ pub fn cpuset_getdomain(
+ level: ::cpulevel_t,
+ which: ::cpuwhich_t,
+ id: ::id_t,
+ setsize: ::size_t,
+ mask: *mut ::domainset_t,
+ policy: *mut ::c_int,
+ ) -> ::c_int;
+ pub fn cpuset_setdomain(
+ level: ::cpulevel_t,
+ which: ::cpuwhich_t,
+ id: ::id_t,
+ setsize: ::size_t,
+ mask: *const ::domainset_t,
+ policy: ::c_int,
+ ) -> ::c_int;
}
#[link(name = "kvm")]
diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs
index 99f272aad6..50c01b370e 100644
--- a/src/unix/bsd/freebsdlike/freebsd/mod.rs
+++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs
@@ -796,6 +796,7 @@ pub const ENOTCAPABLE: ::c_int = 93;
pub const ECAPMODE: ::c_int = 94;
pub const ENOTRECOVERABLE: ::c_int = 95;
pub const EOWNERDEAD: ::c_int = 96;
+pub const EINTEGRITY: ::c_int = 97;
pub const RLIMIT_NPTS: ::c_int = 11;
pub const RLIMIT_SWAP: ::c_int = 12;
pub const RLIMIT_KQUEUES: ::c_int = 13;
@@ -1072,6 +1073,8 @@ pub const MNT_UNION: ::c_int = 0x00000020;
pub const MNT_EXPUBLIC: ::c_int = 0x20000000;
pub const MNT_NONBUSY: ::c_int = 0x04000000;
+pub const SCM_CREDS2: ::c_int = 0x08;
+
pub const SO_BINTIME: ::c_int = 0x2000;
pub const SO_NO_OFFLOAD: ::c_int = 0x4000;
pub const SO_NO_DDP: ::c_int = 0x8000;
@@ -1085,9 +1088,11 @@ pub const SO_SETFIB: ::c_int = 0x1014;
pub const SO_USER_COOKIE: ::c_int = 0x1015;
pub const SO_PROTOCOL: ::c_int = 0x1016;
pub const SO_PROTOTYPE: ::c_int = SO_PROTOCOL;
+pub const SO_DOMAIN: ::c_int = 0x1019;
pub const SO_VENDOR: ::c_int = 0x80000000;
pub const LOCAL_CREDS: ::c_int = 2;
+pub const LOCAL_CREDS_PERSISTENT: ::c_int = 3;
pub const LOCAL_CONNWAIT: ::c_int = 4;
pub const LOCAL_VENDOR: ::c_int = SO_VENDOR;
@@ -1136,8 +1141,13 @@ pub const PROC_TRAPCAP_CTL: ::c_int = 9;
pub const PROC_TRAPCAP_STATUS: ::c_int = 10;
pub const PROC_PDEATHSIG_CTL: ::c_int = 11;
pub const PROC_PDEATHSIG_STATUS: ::c_int = 12;
+pub const PROC_ASLR_CTL: ::c_int = 13;
+pub const PROC_ASLR_STATUS: ::c_int = 14;
+pub const PROC_PROTMAX_CTL: ::c_int = 15;
+pub const PROC_PROTMAX_STATUS: ::c_int = 16;
pub const PROC_STACKGAP_CTL: ::c_int = 17;
pub const PROC_STACKGAP_STATUS: ::c_int = 18;
+pub const PROC_PROCCTL_MD_MIN: ::c_int = 0x10000000;
pub const AF_SLOW: ::c_int = 33;
pub const AF_SCLUSTER: ::c_int = 34;
@@ -1604,14 +1614,28 @@ pub const UF_READONLY: ::c_ulong = 0x00001000;
pub const UF_HIDDEN: ::c_ulong = 0x00008000;
pub const SF_SNAPSHOT: ::c_ulong = 0x00200000;
+// fcntl commands
+pub const F_ADD_SEALS: ::c_int = 19;
+pub const F_DUP2FD: ::c_int = 10;
+pub const F_DUP2FD_CLOEXEC: ::c_int = 18;
+pub const F_GET_SEALS: ::c_int = 20;
pub const F_OGETLK: ::c_int = 7;
pub const F_OSETLK: ::c_int = 8;
pub const F_OSETLKW: ::c_int = 9;
-pub const F_DUP2FD: ::c_int = 10;
-pub const F_SETLK_REMOTE: ::c_int = 14;
-pub const F_READAHEAD: ::c_int = 15;
pub const F_RDAHEAD: ::c_int = 16;
-pub const F_DUP2FD_CLOEXEC: ::c_int = 18;
+pub const F_READAHEAD: ::c_int = 15;
+pub const F_SETLK_REMOTE: ::c_int = 14;
+
+// for use with F_ADD_SEALS
+pub const F_SEAL_GROW: ::c_int = 4;
+pub const F_SEAL_SEAL: ::c_int = 1;
+pub const F_SEAL_SHRINK: ::c_int = 2;
+pub const F_SEAL_WRITE: ::c_int = 8;
+
+// For getrandom()
+pub const GRND_NONBLOCK: ::c_uint = 0x1;
+pub const GRND_RANDOM: ::c_uint = 0x2;
+pub const GRND_INSECURE: ::c_uint = 0x4;
// For realhostname* api
pub const HOSTNAME_FOUND: ::c_int = 0;
@@ -2106,11 +2130,6 @@ extern "C" {
msgflg: ::c_int,
) -> ::c_int;
pub fn cfmakesane(termios: *mut ::termios);
- pub fn fexecve(
- fd: ::c_int,
- argv: *const *const ::c_char,
- envp: *const *const ::c_char,
- ) -> ::c_int;
pub fn pdfork(fdp: *mut ::c_int, flags: ::c_int) -> ::pid_t;
pub fn pdgetpid(fd: ::c_int, pidp: *mut ::pid_t) -> ::c_int;
diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs
index 2717a5cfb7..41803ead02 100644
--- a/src/unix/bsd/freebsdlike/mod.rs
+++ b/src/unix/bsd/freebsdlike/mod.rs
@@ -1441,6 +1441,11 @@ extern "C" {
pub fn duplocale(base: ::locale_t) -> ::locale_t;
pub fn endutxent();
pub fn fchflags(fd: ::c_int, flags: ::c_ulong) -> ::c_int;
+ pub fn fexecve(
+ fd: ::c_int,
+ argv: *const *const ::c_char,
+ envp: *const *const ::c_char,
+ ) -> ::c_int;
pub fn futimens(fd: ::c_int, times: *const ::timespec) -> ::c_int;
pub fn getdomainname(name: *mut ::c_char, len: ::c_int) -> ::c_int;
pub fn getgrent_r(
diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs
index 6faadb9b88..759eaa9af4 100644
--- a/src/unix/linux_like/android/mod.rs
+++ b/src/unix/linux_like/android/mod.rs
@@ -2447,6 +2447,8 @@ pub const SCHED_DEADLINE: ::c_int = 6;
pub const SCHED_RESET_ON_FORK: ::c_int = 0x40000000;
+pub const CLONE_PIDFD: ::c_int = 0x1000;
+
// bits/seek_constants.h
pub const SEEK_DATA: ::c_int = 3;
pub const SEEK_HOLE: ::c_int = 4;
@@ -2480,6 +2482,12 @@ f! {
}
}
+ pub fn CPU_ALLOC_SIZE(count: ::c_int) -> ::size_t {
+ let _dummy: cpu_set_t = ::mem::zeroed();
+ let size_in_bits = 8 * ::mem::size_of_val(&_dummy.__bits[0]);
+ ((count as ::size_t + size_in_bits - 1) / 8) as ::size_t
+ }
+
pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () {
for slot in cpuset.__bits.iter_mut() {
*slot = 0;
@@ -2487,28 +2495,44 @@ f! {
}
pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () {
- let size_in___bits = 8 * ::mem::size_of_val(&cpuset.__bits[0]);
- let (idx, offset) = (cpu / size_in___bits, cpu % size_in___bits);
+ let size_in_bits
+ = 8 * ::mem::size_of_val(&cpuset.__bits[0]); // 32, 64 etc
+ let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
cpuset.__bits[idx] |= 1 << offset;
()
}
pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () {
- let size_in___bits = 8 * ::mem::size_of_val(&cpuset.__bits[0]);
- let (idx, offset) = (cpu / size_in___bits, cpu % size_in___bits);
+ let size_in_bits
+ = 8 * ::mem::size_of_val(&cpuset.__bits[0]); // 32, 64 etc
+ let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
cpuset.__bits[idx] &= !(1 << offset);
()
}
pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool {
- let size_in___bits = 8 * ::mem::size_of_val(&cpuset.__bits[0]);
- let (idx, offset) = (cpu / size_in___bits, cpu % size_in___bits);
+ let size_in_bits = 8 * ::mem::size_of_val(&cpuset.__bits[0]);
+ let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits);
0 != (cpuset.__bits[idx] & (1 << offset))
}
+ pub fn CPU_COUNT_S(size: usize, cpuset: &cpu_set_t) -> ::c_int {
+ let mut s: u32 = 0;
+ let size_of_mask = ::mem::size_of_val(&cpuset.__bits[0]);
+ for i in cpuset.__bits[..(size / size_of_mask)].iter() {
+ s += i.count_ones();
+ };
+ s as ::c_int
+ }
+
+ pub fn CPU_COUNT(cpuset: &cpu_set_t) -> ::c_int {
+ CPU_COUNT_S(::mem::size_of::<cpu_set_t>(), cpuset)
+ }
+
pub fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool {
set1.__bits == set2.__bits
}
+
pub fn major(dev: ::dev_t) -> ::c_int {
((dev >> 8) & 0xfff) as ::c_int
}
diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs
index bb2a777d77..598bf465b4 100644
--- a/src/unix/linux_like/linux/gnu/mod.rs
+++ b/src/unix/linux_like/linux/gnu/mod.rs
@@ -956,6 +956,25 @@ pub const TIOCM_RTS: ::c_int = 0x004;
pub const TIOCM_CD: ::c_int = TIOCM_CAR;
pub const TIOCM_RI: ::c_int = TIOCM_RNG;
+// elf.h
+pub const NT_PRSTATUS: ::c_int = 1;
+pub const NT_PRFPREG: ::c_int = 2;
+pub const NT_FPREGSET: ::c_int = 2;
+pub const NT_PRPSINFO: ::c_int = 3;
+pub const NT_PRXREG: ::c_int = 4;
+pub const NT_TASKSTRUCT: ::c_int = 4;
+pub const NT_PLATFORM: ::c_int = 5;
+pub const NT_AUXV: ::c_int = 6;
+pub const NT_GWINDOWS: ::c_int = 7;
+pub const NT_ASRS: ::c_int = 8;
+pub const NT_PSTATUS: ::c_int = 10;
+pub const NT_PSINFO: ::c_int = 13;
+pub const NT_PRCRED: ::c_int = 14;
+pub const NT_UTSNAME: ::c_int = 15;
+pub const NT_LWPSTATUS: ::c_int = 16;
+pub const NT_LWPSINFO: ::c_int = 17;
+pub const NT_PRFPXREG: ::c_int = 20;
+
// linux/keyctl.h
pub const KEYCTL_DH_COMPUTE: u32 = 23;
pub const KEYCTL_PKEY_QUERY: u32 = 24;
diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs
index 7f837f2ab8..d0d86ac0b5 100644
--- a/src/unix/linux_like/linux/mod.rs
+++ b/src/unix/linux_like/linux/mod.rs
@@ -1509,6 +1509,8 @@ pub const SCHED_IDLE: ::c_int = 5;
pub const SCHED_RESET_ON_FORK: ::c_int = 0x40000000;
+pub const CLONE_PIDFD: ::c_int = 0x1000;
+
// netinet/in.h
// NOTE: These are in addition to the constants defined in src/unix/mod.rs
@@ -1818,6 +1820,10 @@ pub const MFD_CLOEXEC: ::c_uint = 0x0001;
pub const MFD_ALLOW_SEALING: ::c_uint = 0x0002;
pub const MFD_HUGETLB: ::c_uint = 0x0004;
+// linux/close_range.h
+pub const CLOSE_RANGE_UNSHARE: ::c_uint = 1 << 1;
+pub const CLOSE_RANGE_CLOEXEC: ::c_uint = 1 << 2;
+
// these are used in the p_type field of Elf32_Phdr and Elf64_Phdr, which has
// the type Elf32Word and Elf64Word respectively. Luckily, both of those are u32
// so we can use that type here to avoid having to cast.
@@ -2390,6 +2396,8 @@ pub const NETLINK_TX_RING: ::c_int = 7;
pub const NETLINK_LISTEN_ALL_NSID: ::c_int = 8;
pub const NETLINK_LIST_MEMBERSHIPS: ::c_int = 9;
pub const NETLINK_CAP_ACK: ::c_int = 10;
+pub const NETLINK_EXT_ACK: ::c_int = 11;
+pub const NETLINK_GET_STRICT_CHK: ::c_int = 12;
pub const NLA_F_NESTED: ::c_int = 1 << 15;
pub const NLA_F_NET_BYTEORDER: ::c_int = 1 << 14;
diff --git a/src/unix/linux_like/linux/uclibc/x86_64/mod.rs b/src/unix/linux_like/linux/uclibc/x86_64/mod.rs
index 4f7974c5e9..7f80df4377 100644
--- a/src/unix/linux_like/linux/uclibc/x86_64/mod.rs
+++ b/src/unix/linux_like/linux/uclibc/x86_64/mod.rs
@@ -292,8 +292,13 @@ s_no_extra_traits! {
}
// constants
+pub const ENAMETOOLONG: ::c_int = 36; // File name too long
+pub const ENOTEMPTY: ::c_int = 39; // Directory not empty
+pub const ELOOP: ::c_int = 40; // Too many symbolic links encountered
pub const EADDRINUSE: ::c_int = 98; // Address already in use
pub const EADDRNOTAVAIL: ::c_int = 99; // Cannot assign requested address
+pub const ENETDOWN: ::c_int = 100; // Network is down
+pub const ENETUNREACH: ::c_int = 101; // Network is unreachable
pub const ECONNABORTED: ::c_int = 103; // Software caused connection abort
pub const ECONNREFUSED: ::c_int = 111; // Connection refused
pub const ECONNRESET: ::c_int = 104; // Connection reset by peer
@@ -301,6 +306,9 @@ pub const EDEADLK: ::c_int = 35; // Resource deadlock would occur
pub const ENOSYS: ::c_int = 38; // Function not implemented
pub const ENOTCONN: ::c_int = 107; // Transport endpoint is not connected
pub const ETIMEDOUT: ::c_int = 110; // connection timed out
+pub const ESTALE: ::c_int = 116; // Stale file handle
+pub const EHOSTUNREACH: ::c_int = 113; // No route to host
+pub const EDQUOT: ::c_int = 122; // Quota exceeded
pub const EOPNOTSUPP: ::c_int = 0x5f;
pub const ENODATA: ::c_int = 0x3d;
pub const O_APPEND: ::c_int = 02000;
diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs
index f2a2d62958..9836551d94 100644
--- a/src/unix/redox/mod.rs
+++ b/src/unix/redox/mod.rs
@@ -1001,6 +1001,8 @@ extern "C" {
set: *const ::sigset_t,
oldset: *mut ::sigset_t,
) -> ::c_int;
+ pub fn pthread_cancel(thread: ::pthread_t) -> ::c_int;
+ pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int;
// sys/epoll.h
pub fn epoll_create(size: ::c_int) -> ::c_int;