diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 73d2f9f42c785..d581b362ebacf 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -232,7 +232,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: test on Solaris - uses: vmactions/solaris-vm@v1 + uses: vmactions/solaris-vm@v1.1.3 with: release: "11.4-gcc" usesh: true diff --git a/Cargo.toml b/Cargo.toml index cabbc528a16c2..9e53e45110a7e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,21 +1,16 @@ [package] name = "libc" version = "0.2.172" -authors = ["The Rust Project Developers"] -license = "MIT OR Apache-2.0" -readme = "README.md" -edition = "2021" -repository = "https://github.com/rust-lang/libc" -homepage = "https://github.com/rust-lang/libc" -documentation = "https://docs.rs/libc/" keywords = ["libc", "ffi", "bindings", "operating", "system"] categories = ["external-ffi-bindings", "no-std", "os"] -build = "build.rs" exclude = ["/ci/*", "/.github/*", "/.cirrus.yml", "/triagebot.toml"] +description = "Raw FFI bindings to platform libraries like libc." +publish = false # On the main branch, we don't want to publish anything +authors = ["The Rust Project Developers"] +edition = "2021" +license = "MIT OR Apache-2.0" +repository = "https://github.com/rust-lang/libc" rust-version = "1.63" -description = """ -Raw FFI bindings to platform libraries like libc. -""" [package.metadata.docs.rs] features = ["extra_traits"] diff --git a/build.rs b/build.rs index bf5277a9a9968..ec2c599ca7de0 100644 --- a/build.rs +++ b/build.rs @@ -241,7 +241,13 @@ fn which_freebsd() -> Option { } fn emcc_version_code() -> Option { - let output = Command::new("emcc").arg("-dumpversion").output().ok()?; + let emcc = if cfg!(target_os = "windows") { + "emcc.bat" + } else { + "emcc" + }; + + let output = Command::new(emcc).arg("-dumpversion").output().ok()?; if !output.status.success() { return None; } diff --git a/libc-test/Cargo.toml b/libc-test/Cargo.toml index 26b38621fb3c8..9573c3fdb8288 100644 --- a/libc-test/Cargo.toml +++ b/libc-test/Cargo.toml @@ -1,16 +1,12 @@ [package] name = "libc-test" -version = "0.2.155" -edition = "2021" +version = "0.1.0" +description = "A test crate for the libc crate." +publish = false authors = ["The Rust Project Developers"] +edition = "2021" license = "MIT OR Apache-2.0" -build = "build.rs" -publish = false repository = "https://github.com/rust-lang/libc" -homepage = "https://github.com/rust-lang/libc" -description = """ -A test crate for the libc crate. -""" [dependencies] cfg-if = "1.0.0" diff --git a/libc-test/build.rs b/libc-test/build.rs index 4955e8545d8aa..7d6e5fe6d7330 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -4123,6 +4123,10 @@ fn test_linux(target: &str) { // Might differ between kernel versions "open_how" => true, + // Linux >= 6.13 (pidfd_info.exit_code: Linux >= 6.15) + // Might differ between kernel versions + "pidfd_info" => true, + "sctp_initmsg" | "sctp_sndrcvinfo" | "sctp_sndinfo" | "sctp_rcvinfo" | "sctp_nxtinfo" | "sctp_prinfo" | "sctp_authinfo" => true, @@ -4229,6 +4233,7 @@ fn test_linux(target: &str) { || name.starts_with("OPEN_TREE_") || name.starts_with("P_") || name.starts_with("PF_") + || name.starts_with("PIDFD_") || name.starts_with("RLIMIT_") || name.starts_with("RTEXT_FILTER_") || name.starts_with("SOL_") @@ -4297,6 +4302,10 @@ fn test_linux(target: &str) { if loongarch64 && (name == "MFD_NOEXEC_SEAL" || name == "MFD_EXEC") { return true; } + // FIXME: Requires >= 6.3 (6.6) kernel headers + if name == "PR_GET_MDWE" || name == "PR_MDWE_NO_INHERIT" || name == "PR_MDWE_REFUSE_EXEC_GAIN" || name == "PR_SET_MDWE" { + return true; + } // FIXME(musl): Requires musl >= 1.2 if name == "SO_PREFER_BUSY_POLL" || name == "SO_BUSY_POLL_BUDGET" @@ -4432,6 +4441,30 @@ fn test_linux(target: &str) { // headers conflicts with linux/pidfd.h "PIDFD_NONBLOCK" => true, + // Linux >= 6.9 + "PIDFD_THREAD" + | "PIDFD_SIGNAL_THREAD" + | "PIDFD_SIGNAL_THREAD_GROUP" + | "PIDFD_SIGNAL_PROCESS_GROUP" => true, + // Linux >= 6.11 + "PIDFD_GET_CGROUP_NAMESPACE" + | "PIDFD_GET_IPC_NAMESPACE" + | "PIDFD_GET_MNT_NAMESPACE" + | "PIDFD_GET_NET_NAMESPACE" + | "PIDFD_GET_PID_NAMESPACE" + | "PIDFD_GET_PID_FOR_CHILDREN_NAMESPACE" + | "PIDFD_GET_TIME_NAMESPACE" + | "PIDFD_GET_TIME_FOR_CHILDREN_NAMESPACE" + | "PIDFD_GET_USER_NAMESPACE" + | "PIDFD_GET_UTS_NAMESPACE" => true, + // Linux >= 6.13 + "PIDFD_GET_INFO" + | "PIDFD_INFO_PID" + | "PIDFD_INFO_CREDS" + | "PIDFD_INFO_CGROUPID" + | "PIDFD_INFO_SIZE_VER0" => true, + // Linux >= 6.15 + "PIDFD_INFO_EXIT" | "PIDFD_SELF" | "PIDFD_SELF_PROCESS" => true, // is a private value for kernel usage normally "FUSE_SUPER_MAGIC" => true, @@ -4554,6 +4587,9 @@ fn test_linux(target: &str) { true } + // FIXME(linux): Requires >= 6.6 kernel headers. + "PR_MDWE_NO_INHERIT" => true, + // FIXME(linux): Requires >= 6.8 kernel headers. "XDP_UMEM_TX_SW_CSUM" | "XDP_TXMD_FLAGS_TIMESTAMP" @@ -4851,7 +4887,9 @@ fn test_linux(target: &str) { (struct_ == "statvfs" && field == "__f_spare") || (struct_ == "statvfs64" && field == "__f_spare") || // the `xsk_tx_metadata_union` field is an anonymous union - (struct_ == "xsk_tx_metadata" && field == "xsk_tx_metadata_union") + (struct_ == "xsk_tx_metadata" && field == "xsk_tx_metadata_union") || + // FIXME(musl): After musl 1.2.0, the type becomes `int` instead of `long`. + (struct_ == "utmpx" && field == "ut_session") }); cfg.skip_roundtrip(move |s| match s { diff --git a/libc-test/semver/linux-musl.txt b/libc-test/semver/linux-musl.txt index e2fdcbf006c64..462f45f7d13b0 100644 --- a/libc-test/semver/linux-musl.txt +++ b/libc-test/semver/linux-musl.txt @@ -28,7 +28,6 @@ OLD_TIME PF_IB PF_MPLS PF_XDP -PIDFD_NONBLOCK PR_SET_VMA PR_SET_VMA_ANON_NAME RUN_LVL diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index 9bf5ec61c461f..011fba0d85b6b 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -2084,6 +2084,7 @@ PACKET_FANOUT_QM PACKET_FANOUT_RND PACKET_FANOUT_ROLLOVER PACKET_HOST +PACKET_IGNORE_OUTGOING PACKET_KERNEL PACKET_LOOPBACK PACKET_LOSS @@ -2171,6 +2172,32 @@ PF_WANPIPE PF_WQ_WORKER PF_X PF_X25 +PIDFD_GET_CGROUP_NAMESPACE +PIDFD_GET_INFO +PIDFD_GET_IPC_NAMESPACE +PIDFD_GET_MNT_NAMESPACE +PIDFD_GET_NET_NAMESPACE +PIDFD_GET_PID_FOR_CHILDREN_NAMESPACE +PIDFD_GET_PID_NAMESPACE +PIDFD_GET_TIME_FOR_CHILDREN_NAMESPACE +PIDFD_GET_TIME_NAMESPACE +PIDFD_GET_USER_NAMESPACE +PIDFD_GET_UTS_NAMESPACE +PIDFD_INFO_CGROUPID +PIDFD_INFO_CREDS +PIDFD_INFO_EXIT +PIDFD_INFO_PID +PIDFD_INFO_SIZE_VER0 +PIDFD_NONBLOCK +PIDFD_SIGNAL_PROCESS_GROUP +PIDFD_SIGNAL_THREAD +PIDFD_SIGNAL_THREAD_GROUP +PIDFD_THREAD +PIDTYPE_MAX +PIDTYPE_PGID +PIDTYPE_PID +PIDTYPE_SID +PIDTYPE_TGID PIPE_BUF PM_STR POLLRDBAND @@ -2229,6 +2256,7 @@ PR_GET_FPEMU PR_GET_FPEXC PR_GET_FP_MODE PR_GET_KEEPCAPS +PR_GET_MDWE PR_GET_NAME PR_GET_NO_NEW_PRIVS PR_GET_PDEATHSIG @@ -2247,6 +2275,8 @@ PR_MCE_KILL_EARLY PR_MCE_KILL_GET PR_MCE_KILL_LATE PR_MCE_KILL_SET +PR_MDWE_NO_INHERIT +PR_MDWE_REFUSE_EXEC_GAIN PR_MPX_DISABLE_MANAGEMENT PR_MPX_ENABLE_MANAGEMENT PR_SCHED_CORE @@ -2265,6 +2295,7 @@ PR_SET_FPEMU PR_SET_FPEXC PR_SET_FP_MODE PR_SET_KEEPCAPS +PR_SET_MDWE PR_SET_MM PR_SET_MM_ARG_END PR_SET_MM_ARG_START @@ -4038,6 +4069,8 @@ packet_mreq pause personality pgn_t +pid_type +pidfd_info pipe2 popen posix_fadvise diff --git a/libc-test/semver/redox.txt b/libc-test/semver/redox.txt index 8e7403982e216..3c3c52eabb4f0 100644 --- a/libc-test/semver/redox.txt +++ b/libc-test/semver/redox.txt @@ -135,6 +135,7 @@ O_SHLOCK O_SYMLINK PTHREAD_STACK_MIN SA_RESTORER +SCM_RIGHTS SIGIO SIGPWR SIGSTKFLT diff --git a/libc-test/semver/windows.txt b/libc-test/semver/windows.txt index db55da5f4e48d..281a13bb73034 100644 --- a/libc-test/semver/windows.txt +++ b/libc-test/semver/windows.txt @@ -174,12 +174,15 @@ c_void calloc chdir chmod +clock clock_t close commit connect creat +ctime dev_t +difftime dup dup2 errno_t @@ -214,7 +217,11 @@ fsetpos fstat ftell fwrite +get_daylight +get_dstbias get_osfhandle +get_timezone +get_tzname getchar getcwd getenv @@ -326,6 +333,7 @@ tm tmpfile tolower toupper +tzset uint16_t uint32_t uint64_t diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index b60201791b645..f065eaa3aec8b 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -1452,9 +1452,9 @@ pub const GRPQUOTA: c_int = 1; pub const SIGIOT: c_int = 6; -pub const S_ISUID: crate::mode_t = 0o4000; -pub const S_ISGID: crate::mode_t = 0o2000; -pub const S_ISVTX: crate::mode_t = 0o1000; +pub const S_ISUID: mode_t = 0o4000; +pub const S_ISGID: mode_t = 0o2000; +pub const S_ISVTX: mode_t = 0o1000; pub const IF_NAMESIZE: size_t = 16; pub const IFNAMSIZ: size_t = IF_NAMESIZE; @@ -1585,26 +1585,26 @@ pub const O_RDONLY: c_int = 0; pub const O_WRONLY: c_int = 1; pub const O_RDWR: c_int = 2; -pub const S_IFIFO: crate::mode_t = 0o1_0000; -pub const S_IFCHR: crate::mode_t = 0o2_0000; -pub const S_IFBLK: crate::mode_t = 0o6_0000; -pub const S_IFDIR: crate::mode_t = 0o4_0000; -pub const S_IFREG: crate::mode_t = 0o10_0000; -pub const S_IFLNK: crate::mode_t = 0o12_0000; -pub const S_IFSOCK: crate::mode_t = 0o14_0000; -pub const S_IFMT: crate::mode_t = 0o17_0000; -pub const S_IRWXU: crate::mode_t = 0o0700; -pub const S_IXUSR: crate::mode_t = 0o0100; -pub const S_IWUSR: crate::mode_t = 0o0200; -pub const S_IRUSR: crate::mode_t = 0o0400; -pub const S_IRWXG: crate::mode_t = 0o0070; -pub const S_IXGRP: crate::mode_t = 0o0010; -pub const S_IWGRP: crate::mode_t = 0o0020; -pub const S_IRGRP: crate::mode_t = 0o0040; -pub const S_IRWXO: crate::mode_t = 0o0007; -pub const S_IXOTH: crate::mode_t = 0o0001; -pub const S_IWOTH: crate::mode_t = 0o0002; -pub const S_IROTH: crate::mode_t = 0o0004; +pub const S_IFIFO: mode_t = 0o1_0000; +pub const S_IFCHR: mode_t = 0o2_0000; +pub const S_IFBLK: mode_t = 0o6_0000; +pub const S_IFDIR: mode_t = 0o4_0000; +pub const S_IFREG: mode_t = 0o10_0000; +pub const S_IFLNK: mode_t = 0o12_0000; +pub const S_IFSOCK: mode_t = 0o14_0000; +pub const S_IFMT: mode_t = 0o17_0000; +pub const S_IRWXU: mode_t = 0o0700; +pub const S_IXUSR: mode_t = 0o0100; +pub const S_IWUSR: mode_t = 0o0200; +pub const S_IRUSR: mode_t = 0o0400; +pub const S_IRWXG: mode_t = 0o0070; +pub const S_IXGRP: mode_t = 0o0010; +pub const S_IWGRP: mode_t = 0o0020; +pub const S_IRGRP: mode_t = 0o0040; +pub const S_IRWXO: mode_t = 0o0007; +pub const S_IXOTH: mode_t = 0o0001; +pub const S_IWOTH: mode_t = 0o0002; +pub const S_IROTH: mode_t = 0o0004; pub const F_OK: c_int = 0; pub const R_OK: c_int = 4; pub const W_OK: c_int = 2; @@ -3726,12 +3726,7 @@ extern "C" { pub fn rewinddir(dirp: *mut crate::DIR); pub fn openat(dirfd: c_int, pathname: *const c_char, flags: c_int, ...) -> c_int; - pub fn fchmodat( - dirfd: c_int, - pathname: *const c_char, - mode: crate::mode_t, - flags: c_int, - ) -> c_int; + pub fn fchmodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, flags: c_int) -> c_int; pub fn fchown(fd: c_int, owner: crate::uid_t, group: crate::gid_t) -> c_int; pub fn fchownat( dirfd: c_int, @@ -3748,7 +3743,7 @@ extern "C" { newpath: *const c_char, flags: c_int, ) -> c_int; - pub fn mkdirat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int; + pub fn mkdirat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; pub fn readlinkat( dirfd: c_int, pathname: *const c_char, @@ -3966,7 +3961,7 @@ extern "C" { pub fn gmtime(time_p: *const time_t) -> *mut tm; pub fn localtime(time_p: *const time_t) -> *mut tm; - pub fn mknod(pathname: *const c_char, mode: crate::mode_t, dev: crate::dev_t) -> c_int; + pub fn mknod(pathname: *const c_char, mode: mode_t, dev: crate::dev_t) -> c_int; pub fn uname(buf: *mut crate::utsname) -> c_int; pub fn gethostname(name: *mut c_char, len: size_t) -> c_int; pub fn getservbyname(name: *const c_char, proto: *const c_char) -> *mut servent; @@ -4086,8 +4081,7 @@ extern "C" { pub fn fdopendir(fd: c_int) -> *mut crate::DIR; - pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t, dev: dev_t) - -> c_int; + pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int; pub fn pthread_condattr_getclock( attr: *const pthread_condattr_t, clock_id: *mut clockid_t, @@ -4214,7 +4208,7 @@ extern "C" { pub fn setfsuid(uid: crate::uid_t) -> c_int; // Not available now on Android - pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int; + pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; pub fn if_nameindex() -> *mut if_nameindex; pub fn if_freenameindex(ptr: *mut if_nameindex); pub fn sync_file_range(fd: c_int, offset: off64_t, nbytes: off64_t, flags: c_uint) -> c_int; diff --git a/src/macros.rs b/src/macros.rs index e7dbf5611970e..abffa2afb9520 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -193,6 +193,7 @@ macro_rules! missing { /// Implement `Clone` and `Copy` for an enum, as well as `Debug`, `Eq`, `Hash`, and /// `PartialEq` if the `extra_traits` feature is enabled. +// FIXME(#4419): Replace all uses of `e!` with `c_enum!` macro_rules! e { ($( $(#[$attr:meta])* @@ -210,6 +211,48 @@ macro_rules! e { )*); } +/// Represent a C enum as Rust constants and a type. +/// +/// C enums can't soundly be mapped to Rust enums since C enums are allowed to have duplicates or +/// unlisted values, but this is UB in Rust. This enum doesn't implement any traits, its main +/// purpose is to calculate the correct enum values. +/// +/// See for more. +macro_rules! c_enum { + ( + $(#[repr($repr:ty)])? + $ty_name:ident { + $($variant:ident $(= $value:literal)?,)+ + } + ) => { + pub type $ty_name = c_enum!(@ty $($repr)?); + c_enum!(@one; $ty_name; 0; $($variant $(= $value)?,)+); + }; + + // Matcher for a single variant + (@one; $_ty_name:ident; $_idx:expr;) => {}; + ( + @one; $ty_name:ident; $default_val:expr; + $variant:ident $(= $value:literal)?, + $($tail:tt)* + ) => { + pub const $variant: $ty_name = { + #[allow(unused_variables)] + let r = $default_val; + $(let r = $value;)? + r + }; + + // The next value is always one more than the previous value, unless + // set explicitly. + c_enum!(@one; $ty_name; $variant + 1; $($tail)*); + }; + + // Use a specific type if provided, otherwise default to `c_uint` + (@ty $repr:ty) => { $repr }; + (@ty) => { $crate::c_uint }; +} + // This is a pretty horrible hack to allow us to conditionally mark some functions as 'const', // without requiring users of this macro to care "libc_const_extern_fn". // @@ -359,3 +402,76 @@ macro_rules! deprecated_mach { )* } } + +#[cfg(test)] +mod tests { + #[test] + fn c_enumbasic() { + // By default, variants get sequential values. + c_enum! { + e { + VAR0, + VAR1, + VAR2, + } + } + + assert_eq!(VAR0, 0_u32); + assert_eq!(VAR1, 1_u32); + assert_eq!(VAR2, 2_u32); + } + + #[test] + fn c_enumrepr() { + // By default, variants get sequential values. + c_enum! { + #[repr(u16)] + e { + VAR0, + } + } + + assert_eq!(VAR0, 0_u16); + } + + #[test] + fn c_enumset_value() { + // Setting an explicit value resets the count. + c_enum! { + e { + VAR2 = 2, + VAR3, + VAR4, + } + } + + assert_eq!(VAR2, 2_u32); + assert_eq!(VAR3, 3_u32); + assert_eq!(VAR4, 4_u32); + } + + #[test] + fn c_enummultiple_set_value() { + // C enums always take one more than the previous value, unless set to a specific + // value. Duplicates are allowed. + c_enum! { + e { + VAR0, + VAR2_0 = 2, + VAR3_0, + VAR4_0, + VAR2_1 = 2, + VAR3_1, + VAR4_1, + } + } + + assert_eq!(VAR0, 0_u32); + assert_eq!(VAR2_0, 2_u32); + assert_eq!(VAR3_0, 3_u32); + assert_eq!(VAR4_0, 4_u32); + assert_eq!(VAR2_1, 2_u32); + assert_eq!(VAR3_1, 3_u32); + assert_eq!(VAR4_1, 4_u32); + } +} diff --git a/src/unix/aix/mod.rs b/src/unix/aix/mod.rs index a43fcd104748c..8cca9bb3c20d6 100644 --- a/src/unix/aix/mod.rs +++ b/src/unix/aix/mod.rs @@ -2881,9 +2881,8 @@ extern "C" { ) -> *mut c_void; pub fn memset_s(s: *mut c_void, smax: size_t, c: c_int, n: size_t) -> c_int; pub fn mincore(addr: *const c_void, len: size_t, vec: *mut c_char) -> c_int; - pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int; - pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t, dev: dev_t) - -> c_int; + pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; + pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int; pub fn mount(device: *const c_char, path: *const c_char, flags: c_int) -> c_int; pub fn mprotect(addr: *mut c_void, len: size_t, prot: c_int) -> c_int; pub fn mq_close(mqd: crate::mqd_t) -> c_int; @@ -2977,7 +2976,7 @@ extern "C" { fd: c_int, path: *const c_char, oflag: c_int, - mode: crate::mode_t, + mode: mode_t, ) -> c_int; pub fn posix_spawn_file_actions_destroy(actions: *mut posix_spawn_file_actions_t) -> c_int; pub fn posix_spawn_file_actions_init(actions: *mut posix_spawn_file_actions_t) -> c_int; @@ -3142,7 +3141,7 @@ extern "C" { pub fn shmdt(shmaddr: *const c_void) -> c_int; pub fn shmctl(shmid: c_int, cmd: c_int, buf: *mut crate::shmid_ds) -> c_int; pub fn shmget(key: key_t, size: size_t, shmflg: c_int) -> c_int; - pub fn shm_open(name: *const c_char, oflag: c_int, mode: crate::mode_t) -> c_int; + pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int; pub fn shm_unlink(name: *const c_char) -> c_int; pub fn splice(socket1: c_int, socket2: c_int, flags: c_int) -> c_int; pub fn srand(seed: c_uint); diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 56169a5cf73d8..9c76ed7c01cc5 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -775,7 +775,7 @@ s! { pub gid: crate::gid_t, pub cuid: crate::uid_t, pub cgid: crate::gid_t, - pub mode: crate::mode_t, + pub mode: mode_t, pub _seq: c_ushort, pub _key: crate::key_t, } @@ -6341,7 +6341,7 @@ extern "C" { fd: c_int, path: *const c_char, oflag: c_int, - mode: crate::mode_t, + mode: mode_t, ) -> c_int; pub fn posix_spawn_file_actions_addclose( actions: *mut posix_spawn_file_actions_t, @@ -6660,9 +6660,8 @@ extern "C" { pub fn dirname(path: *mut c_char) -> *mut c_char; pub fn basename(path: *mut c_char) -> *mut c_char; - pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int; - pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t, dev: dev_t) - -> c_int; + pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; + pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int; pub fn freadlink(fd: c_int, buf: *mut c_char, size: size_t) -> c_int; pub fn execvP( file: *const c_char, diff --git a/src/unix/bsd/freebsdlike/mod.rs b/src/unix/bsd/freebsdlike/mod.rs index 5ed09c78f1891..197873cd17795 100644 --- a/src/unix/bsd/freebsdlike/mod.rs +++ b/src/unix/bsd/freebsdlike/mod.rs @@ -378,7 +378,7 @@ s! { pub cgid: crate::gid_t, pub uid: crate::uid_t, pub gid: crate::gid_t, - pub mode: crate::mode_t, + pub mode: mode_t, pub seq: c_ushort, pub key: crate::key_t, } @@ -1602,13 +1602,12 @@ extern "C" { pub fn lchflags(path: *const c_char, flags: c_ulong) -> c_int; pub fn lutimes(file: *const c_char, times: *const crate::timeval) -> c_int; pub fn memrchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; - pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int; + pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; #[cfg_attr( all(target_os = "freebsd", any(freebsd11, freebsd10)), link_name = "mknodat@FBSD_1.1" )] - pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t, dev: dev_t) - -> c_int; + pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int; pub fn malloc_usable_size(ptr: *const c_void) -> size_t; pub fn mincore(addr: *const c_void, len: size_t, vec: *mut c_char) -> c_int; pub fn newlocale(mask: c_int, locale: *const c_char, base: crate::locale_t) -> crate::locale_t; @@ -1730,7 +1729,7 @@ extern "C" { pub fn setresuid(ruid: crate::uid_t, euid: crate::uid_t, suid: crate::uid_t) -> c_int; pub fn settimeofday(tv: *const crate::timeval, tz: *const crate::timezone) -> c_int; pub fn setutxent(); - pub fn shm_open(name: *const c_char, oflag: c_int, mode: crate::mode_t) -> c_int; + pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int; pub fn sigtimedwait( set: *const sigset_t, info: *mut siginfo_t, @@ -1872,7 +1871,7 @@ extern "C" { fd: c_int, path: *const c_char, oflag: c_int, - mode: crate::mode_t, + mode: mode_t, ) -> c_int; pub fn posix_spawn_file_actions_addclose( actions: *mut posix_spawn_file_actions_t, diff --git a/src/unix/bsd/netbsdlike/mod.rs b/src/unix/bsd/netbsdlike/mod.rs index dfd58d75b74ae..682b8b7e9fe74 100644 --- a/src/unix/bsd/netbsdlike/mod.rs +++ b/src/unix/bsd/netbsdlike/mod.rs @@ -78,7 +78,7 @@ s! { pub cgid: crate::gid_t, pub uid: crate::uid_t, pub gid: crate::gid_t, - pub mode: crate::mode_t, + pub mode: mode_t, #[cfg(target_os = "openbsd")] pub seq: c_ushort, #[cfg(target_os = "netbsd")] @@ -689,7 +689,7 @@ extern "C" { #[cfg_attr(target_os = "netbsd", link_name = "__clock_settime50")] pub fn clock_settime(clk_id: crate::clockid_t, tp: *const crate::timespec) -> c_int; pub fn __errno() -> *mut c_int; - pub fn shm_open(name: *const c_char, oflag: c_int, mode: crate::mode_t) -> c_int; + pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int; pub fn memrchr(cx: *const c_void, c: c_int, n: size_t) -> *mut c_void; pub fn mkostemp(template: *mut c_char, flags: c_int) -> c_int; pub fn mkostemps(template: *mut c_char, suffixlen: c_int, flags: c_int) -> c_int; @@ -707,9 +707,8 @@ extern "C" { pub fn getpriority(which: c_int, who: crate::id_t) -> c_int; pub fn setpriority(which: c_int, who: crate::id_t, prio: c_int) -> c_int; - pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t, dev: dev_t) - -> c_int; - pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int; + pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int; + pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; pub fn sem_timedwait(sem: *mut sem_t, abstime: *const crate::timespec) -> c_int; pub fn sem_getvalue(sem: *mut sem_t, sval: *mut c_int) -> c_int; pub fn pthread_condattr_setclock( @@ -830,7 +829,7 @@ extern "C" { fd: c_int, path: *const c_char, oflag: c_int, - mode: crate::mode_t, + mode: mode_t, ) -> c_int; pub fn posix_spawn_file_actions_addclose( actions: *mut posix_spawn_file_actions_t, diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index 76e44cc796f1d..ef48fa6f9be4b 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -420,7 +420,7 @@ s! { pub gid: crate::gid_t, pub cuid: crate::uid_t, pub cgid: crate::gid_t, - pub mode: crate::mode_t, + pub mode: mode_t, } pub struct sembuf { @@ -774,27 +774,27 @@ pub const O_NOFOLLOW: c_int = 0x00080000; pub const O_NOCACHE: c_int = 0x00100000; pub const O_DIRECTORY: c_int = 0x00200000; -pub const S_IFIFO: crate::mode_t = 0o1_0000; -pub const S_IFCHR: crate::mode_t = 0o2_0000; -pub const S_IFBLK: crate::mode_t = 0o6_0000; -pub const S_IFDIR: crate::mode_t = 0o4_0000; -pub const S_IFREG: crate::mode_t = 0o10_0000; -pub const S_IFLNK: crate::mode_t = 0o12_0000; -pub const S_IFSOCK: crate::mode_t = 0o14_0000; -pub const S_IFMT: crate::mode_t = 0o17_0000; - -pub const S_IRWXU: crate::mode_t = 0o0700; -pub const S_IRUSR: crate::mode_t = 0o0400; -pub const S_IWUSR: crate::mode_t = 0o0200; -pub const S_IXUSR: crate::mode_t = 0o0100; -pub const S_IRWXG: crate::mode_t = 0o0070; -pub const S_IRGRP: crate::mode_t = 0o0040; -pub const S_IWGRP: crate::mode_t = 0o0020; -pub const S_IXGRP: crate::mode_t = 0o0010; -pub const S_IRWXO: crate::mode_t = 0o0007; -pub const S_IROTH: crate::mode_t = 0o0004; -pub const S_IWOTH: crate::mode_t = 0o0002; -pub const S_IXOTH: crate::mode_t = 0o0001; +pub const S_IFIFO: mode_t = 0o1_0000; +pub const S_IFCHR: mode_t = 0o2_0000; +pub const S_IFBLK: mode_t = 0o6_0000; +pub const S_IFDIR: mode_t = 0o4_0000; +pub const S_IFREG: mode_t = 0o10_0000; +pub const S_IFLNK: mode_t = 0o12_0000; +pub const S_IFSOCK: mode_t = 0o14_0000; +pub const S_IFMT: mode_t = 0o17_0000; + +pub const S_IRWXU: mode_t = 0o0700; +pub const S_IRUSR: mode_t = 0o0400; +pub const S_IWUSR: mode_t = 0o0200; +pub const S_IXUSR: mode_t = 0o0100; +pub const S_IRWXG: mode_t = 0o0070; +pub const S_IRGRP: mode_t = 0o0040; +pub const S_IWGRP: mode_t = 0o0020; +pub const S_IXGRP: mode_t = 0o0010; +pub const S_IRWXO: mode_t = 0o0007; +pub const S_IROTH: mode_t = 0o0004; +pub const S_IWOTH: mode_t = 0o0002; +pub const S_IXOTH: mode_t = 0o0001; pub const F_OK: c_int = 0; pub const R_OK: c_int = 4; @@ -1733,9 +1733,8 @@ extern "C" { bufferSize: size_t, res: *mut *mut spwd, ) -> c_int; - pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int; - pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t, dev: dev_t) - -> c_int; + pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; + pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int; pub fn sem_destroy(sem: *mut sem_t) -> c_int; pub fn sem_init(sem: *mut sem_t, pshared: c_int, value: c_uint) -> c_int; @@ -1813,7 +1812,7 @@ extern "C" { pub fn posix_fadvise(fd: c_int, offset: off_t, len: off_t, advice: c_int) -> c_int; pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int; - pub fn shm_open(name: *const c_char, oflag: c_int, mode: crate::mode_t) -> c_int; + pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int; pub fn shm_unlink(name: *const c_char) -> c_int; pub fn seekdir(dirp: *mut crate::DIR, loc: c_long); @@ -2032,7 +2031,7 @@ extern "C" { fildes: c_int, path: *const c_char, oflag: c_int, - mode: crate::mode_t, + mode: mode_t, ) -> c_int; pub fn posix_spawn_file_actions_addclose( file_actions: *mut posix_spawn_file_actions_t, diff --git a/src/unix/hurd/mod.rs b/src/unix/hurd/mod.rs index 8703f4d37a66d..961710b5ae76d 100644 --- a/src/unix/hurd/mod.rs +++ b/src/unix/hurd/mod.rs @@ -2150,35 +2150,35 @@ pub const SF_NOUNLINK: c_uint = 1048576; pub const SF_SNAPSHOT: c_uint = 2097152; pub const UTIME_NOW: c_long = -1; pub const UTIME_OMIT: c_long = -2; -pub const S_IFMT: crate::mode_t = 0o17_0000; -pub const S_IFDIR: crate::mode_t = 0o4_0000; -pub const S_IFCHR: crate::mode_t = 0o2_0000; -pub const S_IFBLK: crate::mode_t = 0o6_0000; -pub const S_IFREG: crate::mode_t = 0o10_0000; -pub const S_IFIFO: crate::mode_t = 0o1_0000; -pub const S_IFLNK: crate::mode_t = 0o12_0000; -pub const S_IFSOCK: crate::mode_t = 0o14_0000; -pub const S_ISUID: crate::mode_t = 0o4000; -pub const S_ISGID: crate::mode_t = 0o2000; -pub const S_ISVTX: crate::mode_t = 0o1000; -pub const S_IRUSR: crate::mode_t = 0o0400; -pub const S_IWUSR: crate::mode_t = 0o0200; -pub const S_IXUSR: crate::mode_t = 0o0100; -pub const S_IRWXU: crate::mode_t = 0o0700; -pub const S_IREAD: crate::mode_t = 0o0400; -pub const S_IWRITE: crate::mode_t = 0o0200; -pub const S_IEXEC: crate::mode_t = 0o0100; -pub const S_IRGRP: crate::mode_t = 0o0040; -pub const S_IWGRP: crate::mode_t = 0o0020; -pub const S_IXGRP: crate::mode_t = 0o0010; -pub const S_IRWXG: crate::mode_t = 0o0070; -pub const S_IROTH: crate::mode_t = 0o0004; -pub const S_IWOTH: crate::mode_t = 0o0002; -pub const S_IXOTH: crate::mode_t = 0o0001; -pub const S_IRWXO: crate::mode_t = 0o0007; -pub const ACCESSPERMS: crate::mode_t = 511; -pub const ALLPERMS: crate::mode_t = 4095; -pub const DEFFILEMODE: crate::mode_t = 438; +pub const S_IFMT: mode_t = 0o17_0000; +pub const S_IFDIR: mode_t = 0o4_0000; +pub const S_IFCHR: mode_t = 0o2_0000; +pub const S_IFBLK: mode_t = 0o6_0000; +pub const S_IFREG: mode_t = 0o10_0000; +pub const S_IFIFO: mode_t = 0o1_0000; +pub const S_IFLNK: mode_t = 0o12_0000; +pub const S_IFSOCK: mode_t = 0o14_0000; +pub const S_ISUID: mode_t = 0o4000; +pub const S_ISGID: mode_t = 0o2000; +pub const S_ISVTX: mode_t = 0o1000; +pub const S_IRUSR: mode_t = 0o0400; +pub const S_IWUSR: mode_t = 0o0200; +pub const S_IXUSR: mode_t = 0o0100; +pub const S_IRWXU: mode_t = 0o0700; +pub const S_IREAD: mode_t = 0o0400; +pub const S_IWRITE: mode_t = 0o0200; +pub const S_IEXEC: mode_t = 0o0100; +pub const S_IRGRP: mode_t = 0o0040; +pub const S_IWGRP: mode_t = 0o0020; +pub const S_IXGRP: mode_t = 0o0010; +pub const S_IRWXG: mode_t = 0o0070; +pub const S_IROTH: mode_t = 0o0004; +pub const S_IWOTH: mode_t = 0o0002; +pub const S_IXOTH: mode_t = 0o0001; +pub const S_IRWXO: mode_t = 0o0007; +pub const ACCESSPERMS: mode_t = 511; +pub const ALLPERMS: mode_t = 4095; +pub const DEFFILEMODE: mode_t = 438; pub const S_BLKSIZE: usize = 512; pub const STATX_TYPE: c_uint = 1; pub const STATX_MODE: c_uint = 2; @@ -3574,8 +3574,7 @@ extern "C" { pub fn mkfifoat(__fd: c_int, __path: *const c_char, __mode: __mode_t) -> c_int; - pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t, dev: dev_t) - -> c_int; + pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int; pub fn __libc_current_sigrtmin() -> c_int; @@ -4248,7 +4247,7 @@ extern "C" { fd: c_int, path: *const c_char, oflag: c_int, - mode: crate::mode_t, + mode: mode_t, ) -> c_int; pub fn posix_spawn_file_actions_addclose( actions: *mut posix_spawn_file_actions_t, diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index c5875f2956df7..3d24d5d8fb73f 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -2709,7 +2709,7 @@ pub const TUNSETTXFILTER: c_int = _IOW::(T_TYPE, 209); pub const TUNGETIFF: c_int = _IOR::(T_TYPE, 210); pub const TUNGETSNDBUF: c_int = _IOR::(T_TYPE, 211); pub const TUNSETSNDBUF: c_int = _IOW::(T_TYPE, 212); -pub const TUNATTACHFILTER: c_int = _IOW::(T_TYPE, 213); +pub const TUNATTACHFILTER: c_int = _IOW::(T_TYPE, 213); pub const TUNDETACHFILTER: c_int = _IOW::(T_TYPE, 214); pub const TUNGETVNETHDRSZ: c_int = _IOR::(T_TYPE, 215); pub const TUNSETVNETHDRSZ: c_int = _IOW::(T_TYPE, 216); @@ -4307,15 +4307,20 @@ pub const fn _IO(ty: u32, nr: u32) -> c_int { /// Build an ioctl number for an read-only ioctl. pub const fn _IOR(ty: u32, nr: u32) -> c_int { - super::_IOC(super::_IOC_READ, ty, nr, mem::size_of::()) as c_int + super::_IOC(super::_IOC_READ, ty, nr, mem::size_of::()) as c_int } /// Build an ioctl number for an write-only ioctl. pub const fn _IOW(ty: u32, nr: u32) -> c_int { - super::_IOC(super::_IOC_WRITE, ty, nr, mem::size_of::()) as c_int + super::_IOC(super::_IOC_WRITE, ty, nr, mem::size_of::()) as c_int } /// Build an ioctl number for a read-write ioctl. pub const fn _IOWR(ty: u32, nr: u32) -> c_int { - super::_IOC(super::_IOC_READ | super::_IOC_WRITE, ty, nr, mem::size_of::()) as c_int + super::_IOC( + super::_IOC_READ | super::_IOC_WRITE, + ty, + nr, + mem::size_of::(), + ) as c_int } diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index 985b3c0c5e187..462a944b1e2b1 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -171,7 +171,7 @@ s! { pub gid: crate::gid_t, pub cuid: crate::uid_t, pub cgid: crate::gid_t, - pub mode: crate::mode_t, + pub mode: mode_t, pub __seq: c_int, __unused1: c_long, __unused2: c_long, @@ -229,7 +229,7 @@ s! { __st_dev_padding: c_int, #[cfg(emscripten_old_stat_abi)] __st_ino_truncated: c_long, - pub st_mode: crate::mode_t, + pub st_mode: mode_t, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, @@ -1530,7 +1530,7 @@ extern "C" { ) -> c_int; pub fn getloadavg(loadavg: *mut c_double, nelem: c_int) -> c_int; - pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int; + pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; pub fn if_nameindex() -> *mut if_nameindex; pub fn if_freenameindex(ptr: *mut if_nameindex); diff --git a/src/unix/linux_like/linux/gnu/b64/s390x.rs b/src/unix/linux_like/linux/gnu/b64/s390x.rs index c08e12108b918..18684de36dc52 100644 --- a/src/unix/linux_like/linux/gnu/b64/s390x.rs +++ b/src/unix/linux_like/linux/gnu/b64/s390x.rs @@ -235,7 +235,7 @@ cfg_if! { impl hash::Hash for fpreg_t { fn hash(&self, state: &mut H) { - let d: u64 = unsafe { mem::transmute(self.d) }; + let d: u64 = self.d.to_bits(); d.hash(state); } } diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 823f495084bda..84d7c24742c37 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -751,7 +751,6 @@ pub const RTLD_DI_TLS_MODID: c_int = 9; pub const RTLD_DI_TLS_DATA: c_int = 10; pub const SOCK_NONBLOCK: c_int = O_NONBLOCK; -pub const PIDFD_NONBLOCK: c_uint = O_NONBLOCK as c_uint; pub const SOL_RXRPC: c_int = 272; pub const SOL_PPPOL2TP: c_int = 273; diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 5be701beeaabc..c0989d2d74c7d 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -93,6 +93,16 @@ e! { } } +c_enum! { + pid_type { + PIDTYPE_PID, + PIDTYPE_TGID, + PIDTYPE_PGID, + PIDTYPE_SID, + PIDTYPE_MAX, + } +} + s! { pub struct glob_t { pub gl_pathc: size_t, @@ -1366,6 +1376,25 @@ s! { pub userns_fd: crate::__u64, } + // linux/pidfd.h + + pub struct pidfd_info { + mask: crate::__u64, + cgroupid: crate::__u64, + pid: crate::__u32, + tgid: crate::__u32, + ppid: crate::__u32, + ruid: crate::__u32, + rgid: crate::__u32, + euid: crate::__u32, + egid: crate::__u32, + suid: crate::__u32, + sgid: crate::__u32, + fsuid: crate::__u32, + fsgid: crate::__u32, + exit_code: crate::__s32, + } + // linux/uio.h pub struct dmabuf_cmsg { @@ -3182,6 +3211,35 @@ pub const MREMAP_MAYMOVE: c_int = 1; pub const MREMAP_FIXED: c_int = 2; pub const MREMAP_DONTUNMAP: c_int = 4; +// linux/pidfd.h +pub const PIDFD_NONBLOCK: c_uint = O_NONBLOCK as c_uint; +pub const PIDFD_THREAD: c_uint = O_EXCL as c_uint; + +pub const PIDFD_SIGNAL_THREAD: c_uint = 1 << 0; +pub const PIDFD_SIGNAL_THREAD_GROUP: c_uint = 1 << 1; +pub const PIDFD_SIGNAL_PROCESS_GROUP: c_uint = 1 << 2; + +pub const PIDFD_INFO_PID: c_uint = 1 << 0; +pub const PIDFD_INFO_CREDS: c_uint = 1 << 1; +pub const PIDFD_INFO_CGROUPID: c_uint = 1 << 2; +pub const PIDFD_INFO_EXIT: c_uint = 1 << 3; + +pub const PIDFD_INFO_SIZE_VER0: c_uint = 64; + +const PIDFS_IOCTL_MAGIC: c_uint = 0xFF; +pub const PIDFD_GET_CGROUP_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 1); +pub const PIDFD_GET_IPC_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 2); +pub const PIDFD_GET_MNT_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 3); +pub const PIDFD_GET_NET_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 4); +pub const PIDFD_GET_PID_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 5); +pub const PIDFD_GET_PID_FOR_CHILDREN_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 6); +pub const PIDFD_GET_TIME_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 7); +pub const PIDFD_GET_TIME_FOR_CHILDREN_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 8); +pub const PIDFD_GET_USER_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 9); +pub const PIDFD_GET_UTS_NAMESPACE: c_uint = _IO(PIDFS_IOCTL_MAGIC, 10); +pub const PIDFD_GET_INFO: c_uint = _IOWR::(PIDFS_IOCTL_MAGIC, 11); + +// linux/prctl.h pub const PR_SET_PDEATHSIG: c_int = 1; pub const PR_GET_PDEATHSIG: c_int = 2; @@ -3284,6 +3342,11 @@ pub const PR_GET_CHILD_SUBREAPER: c_int = 37; pub const PR_SET_NO_NEW_PRIVS: c_int = 38; pub const PR_GET_NO_NEW_PRIVS: c_int = 39; +pub const PR_SET_MDWE: c_int = 65; +pub const PR_GET_MDWE: c_int = 66; +pub const PR_MDWE_REFUSE_EXEC_GAIN: c_uint = 1 << 0; +pub const PR_MDWE_NO_INHERIT: c_uint = 1 << 1; + pub const PR_GET_TID_ADDRESS: c_int = 40; pub const PR_SET_THP_DISABLE: c_int = 41; @@ -3830,6 +3893,7 @@ pub const PACKET_LOSS: c_int = 14; pub const PACKET_TIMESTAMP: c_int = 17; pub const PACKET_FANOUT: c_int = 18; pub const PACKET_QDISC_BYPASS: c_int = 20; +pub const PACKET_IGNORE_OUTGOING: c_int = 23; pub const PACKET_FANOUT_HASH: c_uint = 0; pub const PACKET_FANOUT_LB: c_uint = 1; @@ -6544,7 +6608,7 @@ extern "C" { pub fn setfsuid(uid: crate::uid_t) -> c_int; // Not available now on Android - pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int; + pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; pub fn if_nameindex() -> *mut if_nameindex; pub fn if_freenameindex(ptr: *mut if_nameindex); pub fn sync_file_range(fd: c_int, offset: off64_t, nbytes: off64_t, flags: c_uint) -> c_int; @@ -6899,7 +6963,7 @@ extern "C" { fd: c_int, path: *const c_char, oflag: c_int, - mode: crate::mode_t, + mode: mode_t, ) -> c_int; pub fn posix_spawn_file_actions_addclose( actions: *mut posix_spawn_file_actions_t, diff --git a/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs b/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs index 36f05e10e6ea4..e96bcbb2788e4 100644 --- a/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs +++ b/src/unix/linux_like/linux/musl/b64/loongarch64/mod.rs @@ -65,7 +65,6 @@ s! { pub cgid: crate::gid_t, pub mode: c_uint, pub __seq: c_int, - __pad2: c_ushort, __unused1: c_ulong, __unused2: c_ulong, } diff --git a/src/unix/linux_like/linux/musl/b64/s390x.rs b/src/unix/linux_like/linux/musl/b64/s390x.rs index b992a2c4361e4..8a274f39dfb77 100644 --- a/src/unix/linux_like/linux/musl/b64/s390x.rs +++ b/src/unix/linux_like/linux/musl/b64/s390x.rs @@ -88,7 +88,7 @@ cfg_if! { impl hash::Hash for fpreg_t { fn hash(&self, state: &mut H) { - let d: u64 = unsafe { mem::transmute(self.d) }; + let d: u64 = self.d.to_bits(); d.hash(state); } } diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index f850849b2d6ae..5d4d97fafbc8e 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -787,8 +787,6 @@ pub const EFD_NONBLOCK: c_int = crate::O_NONBLOCK; pub const SFD_NONBLOCK: c_int = crate::O_NONBLOCK; -pub const PIDFD_NONBLOCK: c_uint = O_NONBLOCK as c_uint; - pub const TCSANOW: c_int = 0; pub const TCSADRAIN: c_int = 1; pub const TCSAFLUSH: c_int = 2; diff --git a/src/unix/linux_like/linux/uclibc/arm/mod.rs b/src/unix/linux_like/linux/uclibc/arm/mod.rs index 634161ed622ca..7a517f4974694 100644 --- a/src/unix/linux_like/linux/uclibc/arm/mod.rs +++ b/src/unix/linux_like/linux/uclibc/arm/mod.rs @@ -475,7 +475,6 @@ pub const POLLWRBAND: c_short = 0x200; pub const POLLWRNORM: c_short = 0x100; pub const PTHREAD_STACK_MIN: size_t = 16384; pub const RTLD_GLOBAL: c_int = 0x00100; -pub const PIDFD_NONBLOCK: c_int = 0x800; // These are typed unsigned to match sigaction pub const SA_NOCLDSTOP: c_ulong = 0x1; diff --git a/src/unix/linux_like/linux/uclibc/mips/mod.rs b/src/unix/linux_like/linux/uclibc/mips/mod.rs index f1934c396773a..0ad572a95f888 100644 --- a/src/unix/linux_like/linux/uclibc/mips/mod.rs +++ b/src/unix/linux_like/linux/uclibc/mips/mod.rs @@ -57,7 +57,6 @@ pub const O_LARGEFILE: c_int = 0x2000; pub const O_NDELAY: c_int = 0x80; pub const SOCK_NONBLOCK: c_int = 128; -pub const PIDFD_NONBLOCK: c_int = 128; pub const EDEADLK: c_int = 45; pub const ENAMETOOLONG: c_int = 78; 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 3a4ee0dee31c2..4a6c19fc97da3 100644 --- a/src/unix/linux_like/linux/uclibc/x86_64/mod.rs +++ b/src/unix/linux_like/linux/uclibc/x86_64/mod.rs @@ -342,7 +342,6 @@ pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; pub const __SIZEOF_PTHREAD_BARRIER_T: usize = 32; pub const __SIZEOF_PTHREAD_BARRIERATTR_T: usize = 4; -pub const PIDFD_NONBLOCK: c_int = 0o4000; cfg_if! { if #[cfg(target_os = "l4re")] { diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 64481a673bd39..9c7766a1407d1 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -545,26 +545,26 @@ pub const O_RDWR: c_int = 2; pub const SOCK_CLOEXEC: c_int = O_CLOEXEC; -pub const S_IFIFO: crate::mode_t = 0o1_0000; -pub const S_IFCHR: crate::mode_t = 0o2_0000; -pub const S_IFBLK: crate::mode_t = 0o6_0000; -pub const S_IFDIR: crate::mode_t = 0o4_0000; -pub const S_IFREG: crate::mode_t = 0o10_0000; -pub const S_IFLNK: crate::mode_t = 0o12_0000; -pub const S_IFSOCK: crate::mode_t = 0o14_0000; -pub const S_IFMT: crate::mode_t = 0o17_0000; -pub const S_IRWXU: crate::mode_t = 0o0700; -pub const S_IXUSR: crate::mode_t = 0o0100; -pub const S_IWUSR: crate::mode_t = 0o0200; -pub const S_IRUSR: crate::mode_t = 0o0400; -pub const S_IRWXG: crate::mode_t = 0o0070; -pub const S_IXGRP: crate::mode_t = 0o0010; -pub const S_IWGRP: crate::mode_t = 0o0020; -pub const S_IRGRP: crate::mode_t = 0o0040; -pub const S_IRWXO: crate::mode_t = 0o0007; -pub const S_IXOTH: crate::mode_t = 0o0001; -pub const S_IWOTH: crate::mode_t = 0o0002; -pub const S_IROTH: crate::mode_t = 0o0004; +pub const S_IFIFO: mode_t = 0o1_0000; +pub const S_IFCHR: mode_t = 0o2_0000; +pub const S_IFBLK: mode_t = 0o6_0000; +pub const S_IFDIR: mode_t = 0o4_0000; +pub const S_IFREG: mode_t = 0o10_0000; +pub const S_IFLNK: mode_t = 0o12_0000; +pub const S_IFSOCK: mode_t = 0o14_0000; +pub const S_IFMT: mode_t = 0o17_0000; +pub const S_IRWXU: mode_t = 0o0700; +pub const S_IXUSR: mode_t = 0o0100; +pub const S_IWUSR: mode_t = 0o0200; +pub const S_IRUSR: mode_t = 0o0400; +pub const S_IRWXG: mode_t = 0o0070; +pub const S_IXGRP: mode_t = 0o0010; +pub const S_IWGRP: mode_t = 0o0020; +pub const S_IRGRP: mode_t = 0o0040; +pub const S_IRWXO: mode_t = 0o0007; +pub const S_IXOTH: mode_t = 0o0001; +pub const S_IWOTH: mode_t = 0o0002; +pub const S_IROTH: mode_t = 0o0004; pub const F_OK: c_int = 0; pub const R_OK: c_int = 4; pub const W_OK: c_int = 2; @@ -1877,8 +1877,7 @@ extern "C" { pub fn freelocale(loc: crate::locale_t); pub fn newlocale(mask: c_int, locale: *const c_char, base: crate::locale_t) -> crate::locale_t; pub fn uselocale(loc: crate::locale_t) -> crate::locale_t; - pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t, dev: dev_t) - -> c_int; + pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int; pub fn pthread_condattr_getclock( attr: *const pthread_condattr_t, clock_id: *mut clockid_t, diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 433eeec950965..4fc2afedfc095 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -245,9 +245,9 @@ cfg_if! { } pub const SIGIOT: c_int = 6; -pub const S_ISUID: crate::mode_t = 0o4000; -pub const S_ISGID: crate::mode_t = 0o2000; -pub const S_ISVTX: crate::mode_t = 0o1000; +pub const S_ISUID: mode_t = 0o4000; +pub const S_ISGID: mode_t = 0o2000; +pub const S_ISVTX: mode_t = 0o1000; cfg_if! { if #[cfg(not(any( @@ -939,12 +939,7 @@ extern "C" { )] pub fn rewinddir(dirp: *mut crate::DIR); - pub fn fchmodat( - dirfd: c_int, - pathname: *const c_char, - mode: crate::mode_t, - flags: c_int, - ) -> c_int; + pub fn fchmodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, flags: c_int) -> c_int; pub fn fchown(fd: c_int, owner: crate::uid_t, group: crate::gid_t) -> c_int; pub fn fchownat( dirfd: c_int, @@ -1421,7 +1416,7 @@ extern "C" { all(target_os = "freebsd", any(freebsd11, freebsd10)), link_name = "mknod@FBSD_1.0" )] - pub fn mknod(pathname: *const c_char, mode: crate::mode_t, dev: crate::dev_t) -> c_int; + pub fn mknod(pathname: *const c_char, mode: mode_t, dev: crate::dev_t) -> c_int; pub fn gethostname(name: *mut c_char, len: size_t) -> c_int; pub fn endservent(); pub fn getservbyname(name: *const c_char, proto: *const c_char) -> *mut servent; @@ -1659,7 +1654,7 @@ cfg_if! { )] pub fn pause() -> c_int; - pub fn mkdirat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int; + pub fn mkdirat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; #[cfg_attr(gnu_file_offset_bits64, link_name = "openat64")] pub fn openat(dirfd: c_int, pathname: *const c_char, flags: c_int, ...) -> c_int; diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index ae118b4719a65..d49bdb3e9e18c 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -568,28 +568,28 @@ pub const SEEK_END: c_int = 2; pub const FIOCLEX: c_ulong = 0x20006601; pub const FIONCLEX: c_ulong = 0x20006602; -pub const S_BLKSIZE: crate::mode_t = 1024; -pub const S_IREAD: crate::mode_t = 0o0400; -pub const S_IWRITE: crate::mode_t = 0o0200; -pub const S_IEXEC: crate::mode_t = 0o0100; -pub const S_ENFMT: crate::mode_t = 0o2000; -pub const S_IFMT: crate::mode_t = 0o17_0000; -pub const S_IFDIR: crate::mode_t = 0o4_0000; -pub const S_IFCHR: crate::mode_t = 0o2_0000; -pub const S_IFBLK: crate::mode_t = 0o6_0000; -pub const S_IFREG: crate::mode_t = 0o10_0000; -pub const S_IFLNK: crate::mode_t = 0o12_0000; -pub const S_IFSOCK: crate::mode_t = 0o14_0000; -pub const S_IFIFO: crate::mode_t = 0o1_0000; -pub const S_IRUSR: crate::mode_t = 0o0400; -pub const S_IWUSR: crate::mode_t = 0o0200; -pub const S_IXUSR: crate::mode_t = 0o0100; -pub const S_IRGRP: crate::mode_t = 0o0040; -pub const S_IWGRP: crate::mode_t = 0o0020; -pub const S_IXGRP: crate::mode_t = 0o0010; -pub const S_IROTH: crate::mode_t = 0o0004; -pub const S_IWOTH: crate::mode_t = 0o0002; -pub const S_IXOTH: crate::mode_t = 0o0001; +pub const S_BLKSIZE: mode_t = 1024; +pub const S_IREAD: mode_t = 0o0400; +pub const S_IWRITE: mode_t = 0o0200; +pub const S_IEXEC: mode_t = 0o0100; +pub const S_ENFMT: mode_t = 0o2000; +pub const S_IFMT: mode_t = 0o17_0000; +pub const S_IFDIR: mode_t = 0o4_0000; +pub const S_IFCHR: mode_t = 0o2_0000; +pub const S_IFBLK: mode_t = 0o6_0000; +pub const S_IFREG: mode_t = 0o10_0000; +pub const S_IFLNK: mode_t = 0o12_0000; +pub const S_IFSOCK: mode_t = 0o14_0000; +pub const S_IFIFO: mode_t = 0o1_0000; +pub const S_IRUSR: mode_t = 0o0400; +pub const S_IWUSR: mode_t = 0o0200; +pub const S_IXUSR: mode_t = 0o0100; +pub const S_IRGRP: mode_t = 0o0040; +pub const S_IWGRP: mode_t = 0o0020; +pub const S_IXGRP: mode_t = 0o0010; +pub const S_IROTH: mode_t = 0o0004; +pub const S_IWOTH: mode_t = 0o0002; +pub const S_IXOTH: mode_t = 0o0001; pub const SOL_TCP: c_int = 6; diff --git a/src/unix/nto/mod.rs b/src/unix/nto/mod.rs index e0a1c9b652102..631972b144676 100644 --- a/src/unix/nto/mod.rs +++ b/src/unix/nto/mod.rs @@ -98,7 +98,7 @@ s! { pub __old_st_mtime: crate::_Time32t, pub __old_st_atime: crate::_Time32t, pub __old_st_ctime: crate::_Time32t, - pub st_mode: crate::mode_t, + pub st_mode: mode_t, pub st_nlink: crate::nlink_t, pub st_blocksize: crate::blksize_t, pub st_nblocks: i32, @@ -563,7 +563,7 @@ s! { pub gid: crate::gid_t, pub cuid: crate::uid_t, pub cgid: crate::gid_t, - pub mode: crate::mode_t, + pub mode: mode_t, pub seq: c_uint, pub key: crate::key_t, _reserved: [c_int; 4], @@ -2175,27 +2175,27 @@ pub const S_IEXEC: mode_t = crate::S_IXUSR; pub const S_IWRITE: mode_t = crate::S_IWUSR; pub const S_IREAD: mode_t = crate::S_IRUSR; -pub const S_IFIFO: crate::mode_t = 0o1_0000; -pub const S_IFCHR: crate::mode_t = 0o2_0000; -pub const S_IFDIR: crate::mode_t = 0o4_0000; -pub const S_IFBLK: crate::mode_t = 0o6_0000; -pub const S_IFREG: crate::mode_t = 0o10_0000; -pub const S_IFLNK: crate::mode_t = 0o12_0000; -pub const S_IFSOCK: crate::mode_t = 0o14_0000; -pub const S_IFMT: crate::mode_t = 0o17_0000; - -pub const S_IXOTH: crate::mode_t = 0o0001; -pub const S_IWOTH: crate::mode_t = 0o0002; -pub const S_IROTH: crate::mode_t = 0o0004; -pub const S_IRWXO: crate::mode_t = 0o0007; -pub const S_IXGRP: crate::mode_t = 0o0010; -pub const S_IWGRP: crate::mode_t = 0o0020; -pub const S_IRGRP: crate::mode_t = 0o0040; -pub const S_IRWXG: crate::mode_t = 0o0070; -pub const S_IXUSR: crate::mode_t = 0o0100; -pub const S_IWUSR: crate::mode_t = 0o0200; -pub const S_IRUSR: crate::mode_t = 0o0400; -pub const S_IRWXU: crate::mode_t = 0o0700; +pub const S_IFIFO: mode_t = 0o1_0000; +pub const S_IFCHR: mode_t = 0o2_0000; +pub const S_IFDIR: mode_t = 0o4_0000; +pub const S_IFBLK: mode_t = 0o6_0000; +pub const S_IFREG: mode_t = 0o10_0000; +pub const S_IFLNK: mode_t = 0o12_0000; +pub const S_IFSOCK: mode_t = 0o14_0000; +pub const S_IFMT: mode_t = 0o17_0000; + +pub const S_IXOTH: mode_t = 0o0001; +pub const S_IWOTH: mode_t = 0o0002; +pub const S_IROTH: mode_t = 0o0004; +pub const S_IRWXO: mode_t = 0o0007; +pub const S_IXGRP: mode_t = 0o0010; +pub const S_IWGRP: mode_t = 0o0020; +pub const S_IRGRP: mode_t = 0o0040; +pub const S_IRWXG: mode_t = 0o0070; +pub const S_IXUSR: mode_t = 0o0100; +pub const S_IWUSR: mode_t = 0o0200; +pub const S_IRUSR: mode_t = 0o0400; +pub const S_IRWXU: mode_t = 0o0700; pub const F_LOCK: c_int = 1; pub const F_TEST: c_int = 3; @@ -2982,13 +2982,8 @@ extern "C" { pub fn fdatasync(fd: c_int) -> c_int; pub fn getpriority(which: c_int, who: crate::id_t) -> c_int; pub fn setpriority(which: c_int, who: crate::id_t, prio: c_int) -> c_int; - pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int; - pub fn mknodat( - __fd: c_int, - pathname: *const c_char, - mode: crate::mode_t, - dev: crate::dev_t, - ) -> c_int; + pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; + pub fn mknodat(__fd: c_int, pathname: *const c_char, mode: mode_t, dev: crate::dev_t) -> c_int; pub fn clock_getres(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; pub fn clock_gettime(clk_id: crate::clockid_t, tp: *mut crate::timespec) -> c_int; @@ -3361,7 +3356,7 @@ extern "C" { fd: c_int, path: *const c_char, oflag: c_int, - mode: crate::mode_t, + mode: mode_t, ) -> c_int; pub fn posix_spawn_file_actions_addclose( actions: *mut posix_spawn_file_actions_t, diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index d7ed748c08a43..d9900d1cb4fe7 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -196,7 +196,7 @@ s! { pub st_dev: crate::dev_t, pub st_ino: crate::ino_t, pub st_nlink: crate::nlink_t, - pub st_mode: crate::mode_t, + pub st_mode: mode_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, @@ -661,14 +661,14 @@ pub const SIGPWR: c_int = 30; pub const SIGSYS: c_int = 31; pub const NSIG: c_int = 32; -pub const SA_NOCLDSTOP: c_ulong = 0x00000001; -pub const SA_NOCLDWAIT: c_ulong = 0x00000002; -pub const SA_SIGINFO: c_ulong = 0x00000004; -pub const SA_RESTORER: c_ulong = 0x04000000; -pub const SA_ONSTACK: c_ulong = 0x08000000; -pub const SA_RESTART: c_ulong = 0x10000000; -pub const SA_NODEFER: c_ulong = 0x40000000; -pub const SA_RESETHAND: c_ulong = 0x80000000; +pub const SA_NOCLDWAIT: c_ulong = 0x0000_0002; +pub const SA_RESTORER: c_ulong = 0x0000_0004; // FIXME(redox): remove after relibc removes it +pub const SA_SIGINFO: c_ulong = 0x0200_0000; +pub const SA_ONSTACK: c_ulong = 0x0400_0000; +pub const SA_RESTART: c_ulong = 0x0800_0000; +pub const SA_NODEFER: c_ulong = 0x1000_0000; +pub const SA_RESETHAND: c_ulong = 0x2000_0000; +pub const SA_NOCLDSTOP: c_ulong = 0x4000_0000; // sys/file.h pub const LOCK_SH: c_int = 1; @@ -782,6 +782,7 @@ pub const MSG_PEEK: c_int = 2; pub const MSG_TRUNC: c_int = 32; pub const MSG_DONTWAIT: c_int = 64; pub const MSG_WAITALL: c_int = 256; +pub const SCM_RIGHTS: c_int = 1; pub const SHUT_RD: c_int = 0; pub const SHUT_WR: c_int = 1; pub const SHUT_RDWR: c_int = 2; @@ -1014,8 +1015,19 @@ pub const PRIO_PROCESS: c_int = 0; pub const PRIO_PGRP: c_int = 1; pub const PRIO_USER: c_int = 2; -// wait.h f! { + //sys/socket.h + pub {const} fn CMSG_ALIGN(len: size_t) -> size_t { + (len + mem::size_of::() - 1) & !(mem::size_of::() - 1) + } + pub {const} fn CMSG_LEN(length: c_uint) -> c_uint { + (CMSG_ALIGN(mem::size_of::()) + length as usize) as c_uint + } + pub {const} fn CMSG_SPACE(len: c_uint) -> c_uint { + (CMSG_ALIGN(len as size_t) + CMSG_ALIGN(mem::size_of::())) as c_uint + } + + // wait.h pub fn FD_CLR(fd: c_int, set: *mut fd_set) -> () { let fd = fd as usize; let size = mem::size_of_val(&(*set).fds_bits[0]) * 8; @@ -1228,12 +1240,9 @@ extern "C" { pub fn setrlimit(resource: c_int, rlim: *const crate::rlimit) -> c_int; // sys/socket.h - pub fn CMSG_ALIGN(len: size_t) -> size_t; pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar; pub fn CMSG_FIRSTHDR(mhdr: *const msghdr) -> *mut cmsghdr; - pub fn CMSG_LEN(len: c_uint) -> c_uint; pub fn CMSG_NXTHDR(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr; - pub fn CMSG_SPACE(len: c_uint) -> c_uint; pub fn bind( socket: c_int, address: *const crate::sockaddr, @@ -1262,18 +1271,8 @@ extern "C" { pub fn futimens(fd: c_int, times: *const crate::timespec) -> c_int; // sys/uio.h - pub fn preadv( - fd: c_int, - iov: *const crate::iovec, - iovcnt: c_int, - offset: off_t, - ) -> ssize_t; - pub fn pwritev( - fd: c_int, - iov: *const crate::iovec, - iovcnt: c_int, - offset: off_t, - ) -> ssize_t; + pub fn preadv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t; + pub fn pwritev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int, offset: off_t) -> ssize_t; pub fn readv(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t; pub fn writev(fd: c_int, iov: *const crate::iovec, iovcnt: c_int) -> ssize_t; diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index 3ddde8da0c407..652d5263a5fd0 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -96,7 +96,7 @@ s! { pub gid: crate::gid_t, pub cuid: crate::uid_t, pub cgid: crate::gid_t, - pub mode: crate::mode_t, + pub mode: mode_t, pub seq: c_uint, pub key: crate::key_t, } @@ -328,7 +328,7 @@ s! { pub struct stat { pub st_dev: crate::dev_t, pub st_ino: crate::ino_t, - pub st_mode: crate::mode_t, + pub st_mode: mode_t, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, @@ -2648,9 +2648,8 @@ extern "C" { pub fn getpriority(which: c_int, who: c_int) -> c_int; pub fn setpriority(which: c_int, who: c_int, prio: c_int) -> c_int; - pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t, dev: dev_t) - -> c_int; - pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int; + pub fn mknodat(dirfd: c_int, pathname: *const c_char, mode: mode_t, dev: dev_t) -> c_int; + pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; pub fn sethostname(name: *const c_char, len: c_int) -> c_int; pub fn if_nameindex() -> *mut if_nameindex; pub fn if_freenameindex(ptr: *mut if_nameindex); @@ -2727,7 +2726,7 @@ extern "C" { fildes: c_int, path: *const c_char, oflag: c_int, - mode: crate::mode_t, + mode: mode_t, ) -> c_int; pub fn posix_spawn_file_actions_addclose( file_actions: *mut posix_spawn_file_actions_t, @@ -2810,7 +2809,7 @@ extern "C" { pub fn shmget(key: key_t, size: size_t, shmflg: c_int) -> c_int; - pub fn shm_open(name: *const c_char, oflag: c_int, mode: crate::mode_t) -> c_int; + pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int; pub fn shm_unlink(name: *const c_char) -> c_int; pub fn seekdir(dirp: *mut crate::DIR, loc: c_long); diff --git a/src/unix/solarish/x86_64.rs b/src/unix/solarish/x86_64.rs index 4deaac0fc1718..2f82d244863aa 100644 --- a/src/unix/solarish/x86_64.rs +++ b/src/unix/solarish/x86_64.rs @@ -91,7 +91,9 @@ s_no_extra_traits! { #[cfg(target_os = "solaris")] pub uc_xrs: solaris::xrs_t, #[cfg(target_os = "solaris")] - pub uc_filler: [c_long; 3], + pub uc_lwpid: c_uint, + #[cfg(target_os = "solaris")] + pub uc_filler: [c_long; 2], } } diff --git a/src/vxworks/mod.rs b/src/vxworks/mod.rs index 3a44adc7ea5b0..cdca84e471e55 100644 --- a/src/vxworks/mod.rs +++ b/src/vxworks/mod.rs @@ -220,7 +220,7 @@ s! { pub struct stat { pub st_dev: crate::dev_t, pub st_ino: crate::ino_t, - pub st_mode: crate::mode_t, + pub st_mode: mode_t, pub st_nlink: crate::nlink_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, @@ -745,6 +745,7 @@ pub const S_taskLib_ILLEGAL_PRIORITY: c_int = taskErrorBase + 0x0068; // FIXME(vxworks): could also be useful for TASK_DESC type pub const VX_TASK_NAME_LENGTH: c_int = 31; +pub const VX_TASK_RENAME_LENGTH: c_int = 16; // semLibCommon.h pub const S_semLib_INVALID_STATE: c_int = semErrorBase + 0x0065; @@ -806,6 +807,9 @@ pub const S_IWOTH: c_int = 0o0002; pub const S_IXOTH: c_int = 0o0001; pub const S_IRWXO: c_int = 0o0007; +pub const UTIME_OMIT: c_long = 0x3ffffffe; +pub const UTIME_NOW: c_long = 0x3fffffff; + // socket.h pub const SOL_SOCKET: c_int = 0xffff; pub const SOMAXCONN: c_int = 128; @@ -1299,7 +1303,7 @@ extern "C" { pub fn msync(addr: *mut c_void, len: size_t, flags: c_int) -> c_int; pub fn truncate(path: *const c_char, length: off_t) -> c_int; - pub fn shm_open(name: *const c_char, oflag: c_int, mode: crate::mode_t) -> c_int; + pub fn shm_open(name: *const c_char, oflag: c_int, mode: mode_t) -> c_int; pub fn shm_unlink(name: *const c_char) -> c_int; pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut c_void) -> c_int; @@ -1810,13 +1814,13 @@ extern "C" { pub fn rmdir(path: *const c_char) -> c_int; // stat.h - pub fn mkdir(dirName: *const c_char, mode: crate::mode_t) -> c_int; + pub fn mkdir(dirName: *const c_char, mode: mode_t) -> c_int; // stat.h - pub fn chmod(path: *const c_char, mode: crate::mode_t) -> c_int; + pub fn chmod(path: *const c_char, mode: mode_t) -> c_int; // stat.h - pub fn fchmod(attr1: c_int, attr2: crate::mode_t) -> c_int; + pub fn fchmod(attr1: c_int, attr2: mode_t) -> c_int; // unistd.h pub fn fsync(fd: c_int) -> c_int; diff --git a/src/wasi/mod.rs b/src/wasi/mod.rs index 035ff8958ab20..61061918c05fc 100644 --- a/src/wasi/mod.rs +++ b/src/wasi/mod.rs @@ -653,7 +653,7 @@ extern "C" { newpath: *const c_char, flags: c_int, ) -> c_int; - pub fn mkdirat(dirfd: c_int, pathname: *const c_char, mode: crate::mode_t) -> c_int; + pub fn mkdirat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; pub fn readlinkat( dirfd: c_int, pathname: *const c_char, diff --git a/src/windows/mod.rs b/src/windows/mod.rs index 06cab0e5037a3..8490b709bae9e 100644 --- a/src/windows/mod.rs +++ b/src/windows/mod.rs @@ -382,12 +382,25 @@ extern "C" { pub fn signal(signum: c_int, handler: sighandler_t) -> sighandler_t; pub fn raise(signum: c_int) -> c_int; + pub fn clock() -> clock_t; + pub fn ctime(sourceTime: *const time_t) -> *mut c_char; + pub fn difftime(timeEnd: time_t, timeStart: time_t) -> c_double; #[link_name = "_gmtime64_s"] pub fn gmtime_s(destTime: *mut tm, srcTime: *const time_t) -> c_int; + #[link_name = "_get_daylight"] + pub fn get_daylight(hours: *mut c_int) -> errno_t; + #[link_name = "_get_dstbias"] + pub fn get_dstbias(seconds: *mut c_long) -> errno_t; + #[link_name = "_get_timezone"] + pub fn get_timezone(seconds: *mut c_long) -> errno_t; + #[link_name = "_get_tzname"] + pub fn get_tzname(p_return_value: *mut size_t, time_zone_name: *mut c_char, size_in_bytes: size_t, index: c_int) -> errno_t; #[link_name = "_localtime64_s"] pub fn localtime_s(tmDest: *mut tm, sourceTime: *const time_t) -> crate::errno_t; #[link_name = "_time64"] pub fn time(destTime: *mut time_t) -> time_t; + #[link_name = "_tzset"] + pub fn tzset(); #[link_name = "_chmod"] pub fn chmod(path: *const c_char, mode: c_int) -> c_int; #[link_name = "_wchmod"] diff --git a/triagebot.toml b/triagebot.toml index f42f244bd6f85..fe3a00af581f7 100644 --- a/triagebot.toml +++ b/triagebot.toml @@ -11,10 +11,11 @@ allow-unauthenticated = [ warn_non_default_branch.enable = true contributing_url = "https://github.com/rust-lang/libc/blob/HEAD/CONTRIBUTING.md" -[assign.owners] -"*" = [ - "@tgross35", -] +# Ensure issue links link to this repo +[issue-links] + +# Prevents mentions in commits to avoid users being spammed +[no-mentions] [autolabel."A-CI"] trigger_files = [