From 651bdf22d9a91547b07d610d5f9e51b4d4a8ed24 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 12 Mar 2025 18:15:07 +0100 Subject: [PATCH 1/8] Add missing `filedesc` and `fdescenttbl` in FreeBSD [ edited the message to be more specific - Trevor ] (backport ) (cherry picked from commit a23e0e0bc99dae996491249c36b163dea13427eb) --- .../bsd/freebsdlike/freebsd/freebsd11/mod.rs | 3 +- .../bsd/freebsdlike/freebsd/freebsd12/mod.rs | 3 +- .../bsd/freebsdlike/freebsd/freebsd13/mod.rs | 3 +- .../bsd/freebsdlike/freebsd/freebsd14/mod.rs | 3 +- .../bsd/freebsdlike/freebsd/freebsd15/mod.rs | 3 +- src/unix/bsd/freebsdlike/freebsd/mod.rs | 41 +++++++++++++++++++ 6 files changed, 46 insertions(+), 10 deletions(-) diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs index 87ddbcc4376c8..584644701aea2 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd11/mod.rs @@ -51,9 +51,8 @@ s! { // This is normally "struct vnode". /// Pointer to executable file. pub ki_textvp: *mut c_void, - // This is normally "struct filedesc". /// Pointer to open file info. - pub ki_fd: *mut c_void, + pub ki_fd: *mut crate::filedesc, // This is normally "struct vmspace". /// Pointer to kernel vmspace struct. pub ki_vmspace: *mut c_void, diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs index 6c2f586195dc5..21062e50afcbd 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd12/mod.rs @@ -59,9 +59,8 @@ s! { // This is normally "struct vnode". /// Pointer to executable file. pub ki_textvp: *mut c_void, - // This is normally "struct filedesc". /// Pointer to open file info. - pub ki_fd: *mut c_void, + pub ki_fd: *mut crate::filedesc, // This is normally "struct vmspace". /// Pointer to kernel vmspace struct. pub ki_vmspace: *mut c_void, diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs index cf507e66b38c0..505d2d1591652 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd13/mod.rs @@ -69,9 +69,8 @@ s! { // This is normally "struct vnode". /// Pointer to executable file. pub ki_textvp: *mut c_void, - // This is normally "struct filedesc". /// Pointer to open file info. - pub ki_fd: *mut c_void, + pub ki_fd: *mut crate::filedesc, // This is normally "struct vmspace". /// Pointer to kernel vmspace struct. pub ki_vmspace: *mut c_void, diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs index 0a05ca9fad3e8..44a3656d674f7 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs @@ -69,9 +69,8 @@ s! { // This is normally "struct vnode". /// Pointer to executable file. pub ki_textvp: *mut c_void, - // This is normally "struct filedesc". /// Pointer to open file info. - pub ki_fd: *mut c_void, + pub ki_fd: *mut crate::filedesc, // This is normally "struct vmspace". /// Pointer to kernel vmspace struct. pub ki_vmspace: *mut c_void, diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs index 2fe39a3acea2c..29c9c0cb94fff 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd15/mod.rs @@ -69,9 +69,8 @@ s! { // This is normally "struct vnode". /// Pointer to executable file. pub ki_textvp: *mut c_void, - // This is normally "struct filedesc". /// Pointer to open file info. - pub ki_fd: *mut c_void, + pub ki_fd: *mut crate::filedesc, // This is normally "struct vmspace". /// Pointer to kernel vmspace struct. pub ki_vmspace: *mut c_void, diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 375c51b3de669..11830db22ab5a 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -1357,6 +1357,47 @@ s! { pub strchange_instrms: u16, pub strchange_outstrms: u16, } + + pub struct filedesc { + pub fd_files: *mut fdescenttbl, + pub fd_map: *mut c_ulong, + pub fd_freefile: c_int, + pub fd_refcnt: c_int, + pub fd_holdcnt: c_int, + fd_sx: sx, + fd_kqlist: kqlist, + pub fd_holdleaderscount: c_int, + pub fd_holdleaderswakeup: c_int, + } + + pub struct fdescenttbl { + pub fdt_nfiles: c_int, + fdt_ofiles: [*mut c_void; 0], + } + + // FIXME: Should be private. + #[doc(hidden)] + pub struct sx { + lock_object: lock_object, + sx_lock: crate::uintptr_t, + } + + // FIXME: Should be private. + #[doc(hidden)] + pub struct lock_object { + lo_name: *const c_char, + lo_flags: c_uint, + lo_data: c_uint, + // This is normally `struct witness`. + lo_witness: *mut c_void, + } + + // FIXME: Should be private. + #[doc(hidden)] + pub struct kqlist { + tqh_first: *mut c_void, + tqh_last: *mut *mut c_void, + } } s_no_extra_traits! { From 087820baff4889115bbfca2a64f769bfe3255423 Mon Sep 17 00:00:00 2001 From: Berrysoft Date: Thu, 10 Apr 2025 14:43:28 +0800 Subject: [PATCH 2/8] cygwin: posix_spawn_file_actions_add[f]chdir[_np] (backport ) (cherry picked from commit e46d0c7e74701ea90fd1a8f562620aa5b26c97ad) --- libc-test/semver/cygwin.txt | 4 ++++ src/unix/cygwin/mod.rs | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/libc-test/semver/cygwin.txt b/libc-test/semver/cygwin.txt index 2b0b827674fdf..99e822ca62d18 100644 --- a/libc-test/semver/cygwin.txt +++ b/libc-test/semver/cygwin.txt @@ -734,8 +734,12 @@ posix_fadvise posix_fallocate posix_madvise posix_spawn +posix_spawn_file_actions_addchdir +posix_spawn_file_actions_addchdir_np posix_spawn_file_actions_addclose posix_spawn_file_actions_adddup2 +posix_spawn_file_actions_addfchdir +posix_spawn_file_actions_addfchdir_np posix_spawn_file_actions_addopen posix_spawn_file_actions_destroy posix_spawn_file_actions_init diff --git a/src/unix/cygwin/mod.rs b/src/unix/cygwin/mod.rs index 9fe63985f1180..c2fda6768b2b0 100644 --- a/src/unix/cygwin/mod.rs +++ b/src/unix/cygwin/mod.rs @@ -2479,6 +2479,22 @@ extern "C" { fd: c_int, newfd: c_int, ) -> c_int; + pub fn posix_spawn_file_actions_addchdir( + actions: *mut crate::posix_spawn_file_actions_t, + path: *const c_char, + ) -> c_int; + pub fn posix_spawn_file_actions_addfchdir( + actions: *mut crate::posix_spawn_file_actions_t, + fd: c_int, + ) -> c_int; + pub fn posix_spawn_file_actions_addchdir_np( + actions: *mut crate::posix_spawn_file_actions_t, + path: *const c_char, + ) -> c_int; + pub fn posix_spawn_file_actions_addfchdir_np( + actions: *mut crate::posix_spawn_file_actions_t, + fd: c_int, + ) -> c_int; pub fn forkpty( amaster: *mut c_int, From abf01706808828e82f4132113ecfeee4fe6c0d46 Mon Sep 17 00:00:00 2001 From: Florian Bartels Date: Mon, 2 Dec 2024 10:44:14 +0100 Subject: [PATCH 3/8] Add support for alternative QNX Neutrino network stack `io-sock` Signed-off-by: Florian Bartels (backport ) (cherry picked from commit f5bfa9f86d0d7d6813ac04c17964fc5a11c8fedc) --- libc-test/build.rs | 20 +++ src/unix/mod.rs | 23 +++- src/unix/nto/mod.rs | 291 +++++++++++++++++++++++++++++--------------- 3 files changed, 237 insertions(+), 97 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index c84bddca80960..0bde80b811119 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -3307,6 +3307,20 @@ fn test_neutrino(target: &str) { assert!(target.contains("nto-qnx")); let mut cfg = ctest_cfg(); + if target.ends_with("_iosock") { + let qnx_target_val = std::env::var("QNX_TARGET") + .unwrap_or_else(|_| "QNX_TARGET_not_set_please_source_qnxsdp".into()); + + cfg.include(qnx_target_val + "/usr/include/io-sock"); + headers! { cfg: + "io-sock.h", + "sys/types.h", + "sys/socket.h", + "sys/sysctl.h", + "net/if.h", + "net/if_arp.h" + } + } headers! { cfg: "ctype.h", @@ -3464,6 +3478,9 @@ fn test_neutrino(target: &str) { // Does not exist in Neutrino "locale_t" => true, + // FIXME: "'__uint128' undeclared" in C + "__uint128" => true, + _ => false, } }); @@ -3527,6 +3544,9 @@ fn test_neutrino(target: &str) { // stack unwinding bug. "__my_thread_exit" => true, + // Wrong const-ness + "dl_iterate_phdr" => true, + _ => false, } }); diff --git a/src/unix/mod.rs b/src/unix/mod.rs index fa88de25f4aa2..433eeec950965 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -334,7 +334,13 @@ pub const ATF_PERM: c_int = 0x04; pub const ATF_PUBL: c_int = 0x08; pub const ATF_USETRAILERS: c_int = 0x10; -pub const FNM_PERIOD: c_int = 1 << 2; +cfg_if! { + if #[cfg(target_os = "nto")] { + pub const FNM_PERIOD: c_int = 1 << 1; + } else { + pub const FNM_PERIOD: c_int = 1 << 2; + } +} pub const FNM_NOMATCH: c_int = 1; cfg_if! { @@ -354,9 +360,22 @@ cfg_if! { target_os = "cygwin", ))] { pub const FNM_PATHNAME: c_int = 1 << 1; - pub const FNM_NOESCAPE: c_int = 1 << 0; } else { pub const FNM_PATHNAME: c_int = 1 << 0; + } +} + +cfg_if! { + if #[cfg(any( + target_os = "macos", + target_os = "freebsd", + target_os = "android", + target_os = "openbsd", + ))] { + pub const FNM_NOESCAPE: c_int = 1 << 0; + } else if #[cfg(target_os = "nto")] { + pub const FNM_NOESCAPE: c_int = 1 << 2; + } else { pub const FNM_NOESCAPE: c_int = 1 << 1; } } diff --git a/src/unix/nto/mod.rs b/src/unix/nto/mod.rs index c1457d631acf1..e0a1c9b652102 100644 --- a/src/unix/nto/mod.rs +++ b/src/unix/nto/mod.rs @@ -114,7 +114,7 @@ s! { pub imr_interface: in_addr, } - #[repr(packed)] + #[cfg_attr(any(target_env = "nto71", target_env = "nto70"), repr(packed))] pub struct in_addr { pub s_addr: crate::in_addr_t, } @@ -125,6 +125,7 @@ s! { pub sa_data: [c_char; 14], } + #[cfg(not(target_env = "nto71_iosock"))] pub struct sockaddr_in { pub sin_len: u8, pub sin_family: sa_family_t, @@ -133,6 +134,15 @@ s! { pub sin_zero: [i8; 8], } + #[cfg(target_env = "nto71_iosock")] + pub struct sockaddr_in { + pub sin_len: u8, + pub sin_family: sa_family_t, + pub sin_port: crate::in_port_t, + pub sin_addr: crate::in_addr, + pub sin_zero: [c_char; 8], + } + pub struct sockaddr_in6 { pub sin6_len: u8, pub sin6_family: sa_family_t, @@ -234,6 +244,8 @@ s! { pub _Reserved: [*mut c_char; 8], } + // Does not exist in io-sock + #[cfg(not(target_env = "nto71_iosock"))] pub struct in_pktinfo { pub ipi_addr: crate::in_addr, pub ipi_ifindex: c_uint, @@ -255,7 +267,7 @@ s! { pub arp_flags: c_int, } - #[repr(packed)] + #[cfg_attr(any(target_env = "nto71", target_env = "nto70"), repr(packed))] pub struct arphdr { pub ar_hrd: u16, pub ar_pro: u16, @@ -264,11 +276,18 @@ s! { pub ar_op: u16, } + #[cfg(not(target_env = "nto71_iosock"))] pub struct mmsghdr { pub msg_hdr: crate::msghdr, pub msg_len: c_uint, } + #[cfg(target_env = "nto71_iosock")] + pub struct mmsghdr { + pub msg_hdr: crate::msghdr, + pub msg_len: ssize_t, + } + #[repr(align(8))] pub struct siginfo_t { pub si_signo: c_int, @@ -592,6 +611,7 @@ s! { pub bf_insns: *mut crate::bpf_insn, } + #[cfg(not(target_env = "nto71_iosock"))] pub struct bpf_stat { pub bs_recv: u64, pub bs_drop: u64, @@ -599,6 +619,12 @@ s! { bs_padding: [u64; 13], } + #[cfg(target_env = "nto71_iosock")] + pub struct bpf_stat { + pub bs_recv: c_uint, + pub bs_drop: c_uint, + } + pub struct bpf_version { pub bv_major: c_ushort, pub bv_minor: c_ushort, @@ -623,6 +649,8 @@ s! { pub bfl_list: *mut c_uint, } + // Does not exist in io-sock + #[cfg(not(target_env = "nto71_iosock"))] pub struct unpcbid { pub unp_pid: crate::pid_t, pub unp_euid: crate::uid_t, @@ -723,6 +751,7 @@ s_no_extra_traits! { msg_pad4: [c_long; 4], } + #[cfg(not(target_env = "nto71_iosock"))] pub struct sockaddr_dl { pub sdl_len: c_uchar, pub sdl_family: crate::sa_family_t, @@ -734,6 +763,18 @@ s_no_extra_traits! { pub sdl_data: [c_char; 12], } + #[cfg(target_env = "nto71_iosock")] + pub struct sockaddr_dl { + pub sdl_len: c_uchar, + pub sdl_family: c_uchar, + pub sdl_index: c_ushort, + pub sdl_type: c_uchar, + pub sdl_nlen: c_uchar, + pub sdl_alen: c_uchar, + pub sdl_slen: c_uchar, + pub sdl_data: [c_char; 46], + } + pub struct sync_t { __u: c_uint, // union pub __owner: c_uint, @@ -1232,7 +1273,122 @@ pub const MS_SYNC: c_int = 2; pub const SCM_RIGHTS: c_int = 0x01; pub const SCM_TIMESTAMP: c_int = 0x02; -pub const SCM_CREDS: c_int = 0x04; +cfg_if! { + if #[cfg(not(target_env = "nto71_iosock"))] { + pub const SCM_CREDS: c_int = 0x04; + pub const IFF_NOTRAILERS: c_int = 0x00000020; + pub const AF_INET6: c_int = 24; + pub const AF_BLUETOOTH: c_int = 31; + pub const pseudo_AF_KEY: c_int = 29; + pub const MSG_NOSIGNAL: c_int = 0x0800; + pub const MSG_WAITFORONE: c_int = 0x2000; + pub const IP_IPSEC_POLICY_COMPAT: c_int = 22; + pub const IP_PKTINFO: c_int = 25; + pub const IPPROTO_DIVERT: c_int = 259; + pub const IPV6_IPSEC_POLICY_COMPAT: c_int = 28; + pub const TCP_KEEPALIVE: c_int = 0x04; + pub const ARPHRD_ARCNET: u16 = 7; + pub const SO_BINDTODEVICE: c_int = 0x0800; + pub const EAI_NODATA: c_int = 7; + pub const IPTOS_ECN_NOT_ECT: u8 = 0x00; + pub const RTF_BROADCAST: u32 = 0x80000; + pub const UDP_ENCAP: c_int = 100; + pub const HW_IOSTATS: c_int = 9; + pub const HW_MACHINE_ARCH: c_int = 10; + pub const HW_ALIGNBYTES: c_int = 11; + pub const HW_CNMAGIC: c_int = 12; + pub const HW_PHYSMEM64: c_int = 13; + pub const HW_USERMEM64: c_int = 14; + pub const HW_IOSTATNAMES: c_int = 15; + pub const HW_MAXID: c_int = 15; + pub const CTL_UNSPEC: c_int = 0; + pub const CTL_QNX: c_int = 9; + pub const CTL_PROC: c_int = 10; + pub const CTL_VENDOR: c_int = 11; + pub const CTL_EMUL: c_int = 12; + pub const CTL_SECURITY: c_int = 13; + pub const CTL_MAXID: c_int = 14; + pub const AF_ARP: c_int = 28; + pub const AF_IEEE80211: c_int = 32; + pub const AF_NATM: c_int = 27; + pub const AF_NS: c_int = 6; + pub const BIOCGDLTLIST: c_int = -1072676233; + pub const BIOCGETIF: c_int = 1083196011; + pub const BIOCGSEESENT: c_int = 1074020984; + pub const BIOCGSTATS: c_int = 1082147439; + pub const BIOCSDLT: c_int = -2147204490; + pub const BIOCSETIF: c_int = -2138029460; + pub const BIOCSSEESENT: c_int = -2147204487; + pub const FIONSPACE: c_int = 1074030200; + pub const FIONWRITE: c_int = 1074030201; + pub const IFF_ACCEPTRTADV: c_int = 0x40000000; + pub const IFF_IP6FORWARDING: c_int = 0x20000000; + pub const IFF_SHIM: c_int = 0x80000000; + pub const KERN_ARND: c_int = 81; + pub const KERN_IOV_MAX: c_int = 38; + pub const KERN_LOGSIGEXIT: c_int = 46; + pub const KERN_MAXID: c_int = 83; + pub const KERN_PROC_ARGS: c_int = 48; + pub const KERN_PROC_ENV: c_int = 3; + pub const KERN_PROC_GID: c_int = 7; + pub const KERN_PROC_RGID: c_int = 8; + pub const LOCAL_CONNWAIT: c_int = 0x0002; + pub const LOCAL_CREDS: c_int = 0x0001; + pub const LOCAL_PEEREID: c_int = 0x0003; + pub const MSG_NOTIFICATION: c_int = 0x0400; + pub const NET_RT_IFLIST: c_int = 4; + pub const NI_NUMERICSCOPE: c_int = 0x00000040; + pub const PF_ARP: c_int = 28; + pub const PF_NATM: c_int = 27; + pub const pseudo_AF_HDRCMPLT: c_int = 30; + pub const SIOCGIFADDR: c_int = -1064277727; + pub const SO_FIB: c_int = 0x100a; + pub const SO_TXPRIO: c_int = 0x100b; + pub const SO_SETFIB: c_int = 0x100a; + pub const SO_VLANPRIO: c_int = 0x100c; + pub const USER_ATEXIT_MAX: c_int = 21; + pub const USER_MAXID: c_int = 22; + pub const SO_OVERFLOWED: c_int = 0x1009; + } else { + pub const SCM_CREDS: c_int = 0x03; + pub const AF_INET6: c_int = 28; + pub const AF_BLUETOOTH: c_int = 36; + pub const pseudo_AF_KEY: c_int = 27; + pub const MSG_NOSIGNAL: c_int = 0x20000; + pub const MSG_WAITFORONE: c_int = 0x00080000; + pub const IPPROTO_DIVERT: c_int = 258; + pub const RTF_BROADCAST: u32 = 0x400000; + pub const UDP_ENCAP: c_int = 1; + pub const HW_MACHINE_ARCH: c_int = 11; + pub const AF_ARP: c_int = 35; + pub const AF_IEEE80211: c_int = 37; + pub const AF_NATM: c_int = 29; + pub const BIOCGDLTLIST: c_ulong = 0xffffffffc0104279; + pub const BIOCGETIF: c_int = 0x4020426b; + pub const BIOCGSEESENT: c_int = 0x40044276; + pub const BIOCGSTATS: c_int = 0x4008426f; + pub const BIOCSDLT: c_int = 0x80044278; + pub const BIOCSETIF: c_int = 0x8020426c; + pub const BIOCSSEESENT: c_int = 0x80044277; + pub const KERN_ARND: c_int = 37; + pub const KERN_IOV_MAX: c_int = 35; + pub const KERN_LOGSIGEXIT: c_int = 34; + pub const KERN_PROC_ARGS: c_int = 7; + pub const KERN_PROC_ENV: c_int = 35; + pub const KERN_PROC_GID: c_int = 11; + pub const KERN_PROC_RGID: c_int = 10; + pub const LOCAL_CONNWAIT: c_int = 4; + pub const LOCAL_CREDS: c_int = 2; + pub const MSG_NOTIFICATION: c_int = 0x00002000; + pub const NET_RT_IFLIST: c_int = 3; + pub const NI_NUMERICSCOPE: c_int = 0x00000020; + pub const PF_ARP: c_int = AF_ARP; + pub const PF_NATM: c_int = AF_NATM; + pub const pseudo_AF_HDRCMPLT: c_int = 31; + pub const SIOCGIFADDR: c_int = 0xc0206921; + pub const SO_SETFIB: c_int = 0x1014; + } +} pub const MAP_TYPE: c_int = 0x3; @@ -1241,7 +1397,6 @@ pub const IFF_BROADCAST: c_int = 0x00000002; pub const IFF_DEBUG: c_int = 0x00000004; pub const IFF_LOOPBACK: c_int = 0x00000008; pub const IFF_POINTOPOINT: c_int = 0x00000010; -pub const IFF_NOTRAILERS: c_int = 0x00000020; pub const IFF_RUNNING: c_int = 0x00000040; pub const IFF_NOARP: c_int = 0x00000080; pub const IFF_PROMISC: c_int = 0x00000100; @@ -1254,10 +1409,9 @@ pub const AF_LOCAL: c_int = 1; pub const AF_INET: c_int = 2; pub const AF_IPX: c_int = 23; pub const AF_APPLETALK: c_int = 16; -pub const AF_INET6: c_int = 24; pub const AF_ROUTE: c_int = 17; pub const AF_SNA: c_int = 11; -pub const AF_BLUETOOTH: c_int = 31; + pub const AF_ISDN: c_int = 26; pub const PF_UNSPEC: c_int = AF_UNSPEC; @@ -1267,7 +1421,6 @@ pub const PF_INET: c_int = AF_INET; pub const PF_IPX: c_int = AF_IPX; pub const PF_APPLETALK: c_int = AF_APPLETALK; pub const PF_INET6: c_int = AF_INET6; -pub const pseudo_AF_KEY: c_int = 29; pub const PF_KEY: c_int = pseudo_AF_KEY; pub const PF_ROUTE: c_int = AF_ROUTE; pub const PF_SNA: c_int = AF_SNA; @@ -1285,8 +1438,6 @@ pub const MSG_TRUNC: c_int = 0x0010; pub const MSG_DONTWAIT: c_int = 0x0080; pub const MSG_EOR: c_int = 0x0008; pub const MSG_WAITALL: c_int = 0x0040; -pub const MSG_NOSIGNAL: c_int = 0x0800; -pub const MSG_WAITFORONE: c_int = 0x2000; pub const IP_TOS: c_int = 3; pub const IP_TTL: c_int = 4; @@ -1294,8 +1445,6 @@ pub const IP_HDRINCL: c_int = 2; pub const IP_OPTIONS: c_int = 1; pub const IP_RECVOPTS: c_int = 5; pub const IP_RETOPTS: c_int = 8; -pub const IP_PKTINFO: c_int = 25; -pub const IP_IPSEC_POLICY_COMPAT: c_int = 22; pub const IP_MULTICAST_IF: c_int = 9; pub const IP_MULTICAST_TTL: c_int = 10; pub const IP_MULTICAST_LOOP: c_int = 11; @@ -1325,7 +1474,6 @@ pub const IPPROTO_SCTP: c_int = 132; pub const IPPROTO_RAW: c_int = 255; pub const IPPROTO_MAX: c_int = 256; pub const IPPROTO_CARP: c_int = 112; -pub const IPPROTO_DIVERT: c_int = 259; pub const IPPROTO_DONE: c_int = 257; pub const IPPROTO_EON: c_int = 80; pub const IPPROTO_ETHERIP: c_int = 97; @@ -1343,7 +1491,6 @@ pub const IPV6_JOIN_GROUP: c_int = 12; pub const IPV6_LEAVE_GROUP: c_int = 13; pub const IPV6_CHECKSUM: c_int = 26; pub const IPV6_V6ONLY: c_int = 27; -pub const IPV6_IPSEC_POLICY_COMPAT: c_int = 28; pub const IPV6_RTHDRDSTOPTS: c_int = 35; pub const IPV6_RECVPKTINFO: c_int = 36; pub const IPV6_RECVHOPLIMIT: c_int = 37; @@ -1364,7 +1511,6 @@ pub const IPV6_DONTFRAG: c_int = 62; pub const TCP_NODELAY: c_int = 0x01; pub const TCP_MAXSEG: c_int = 0x02; pub const TCP_MD5SIG: c_int = 0x10; -pub const TCP_KEEPALIVE: c_int = 0x04; pub const SHUT_RD: c_int = 0; pub const SHUT_WR: c_int = 1; @@ -1514,7 +1660,6 @@ pub const MAXTTL: u8 = 255; pub const ARPHRD_ETHER: u16 = 1; pub const ARPHRD_IEEE802: u16 = 6; -pub const ARPHRD_ARCNET: u16 = 7; pub const ARPHRD_IEEE1394: u16 = 24; pub const SOL_SOCKET: c_int = 0xffff; @@ -1535,7 +1680,6 @@ pub const SO_RCVLOWAT: c_int = 0x1004; pub const SO_SNDLOWAT: c_int = 0x1003; pub const SO_RCVTIMEO: c_int = 0x1006; pub const SO_SNDTIMEO: c_int = 0x1005; -pub const SO_BINDTODEVICE: c_int = 0x0800; pub const SO_TIMESTAMP: c_int = 0x0400; pub const SO_ACCEPTCONN: c_int = 0x0002; @@ -1581,7 +1725,6 @@ pub const EAI_BADFLAGS: c_int = 3; pub const EAI_NONAME: c_int = 8; pub const EAI_AGAIN: c_int = 2; pub const EAI_FAIL: c_int = 4; -pub const EAI_NODATA: c_int = 7; pub const EAI_FAMILY: c_int = 5; pub const EAI_SOCKTYPE: c_int = 10; pub const EAI_SERVICE: c_int = 9; @@ -1616,8 +1759,6 @@ pub const POSIX_SPAWN_SETSIGMASK: c_int = 0x00000002; pub const POSIX_SPAWN_SETSCHEDPARAM: c_int = 0x00000400; pub const POSIX_SPAWN_SETSCHEDULER: c_int = 0x00000040; -pub const IPTOS_ECN_NOT_ECT: u8 = 0x00; - pub const RTF_UP: c_ushort = 0x0001; pub const RTF_GATEWAY: c_ushort = 0x0002; @@ -1627,14 +1768,11 @@ pub const RTF_MODIFIED: c_ushort = 0x0020; pub const RTF_REJECT: c_ushort = 0x0008; pub const RTF_STATIC: c_ushort = 0x0800; pub const RTF_XRESOLVE: c_ushort = 0x0200; -pub const RTF_BROADCAST: u32 = 0x80000; pub const RTM_NEWADDR: u16 = 0xc; pub const RTM_DELADDR: u16 = 0xd; pub const RTA_DST: c_ushort = 0x1; pub const RTA_GATEWAY: c_ushort = 0x2; -pub const UDP_ENCAP: c_int = 100; - pub const IN_ACCESS: u32 = 0x00000001; pub const IN_MODIFY: u32 = 0x00000002; pub const IN_ATTRIB: u32 = 0x00000004; @@ -2268,16 +2406,6 @@ pub const HW_PHYSMEM: c_int = 5; pub const HW_USERMEM: c_int = 6; pub const HW_PAGESIZE: c_int = 7; pub const HW_DISKNAMES: c_int = 8; -pub const HW_IOSTATS: c_int = 9; -pub const HW_MACHINE_ARCH: c_int = 10; -pub const HW_ALIGNBYTES: c_int = 11; -pub const HW_CNMAGIC: c_int = 12; -pub const HW_PHYSMEM64: c_int = 13; -pub const HW_USERMEM64: c_int = 14; -pub const HW_IOSTATNAMES: c_int = 15; -pub const HW_MAXID: c_int = 15; - -pub const CTL_UNSPEC: c_int = 0; pub const CTL_KERN: c_int = 1; pub const CTL_VM: c_int = 2; pub const CTL_VFS: c_int = 3; @@ -2286,12 +2414,6 @@ pub const CTL_DEBUG: c_int = 5; pub const CTL_HW: c_int = 6; pub const CTL_MACHDEP: c_int = 7; pub const CTL_USER: c_int = 8; -pub const CTL_QNX: c_int = 9; -pub const CTL_PROC: c_int = 10; -pub const CTL_VENDOR: c_int = 11; -pub const CTL_EMUL: c_int = 12; -pub const CTL_SECURITY: c_int = 13; -pub const CTL_MAXID: c_int = 14; pub const DAY_1: crate::nl_item = 8; pub const DAY_2: crate::nl_item = 9; @@ -2335,7 +2457,6 @@ pub const ABMON_10: crate::nl_item = 43; pub const ABMON_11: crate::nl_item = 44; pub const ABMON_12: crate::nl_item = 45; -pub const AF_ARP: c_int = 28; pub const AF_CCITT: c_int = 10; pub const AF_CHAOS: c_int = 5; pub const AF_CNT: c_int = 21; @@ -2346,13 +2467,10 @@ pub const AF_DLI: c_int = 13; pub const AF_E164: c_int = 26; pub const AF_ECMA: c_int = 8; pub const AF_HYLINK: c_int = 15; -pub const AF_IEEE80211: c_int = 32; pub const AF_IMPLINK: c_int = 3; pub const AF_ISO: c_int = 7; pub const AF_LAT: c_int = 14; pub const AF_LINK: c_int = 18; -pub const AF_NATM: c_int = 27; -pub const AF_NS: c_int = 6; pub const AF_OSI: c_int = 7; pub const AF_PUP: c_int = 4; pub const ALT_DIGITS: crate::nl_item = 50; @@ -2362,21 +2480,14 @@ pub const B76800: crate::speed_t = 76800; pub const BIOCFLUSH: c_int = 17000; pub const BIOCGBLEN: c_int = 1074020966; pub const BIOCGDLT: c_int = 1074020970; -pub const BIOCGDLTLIST: c_int = -1072676233; -pub const BIOCGETIF: c_int = 1083196011; pub const BIOCGHDRCMPLT: c_int = 1074020980; pub const BIOCGRTIMEOUT: c_int = 1074807406; -pub const BIOCGSEESENT: c_int = 1074020984; -pub const BIOCGSTATS: c_int = 1082147439; pub const BIOCIMMEDIATE: c_int = -2147204496; pub const BIOCPROMISC: c_int = 17001; pub const BIOCSBLEN: c_int = -1073462682; -pub const BIOCSDLT: c_int = -2147204490; pub const BIOCSETF: c_int = -2146418073; -pub const BIOCSETIF: c_int = -2138029460; pub const BIOCSHDRCMPLT: c_int = -2147204491; pub const BIOCSRTIMEOUT: c_int = -2146418067; -pub const BIOCSSEESENT: c_int = -2147204487; pub const BIOCVERSION: c_int = 1074020977; pub const BPF_ALIGNMENT: usize = mem::size_of::(); @@ -2412,18 +2523,13 @@ pub const FIOCLEX: c_int = 26113; pub const FIOGETOWN: c_int = 1074030203; pub const FIONCLEX: c_int = 26114; pub const FIONREAD: c_int = 1074030207; -pub const FIONSPACE: c_int = 1074030200; -pub const FIONWRITE: c_int = 1074030201; pub const FIOSETOWN: c_int = -2147195268; pub const F_SETOWN: c_int = 36; -pub const IFF_ACCEPTRTADV: c_int = 0x40000000; -pub const IFF_IP6FORWARDING: c_int = 0x20000000; pub const IFF_LINK0: c_int = 0x00001000; pub const IFF_LINK1: c_int = 0x00002000; pub const IFF_LINK2: c_int = 0x00004000; pub const IFF_OACTIVE: c_int = 0x00000400; -pub const IFF_SHIM: c_int = 0x80000000; pub const IFF_SIMPLEX: c_int = 0x00000800; pub const IHFLOW: tcflag_t = 0x00000001; pub const IIDLE: tcflag_t = 0x00000008; @@ -2434,17 +2540,13 @@ pub const IUCLC: tcflag_t = 0x00000200; pub const IUTF8: tcflag_t = 0x0004000; pub const KERN_ARGMAX: c_int = 8; -pub const KERN_ARND: c_int = 81; pub const KERN_BOOTTIME: c_int = 21; pub const KERN_CLOCKRATE: c_int = 12; pub const KERN_FILE: c_int = 15; pub const KERN_HOSTID: c_int = 11; pub const KERN_HOSTNAME: c_int = 10; -pub const KERN_IOV_MAX: c_int = 38; pub const KERN_JOB_CONTROL: c_int = 19; -pub const KERN_LOGSIGEXIT: c_int = 46; pub const KERN_MAXFILES: c_int = 7; -pub const KERN_MAXID: c_int = 83; pub const KERN_MAXPROC: c_int = 6; pub const KERN_MAXVNODES: c_int = 5; pub const KERN_NGROUPS: c_int = 18; @@ -2454,12 +2556,8 @@ pub const KERN_OSTYPE: c_int = 1; pub const KERN_POSIX1: c_int = 17; pub const KERN_PROC: c_int = 14; pub const KERN_PROC_ALL: c_int = 0; -pub const KERN_PROC_ARGS: c_int = 48; -pub const KERN_PROC_ENV: c_int = 3; -pub const KERN_PROC_GID: c_int = 7; pub const KERN_PROC_PGRP: c_int = 2; pub const KERN_PROC_PID: c_int = 1; -pub const KERN_PROC_RGID: c_int = 8; pub const KERN_PROC_RUID: c_int = 6; pub const KERN_PROC_SESSION: c_int = 3; pub const KERN_PROC_TTY: c_int = 4; @@ -2478,25 +2576,16 @@ pub const LC_MONETARY: c_int = 4; pub const LC_NUMERIC: c_int = 8; pub const LC_TIME: c_int = 16; -pub const LOCAL_CONNWAIT: c_int = 0x0002; -pub const LOCAL_CREDS: c_int = 0x0001; -pub const LOCAL_PEEREID: c_int = 0x0003; - pub const MAP_STACK: c_int = 0x00001000; pub const MNT_NOEXEC: c_int = 0x02; pub const MNT_NOSUID: c_int = 0x04; pub const MNT_RDONLY: c_int = 0x01; -pub const MSG_NOTIFICATION: c_int = 0x0400; - pub const NET_RT_DUMP: c_int = 1; pub const NET_RT_FLAGS: c_int = 2; -pub const NET_RT_IFLIST: c_int = 4; -pub const NI_NUMERICSCOPE: c_int = 0x00000040; pub const OHFLOW: tcflag_t = 0x00000002; pub const P_ALL: idtype_t = 0; pub const PARSTK: tcflag_t = 0x00000004; -pub const PF_ARP: c_int = 28; pub const PF_CCITT: c_int = 10; pub const PF_CHAOS: c_int = 5; pub const PF_CNT: c_int = 21; @@ -2510,7 +2599,6 @@ pub const PF_IMPLINK: c_int = 3; pub const PF_ISO: c_int = 7; pub const PF_LAT: c_int = 14; pub const PF_LINK: c_int = 18; -pub const PF_NATM: c_int = 27; pub const PF_OSI: c_int = 7; pub const PF_PIP: c_int = 25; pub const PF_PUP: c_int = 4; @@ -2528,7 +2616,6 @@ pub const P_PID: idtype_t = 1; pub const PRIO_PGRP: c_int = 1; pub const PRIO_PROCESS: c_int = 0; pub const PRIO_USER: c_int = 2; -pub const pseudo_AF_HDRCMPLT: c_int = 30; pub const pseudo_AF_PIP: c_int = 25; pub const pseudo_AF_RTIP: c_int = 22; pub const pseudo_AF_XTP: c_int = 19; @@ -2573,13 +2660,7 @@ pub const SIGEMT: c_int = 7; pub const SIGEV_NONE: c_int = 0; pub const SIGEV_SIGNAL: c_int = 129; pub const SIGEV_THREAD: c_int = 135; -pub const SIOCGIFADDR: c_int = -1064277727; -pub const SO_FIB: c_int = 0x100a; -pub const SO_OVERFLOWED: c_int = 0x1009; -pub const SO_SETFIB: c_int = 0x100a; -pub const SO_TXPRIO: c_int = 0x100b; pub const SO_USELOOPBACK: c_int = 0x0040; -pub const SO_VLANPRIO: c_int = 0x100c; pub const _SS_ALIGNSIZE: usize = mem::size_of::(); pub const _SS_MAXSIZE: usize = 128; pub const _SS_PAD1SIZE: usize = _SS_ALIGNSIZE - 2; @@ -2649,8 +2730,6 @@ pub const USER_POSIX2_SW_DEV: c_int = 17; pub const USER_POSIX2_UPE: c_int = 18; pub const USER_STREAM_MAX: c_int = 19; pub const USER_TZNAME_MAX: c_int = 20; -pub const USER_ATEXIT_MAX: c_int = 21; -pub const USER_MAXID: c_int = 22; pub const VDOWN: usize = 31; pub const VINS: usize = 32; @@ -2856,6 +2935,42 @@ safe_f! { } } +cfg_if! { + if #[cfg(not(target_env = "nto71_iosock"))] { + extern "C" { + pub fn sendmmsg( + sockfd: c_int, + msgvec: *mut crate::mmsghdr, + vlen: c_uint, + flags: c_uint, + ) -> c_int; + pub fn recvmmsg( + sockfd: c_int, + msgvec: *mut crate::mmsghdr, + vlen: c_uint, + flags: c_uint, + timeout: *mut crate::timespec, + ) -> c_int; + } + } else { + extern "C" { + pub fn sendmmsg( + sockfd: c_int, + msgvec: *mut crate::mmsghdr, + vlen: size_t, + flags: c_int, + ) -> ssize_t; + pub fn recvmmsg( + sockfd: c_int, + msgvec: *mut crate::mmsghdr, + vlen: size_t, + flags: c_int, + timeout: *const crate::timespec, + ) -> ssize_t; + } + } +} + // Network related functions are provided by libsocket and regex // functions are provided by libregex. // In QNX <=7.0, libregex functions were included in libc itself. @@ -3277,20 +3392,6 @@ extern "C" { flags: c_int, ) -> c_int; - pub fn sendmmsg( - sockfd: c_int, - msgvec: *mut crate::mmsghdr, - vlen: c_uint, - flags: c_uint, - ) -> c_int; - pub fn recvmmsg( - sockfd: c_int, - msgvec: *mut crate::mmsghdr, - vlen: c_uint, - flags: c_uint, - timeout: *mut crate::timespec, - ) -> c_int; - pub fn mallopt(param: c_int, value: i64) -> c_int; pub fn gettimeofday(tp: *mut crate::timeval, tz: *mut c_void) -> c_int; From 08f84149efe4486c4c9442d4a80f042dbee65b81 Mon Sep 17 00:00:00 2001 From: Florian Bartels Date: Wed, 12 Mar 2025 15:01:38 +0100 Subject: [PATCH 4/8] Add QNX 7.1-iosock and 8.0 to list of additional cfgs (backport ) (cherry picked from commit 0e2dc3f2d09867cd2b01f76b86d917b262ab6245) --- build.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build.rs b/build.rs index 0e83c0eb89da0..bf5277a9a9968 100644 --- a/build.rs +++ b/build.rs @@ -32,7 +32,10 @@ const CHECK_CFG_EXTRA: &'static [(&'static str, &'static [&'static str])] = &[ "switch", "aix", "ohos", "hurd", "rtems", "visionos", "nuttx", "cygwin", ], ), - ("target_env", &["illumos", "wasi", "aix", "ohos"]), + ( + "target_env", + &["illumos", "wasi", "aix", "ohos", "nto71_iosock", "nto80"], + ), ( "target_arch", &["loongarch64", "mips32r6", "mips64r6", "csky"], From 55c58c956d72819faea79fd49ff8dbb779c8a577 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Thu, 10 Apr 2025 08:58:17 -0600 Subject: [PATCH 5/8] Add more redox sys/socket.h and sys/uio.h definitions (backport ) (cherry picked from commit a27b5a644f39e0d574d9c31153dcb8360951c098) --- src/unix/redox/mod.rs | 44 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index c453f83efce60..d7ed748c08a43 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -131,6 +131,22 @@ s! { pub thousands_sep: *const c_char, } + pub struct msghdr { + pub msg_name: *mut c_void, + pub msg_namelen: crate::socklen_t, + pub msg_iov: *mut crate::iovec, + pub msg_iovlen: size_t, + pub msg_control: *mut c_void, + pub msg_controllen: size_t, + pub msg_flags: c_int, + } + + pub struct cmsghdr { + pub cmsg_len: size_t, + pub cmsg_level: c_int, + pub cmsg_type: c_int, + } + pub struct passwd { pub pw_name: *mut c_char, pub pw_passwd: *mut c_char, @@ -1212,6 +1228,12 @@ 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, @@ -1225,11 +1247,33 @@ extern "C" { addr: *mut crate::sockaddr, addrlen: *mut crate::socklen_t, ) -> ssize_t; + pub fn recvmsg(socket: c_int, msg: *mut msghdr, flags: c_int) -> ssize_t; + pub fn sendmsg(socket: c_int, msg: *const msghdr, flags: c_int) -> ssize_t; + pub fn sendto( + socket: c_int, + buf: *const c_void, + len: size_t, + flags: c_int, + addr: *const crate::sockaddr, + addrlen: crate::socklen_t, + ) -> ssize_t; // sys/stat.h 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 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; From 1ff2f2181ae33067ee8e25bee4cbcab535c34160 Mon Sep 17 00:00:00 2001 From: David Carlier Date: Wed, 9 Apr 2025 19:02:55 +0100 Subject: [PATCH 6/8] adding linux glibc ptrace_sud_config and related PTRACE_*ET_SYSCALL_USER_DISPATCH_CONFIG. [ref](https://github.com/torvalds/linux/blob/a24588245776dafc227243a01bfbeb8a59bafba9/include/uapi/linux/ptrace.h#L138) [ref](https://github.com/torvalds/linux/blob/a24588245776dafc227243a01bfbeb8a59bafba9/include/uapi/linux/ptrace.h#L115) (backport ) (cherry picked from commit 795a6d6e6619742755e79db38bb33da7d534d9a7) --- libc-test/build.rs | 5 +++++ libc-test/semver/linux-gnu.txt | 3 +++ src/unix/linux_like/linux/gnu/mod.rs | 9 +++++++++ src/unix/solarish/solaris.rs | 4 ++-- 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 0bde80b811119..4955e8545d8aa 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -4198,6 +4198,9 @@ fn test_linux(target: &str) { // FIXME(linux): Requires >= 6.12 kernel headers. "dmabuf_cmsg" | "dmabuf_token" => true, + // FIXME(linux): Requires >= 6.4 kernel headers. + "ptrace_sud_config" => true, + _ => false, } }); @@ -4622,6 +4625,8 @@ fn test_linux(target: &str) { | "SO_DEVMEM_DONTNEED" | "SCM_DEVMEM_LINEAR" | "SCM_DEVMEM_DMABUF" => true, + // FIXME(linux): Requires >= 6.4 kernel headers. + "PTRACE_SET_SYSCALL_USER_DISPATCH_CONFIG" | "PTRACE_GET_SYSCALL_USER_DISPATCH_CONFIG" => true, _ => false, } diff --git a/libc-test/semver/linux-gnu.txt b/libc-test/semver/linux-gnu.txt index 9001de4c4ff3a..7f04169042c14 100644 --- a/libc-test/semver/linux-gnu.txt +++ b/libc-test/semver/linux-gnu.txt @@ -348,6 +348,8 @@ PR_SET_VMA PR_SET_VMA_ANON_NAME PTHREAD_MUTEX_ADAPTIVE_NP PTRACE_GET_SYSCALL_INFO +PTRACE_GET_SYSCALL_USER_DISPATCH_CONFIG +PTRACE_SET_SYSCALL_USER_DISPATCH_CONFIG PTRACE_SYSCALL_INFO_ENTRY PTRACE_SYSCALL_INFO_EXIT PTRACE_SYSCALL_INFO_NONE @@ -652,6 +654,7 @@ pthread_rwlockattr_getkind_np pthread_rwlockattr_getpshared pthread_rwlockattr_setkind_np ptrace_peeksiginfo_args +ptrace_sud_config ptrace_syscall_info putgrent putpwent diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 7f4ff568ac8e8..823f495084bda 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -332,6 +332,13 @@ s! { pub u: __c_anonymous_ptrace_syscall_info_data, } + pub struct ptrace_sud_config { + pub mode: crate::__u64, + pub selector: crate::__u64, + pub offset: crate::__u64, + pub len: crate::__u64, + } + pub struct iocb { pub aio_data: crate::__u64, #[cfg(target_endian = "little")] @@ -933,6 +940,8 @@ pub const PTRACE_SYSCALL_INFO_NONE: crate::__u8 = 0; pub const PTRACE_SYSCALL_INFO_ENTRY: crate::__u8 = 1; pub const PTRACE_SYSCALL_INFO_EXIT: crate::__u8 = 2; pub const PTRACE_SYSCALL_INFO_SECCOMP: crate::__u8 = 3; +pub const PTRACE_SET_SYSCALL_USER_DISPATCH_CONFIG: crate::__u8 = 0x4210; +pub const PTRACE_GET_SYSCALL_USER_DISPATCH_CONFIG: crate::__u8 = 0x4211; // linux/fs.h diff --git a/src/unix/solarish/solaris.rs b/src/unix/solarish/solaris.rs index 4c6a5bd489604..7baa8a1a2b675 100644 --- a/src/unix/solarish/solaris.rs +++ b/src/unix/solarish/solaris.rs @@ -1,7 +1,7 @@ use crate::prelude::*; use crate::{ - exit_status, off_t, NET_MAC_AWARE, NET_MAC_AWARE_INHERIT, PRIV_AWARE_RESET, PRIV_DEBUG, - PRIV_PFEXEC, PRIV_XPOLICY, termios, + exit_status, off_t, termios, NET_MAC_AWARE, NET_MAC_AWARE_INHERIT, PRIV_AWARE_RESET, + PRIV_DEBUG, PRIV_PFEXEC, PRIV_XPOLICY, }; pub type door_attr_t = c_uint; From a358dae479b3b886caa1410d4f80fa546db31660 Mon Sep 17 00:00:00 2001 From: Etienne Cordonnier Date: Sat, 15 Mar 2025 20:38:25 +0100 Subject: [PATCH 7/8] Add missing utmpx apis for linux musl Close https://github.com/rust-lang/libc/issues/4322 Also add a deprecation warning, because those functions are only implemented as stubs inside musl. Signed-off-by: Etienne Cordonnier (backport ) (cherry picked from commit 42ead6d709c373ad96ad88245d4345510bc0a32b) --- libc-test/semver/linux-musl.txt | 5 ++++ src/unix/linux_like/linux/musl/mod.rs | 35 ++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/libc-test/semver/linux-musl.txt b/libc-test/semver/linux-musl.txt index d8e4918facb16..e2fdcbf006c64 100644 --- a/libc-test/semver/linux-musl.txt +++ b/libc-test/semver/linux-musl.txt @@ -1,3 +1,4 @@ +ACCOUNTING AF_IB AF_MPLS AF_XDP @@ -37,6 +38,9 @@ RWF_HIPRI RWF_NOWAIT RWF_SYNC USER_PROCESS +UT_HOSTSIZE +UT_LINESIZE +UT_NAMESIZE _CS_V6_ENV _CS_V7_ENV adjtimex @@ -82,3 +86,4 @@ reallocarray setutxent tcp_info timex +utmpxname diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 40ca6d82d1690..f850849b2d6ae 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -654,7 +654,7 @@ 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 ACCOUNTING: c_short = 9; pub const SFD_CLOEXEC: c_int = 0x080000; @@ -886,6 +886,10 @@ pub const _CS_V7_ENV: c_int = 1149; pub const CLONE_NEWTIME: c_int = 0x80; +pub const UT_HOSTSIZE: usize = 256; +pub const UT_LINESIZE: usize = 32; +pub const UT_NAMESIZE: usize = 32; + cfg_if! { if #[cfg(target_arch = "s390x")] { pub const POSIX_FADV_DONTNEED: c_int = 6; @@ -985,12 +989,41 @@ extern "C" { fd: c_int, ) -> c_int; + #[deprecated( + since = "0.2.172", + note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html" + )] pub fn getutxent() -> *mut utmpx; + #[deprecated( + since = "0.2.172", + note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html" + )] pub fn getutxid(ut: *const utmpx) -> *mut utmpx; + #[deprecated( + since = "0.2.172", + note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html" + )] pub fn getutxline(ut: *const utmpx) -> *mut utmpx; + #[deprecated( + since = "0.2.172", + note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html" + )] pub fn pututxline(ut: *const utmpx) -> *mut utmpx; + #[deprecated( + since = "0.2.172", + note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html" + )] pub fn setutxent(); + #[deprecated( + since = "0.2.172", + note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html" + )] pub fn endutxent(); + #[deprecated( + since = "0.2.172", + note = "musl provides `utmp` as stubs and an alternative should be preferred; see https://wiki.musl-libc.org/faq.html" + )] + pub fn utmpxname(file: *const c_char) -> c_int; } // Alias to 64 to mimic glibc's LFS64 support From f9a47ac8113e45fc9c6871911bc1e0b7de858972 Mon Sep 17 00:00:00 2001 From: Ningyuan Wang Date: Fri, 11 Apr 2025 16:51:37 +0900 Subject: [PATCH 8/8] Define SO_BINDTOIFINDEX on Android Android supports SO_BINDTOIFINDEX since SDK level 31: https://cs.android.com/android/platform/superproject/main/+/main:prebuilts/vndk/v31/arm/include/bionic/libc/kernel/uapi/asm-generic/socket.h;l=88;drc=684b16d3ce1e891ebe15d5678e12fa05ee6dd6e4 (backport ) (cherry picked from commit efc694994f918f4970c6bca265b69fe42dc0cb1c) --- libc-test/semver/android.txt | 1 + src/unix/linux_like/android/mod.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/libc-test/semver/android.txt b/libc-test/semver/android.txt index 83b27b117d98b..02705fedbf44d 100644 --- a/libc-test/semver/android.txt +++ b/libc-test/semver/android.txt @@ -2446,6 +2446,7 @@ SOL_X25 SOMAXCONN SO_ACCEPTCONN SO_BINDTODEVICE +SO_BINDTOIFINDEX SO_BROADCAST SO_BSDCOMPAT SO_BUSY_POLL diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs index d5fe6c7540a88..c5875f2956df7 100644 --- a/src/unix/linux_like/android/mod.rs +++ b/src/unix/linux_like/android/mod.rs @@ -1555,6 +1555,7 @@ pub const SO_PEEK_OFF: c_int = 42; pub const SO_BUSY_POLL: c_int = 46; pub const SCM_TIMESTAMPING_OPT_STATS: c_int = 54; pub const SCM_TIMESTAMPING_PKTINFO: c_int = 58; +pub const SO_BINDTOIFINDEX: c_int = 62; pub const SO_TIMESTAMP_NEW: c_int = 63; pub const SO_TIMESTAMPNS_NEW: c_int = 64; pub const SO_TIMESTAMPING_NEW: c_int = 65;