diff --git a/libc-test/build.rs b/libc-test/build.rs index a04816093c29d..47ca3b8feee3c 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2764,6 +2764,13 @@ fn test_freebsd(target: &str) { _ => false, } }); + if target.contains("arm") { + cfg.skip_roundtrip(move |s| match s { + // Can't return an array from a C function. + "__gregset_t" => true, + _ => false, + }); + } cfg.generate("../src/lib.rs", "main.rs"); } diff --git a/libc-test/semver/freebsd.txt b/libc-test/semver/freebsd.txt index e3418ef7d220e..096133a059520 100644 --- a/libc-test/semver/freebsd.txt +++ b/libc-test/semver/freebsd.txt @@ -264,6 +264,7 @@ CLOCK_UPTIME CLOCK_UPTIME_FAST CLOCK_UPTIME_PRECISE CLOCK_VIRTUAL +CLOSE_RANGE_CLOEXEC CMGROUP_MAX CMSG_DATA CMSG_FIRSTHDR diff --git a/libc-test/semver/linux-gnu.txt b/libc-test/semver/linux-gnu.txt index cba0384cb191d..9dcb5a6c8ca9f 100644 --- a/libc-test/semver/linux-gnu.txt +++ b/libc-test/semver/linux-gnu.txt @@ -472,6 +472,8 @@ TIME_WAIT TMPFS_MAGIC TMP_MAX TRACEFS_MAGIC +TUNGETDEVNETNS +TUNSETCARRIER UDF_SUPER_MAGIC UNAME26 USBDEVICE_SUPER_MAGIC diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index e75683e5dc5d5..89a90010ee4f1 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -3247,6 +3247,32 @@ TP_STATUS_USER TP_STATUS_VLAN_TPID_VALID TP_STATUS_VLAN_VALID TP_STATUS_WRONG_FORMAT +TUNATTACHFILTER +TUNDETACHFILTER +TUNGETFEATURES +TUNGETFILTER +TUNGETIFF +TUNGETSNDBUF +TUNGETVNETBE +TUNGETVNETHDRSZ +TUNGETVNETLE +TUNSETDEBUG +TUNSETFILTEREBPF +TUNSETGROUP +TUNSETIFF +TUNSETIFINDEX +TUNSETLINK +TUNSETNOCSUM +TUNSETOFFLOAD +TUNSETOWNER +TUNSETPERSIST +TUNSETQUEUE +TUNSETSNDBUF +TUNSETSTEERINGEBPF +TUNSETTXFILTER +TUNSETVNETBE +TUNSETVNETHDRSZ +TUNSETVNETLE TUN_FLT_ALLMULTI TUN_F_CSUM TUN_F_TSO4 diff --git a/src/unix/bsd/freebsdlike/freebsd/arm.rs b/src/unix/bsd/freebsdlike/freebsd/arm.rs index c5c79323f727e..82112a868b0ba 100644 --- a/src/unix/bsd/freebsdlike/freebsd/arm.rs +++ b/src/unix/bsd/freebsdlike/freebsd/arm.rs @@ -12,7 +12,7 @@ pub type __gregset_t = [::__greg_t; 17]; s_no_extra_traits! { pub struct mcontext_t { pub __gregs: ::__gregset_t, - pub mc_vfp_size: ::__size_t, + pub mc_vfp_size: usize, pub mc_vfp_ptr: *mut ::c_void, pub mc_spare: [::c_uint; 33], } diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index 56ceabe6aacb8..7e8d6486d7981 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -4968,6 +4968,10 @@ pub const TFD_CLOEXEC: ::c_int = O_CLOEXEC; pub const TFD_TIMER_ABSTIME: ::c_int = 0x01; pub const TFD_TIMER_CANCEL_ON_SET: ::c_int = 0x02; +// sys/unistd.h + +pub const CLOSE_RANGE_CLOEXEC: ::c_uint = 1 << 2; + cfg_if! { if #[cfg(libc_const_extern_fn)] { pub const fn MAP_ALIGNED(a: ::c_int) -> ::c_int { diff --git a/src/unix/linux_like/linux/arch/generic/mod.rs b/src/unix/linux_like/linux/arch/generic/mod.rs index 2f437e16db26a..ba56be7a92479 100644 --- a/src/unix/linux_like/linux/arch/generic/mod.rs +++ b/src/unix/linux_like/linux/arch/generic/mod.rs @@ -210,6 +210,34 @@ pub const BLKIOMIN: ::Ioctl = 0x1278; pub const BLKIOOPT: ::Ioctl = 0x1279; pub const BLKSSZGET: ::Ioctl = 0x1268; pub const BLKPBSZGET: ::Ioctl = 0x127B; +// linux/if_tun.h +pub const TUNSETNOCSUM: ::Ioctl = 0x400454c8; +pub const TUNSETDEBUG: ::Ioctl = 0x400454c9; +pub const TUNSETIFF: ::Ioctl = 0x400454ca; +pub const TUNSETPERSIST: ::Ioctl = 0x400454cb; +pub const TUNSETOWNER: ::Ioctl = 0x400454cc; +pub const TUNSETLINK: ::Ioctl = 0x400454cd; +pub const TUNSETGROUP: ::Ioctl = 0x400454ce; +pub const TUNGETFEATURES: ::Ioctl = 0x800454cf; +pub const TUNSETOFFLOAD: ::Ioctl = 0x400454d0; +pub const TUNSETTXFILTER: ::Ioctl = 0x400454d1; +pub const TUNGETIFF: ::Ioctl = 0x800454d2; +pub const TUNGETSNDBUF: ::Ioctl = 0x800454d3; +pub const TUNSETSNDBUF: ::Ioctl = 0x400454d4; +pub const TUNGETVNETHDRSZ: ::Ioctl = 0x800454d7; +pub const TUNSETVNETHDRSZ: ::Ioctl = 0x400454d8; +pub const TUNSETQUEUE: ::Ioctl = 0x400454d9; +pub const TUNSETIFINDEX: ::Ioctl = 0x400454da; +pub const TUNSETVNETLE: ::Ioctl = 0x400454dc; +pub const TUNGETVNETLE: ::Ioctl = 0x800454dd; +/* The TUNSETVNETBE and TUNGETVNETBE ioctls are for cross-endian support on + * little-endian hosts. Not all kernel configurations support them, but all + * configurations that support SET also support GET. + */ +pub const TUNSETVNETBE: ::Ioctl = 0x400454de; +pub const TUNGETVNETBE: ::Ioctl = 0x800454df; +pub const TUNSETSTEERINGEBPF: ::Ioctl = 0x800454e0; +pub const TUNSETFILTEREBPF: ::Ioctl = 0x800454e1; cfg_if! { // Those type are constructed using the _IOC macro @@ -227,6 +255,9 @@ cfg_if! { pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x40046602; pub const FS_IOC32_GETVERSION: ::Ioctl = 0x80047601; pub const FS_IOC32_SETVERSION: ::Ioctl = 0x40047602; + pub const TUNATTACHFILTER: ::Ioctl = 0x400854d5; + pub const TUNDETACHFILTER: ::Ioctl = 0x400854d6; + pub const TUNGETFILTER: ::Ioctl = 0x800854db; } else if #[cfg(any(target_arch = "x86_64", target_arch = "riscv64", target_arch = "aarch64", @@ -240,6 +271,9 @@ cfg_if! { pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x40046602; pub const FS_IOC32_GETVERSION: ::Ioctl = 0x80047601; pub const FS_IOC32_SETVERSION: ::Ioctl = 0x40047602; + pub const TUNATTACHFILTER: ::Ioctl = 0x401054d5; + pub const TUNDETACHFILTER: ::Ioctl = 0x401054d6; + pub const TUNGETFILTER: ::Ioctl = 0x801054db; } } diff --git a/src/unix/linux_like/linux/arch/mips/mod.rs b/src/unix/linux_like/linux/arch/mips/mod.rs index 6a96aa9c3b159..bdce5827c07bf 100644 --- a/src/unix/linux_like/linux/arch/mips/mod.rs +++ b/src/unix/linux_like/linux/arch/mips/mod.rs @@ -192,6 +192,34 @@ pub const BLKIOMIN: ::Ioctl = 0x20001278; pub const BLKIOOPT: ::Ioctl = 0x20001279; pub const BLKSSZGET: ::Ioctl = 0x20001268; pub const BLKPBSZGET: ::Ioctl = 0x2000127B; +// linux/if_tun.h +pub const TUNSETNOCSUM: ::Ioctl = 0x800454c8; +pub const TUNSETDEBUG: ::Ioctl = 0x800454c9; +pub const TUNSETIFF: ::Ioctl = 0x800454ca; +pub const TUNSETPERSIST: ::Ioctl = 0x800454cb; +pub const TUNSETOWNER: ::Ioctl = 0x800454cc; +pub const TUNSETLINK: ::Ioctl = 0x800454cd; +pub const TUNSETGROUP: ::Ioctl = 0x800454ce; +pub const TUNGETFEATURES: ::Ioctl = 0x400454cf; +pub const TUNSETOFFLOAD: ::Ioctl = 0x800454d0; +pub const TUNSETTXFILTER: ::Ioctl = 0x800454d1; +pub const TUNGETIFF: ::Ioctl = 0x400454d2; +pub const TUNGETSNDBUF: ::Ioctl = 0x400454d3; +pub const TUNSETSNDBUF: ::Ioctl = 0x800454d4; +pub const TUNGETVNETHDRSZ: ::Ioctl = 0x400454d7; +pub const TUNSETVNETHDRSZ: ::Ioctl = 0x800454d8; +pub const TUNSETQUEUE: ::Ioctl = 0x800454d9; +pub const TUNSETIFINDEX: ::Ioctl = 0x800454da; +pub const TUNSETVNETLE: ::Ioctl = 0x800454dc; +pub const TUNGETVNETLE: ::Ioctl = 0x400454dd; +/* The TUNSETVNETBE and TUNGETVNETBE ioctls are for cross-endian support on + * little-endian hosts. Not all kernel configurations support them, but all + * configurations that support SET also support GET. + */ +pub const TUNSETVNETBE: ::Ioctl = 0x800454de; +pub const TUNGETVNETBE: ::Ioctl = 0x400454df; +pub const TUNSETSTEERINGEBPF: ::Ioctl = 0x400454e0; +pub const TUNSETFILTEREBPF: ::Ioctl = 0x400454e1; cfg_if! { // Those type are constructed using the _IOC macro @@ -209,6 +237,9 @@ cfg_if! { pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x80046602; pub const FS_IOC32_GETVERSION: ::Ioctl = 0x40047601; pub const FS_IOC32_SETVERSION: ::Ioctl = 0x80047602; + pub const TUNATTACHFILTER: ::Ioctl = 0x800854d5; + pub const TUNDETACHFILTER: ::Ioctl = 0x800854d6; + pub const TUNGETFILTER: ::Ioctl = 0x400854db; } else if #[cfg(any(target_arch = "mips64", target_arch = "mips64r6"))] { pub const FS_IOC_GETFLAGS: ::Ioctl = 0x40086601; pub const FS_IOC_SETFLAGS: ::Ioctl = 0x80086602; @@ -218,6 +249,9 @@ cfg_if! { pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x80046602; pub const FS_IOC32_GETVERSION: ::Ioctl = 0x40047601; pub const FS_IOC32_SETVERSION: ::Ioctl = 0x80047602; + pub const TUNATTACHFILTER: ::Ioctl = 0x801054d5; + pub const TUNDETACHFILTER: ::Ioctl = 0x801054d6; + pub const TUNGETFILTER: ::Ioctl = 0x401054db; } } diff --git a/src/unix/linux_like/linux/arch/powerpc/mod.rs b/src/unix/linux_like/linux/arch/powerpc/mod.rs index 27834dbfeabcc..93c454396d9a6 100644 --- a/src/unix/linux_like/linux/arch/powerpc/mod.rs +++ b/src/unix/linux_like/linux/arch/powerpc/mod.rs @@ -178,6 +178,34 @@ pub const BLKIOOPT: ::Ioctl = 0x20001279; pub const BLKSSZGET: ::Ioctl = 0x20001268; pub const BLKPBSZGET: ::Ioctl = 0x2000127B; //pub const FIOQSIZE: ::Ioctl = 0x40086680; +// linux/if_tun.h +pub const TUNSETNOCSUM: ::Ioctl = 0x800454c8; +pub const TUNSETDEBUG: ::Ioctl = 0x800454c9; +pub const TUNSETIFF: ::Ioctl = 0x800454ca; +pub const TUNSETPERSIST: ::Ioctl = 0x800454cb; +pub const TUNSETOWNER: ::Ioctl = 0x800454cc; +pub const TUNSETLINK: ::Ioctl = 0x800454cd; +pub const TUNSETGROUP: ::Ioctl = 0x800454ce; +pub const TUNGETFEATURES: ::Ioctl = 0x400454cf; +pub const TUNSETOFFLOAD: ::Ioctl = 0x800454d0; +pub const TUNSETTXFILTER: ::Ioctl = 0x800454d1; +pub const TUNGETIFF: ::Ioctl = 0x400454d2; +pub const TUNGETSNDBUF: ::Ioctl = 0x400454d3; +pub const TUNSETSNDBUF: ::Ioctl = 0x800454d4; +pub const TUNGETVNETHDRSZ: ::Ioctl = 0x400454d7; +pub const TUNSETVNETHDRSZ: ::Ioctl = 0x800454d8; +pub const TUNSETQUEUE: ::Ioctl = 0x800454d9; +pub const TUNSETIFINDEX: ::Ioctl = 0x800454da; +pub const TUNSETVNETLE: ::Ioctl = 0x800454dc; +pub const TUNGETVNETLE: ::Ioctl = 0x400454dd; +/* The TUNSETVNETBE and TUNGETVNETBE ioctls are for cross-endian support on + * little-endian hosts. Not all kernel configurations support them, but all + * configurations that support SET also support GET. + */ +pub const TUNSETVNETBE: ::Ioctl = 0x800454de; +pub const TUNGETVNETBE: ::Ioctl = 0x400454df; +pub const TUNSETSTEERINGEBPF: ::Ioctl = 0x400454e0; +pub const TUNSETFILTEREBPF: ::Ioctl = 0x400454e1; cfg_if! { // Those type are constructed using the _IOC macro @@ -195,6 +223,9 @@ cfg_if! { pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x80046602; pub const FS_IOC32_GETVERSION: ::Ioctl = 0x40047601; pub const FS_IOC32_SETVERSION: ::Ioctl = 0x80047602; + pub const TUNATTACHFILTER: ::Ioctl = 0x800854d5; + pub const TUNDETACHFILTER: ::Ioctl = 0x800854d6; + pub const TUNGETFILTER: ::Ioctl = 0x400854db; } else if #[cfg(target_arch = "powerpc64")] { pub const FS_IOC_GETFLAGS: ::Ioctl = 0x40086601; pub const FS_IOC_SETFLAGS: ::Ioctl = 0x80086602; @@ -204,6 +235,9 @@ cfg_if! { pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x80046602; pub const FS_IOC32_GETVERSION: ::Ioctl = 0x40047601; pub const FS_IOC32_SETVERSION: ::Ioctl = 0x80047602; + pub const TUNATTACHFILTER: ::Ioctl = 0x801054d5; + pub const TUNDETACHFILTER: ::Ioctl = 0x801054d6; + pub const TUNGETFILTER: ::Ioctl = 0x401054db; } } diff --git a/src/unix/linux_like/linux/arch/sparc/mod.rs b/src/unix/linux_like/linux/arch/sparc/mod.rs index fce466c778998..b64e6ce7149a5 100644 --- a/src/unix/linux_like/linux/arch/sparc/mod.rs +++ b/src/unix/linux_like/linux/arch/sparc/mod.rs @@ -183,6 +183,35 @@ pub const BLKPBSZGET: ::Ioctl = 0x2000127B; //pub const TIOCGRS485: ::Ioctl = 0x40205441; //pub const TIOCSRS485: ::Ioctl = 0xc0205442; +// linux/if_tun.h +pub const TUNSETNOCSUM: ::Ioctl = 0x800454c8; +pub const TUNSETDEBUG: ::Ioctl = 0x800454c9; +pub const TUNSETIFF: ::Ioctl = 0x800454ca; +pub const TUNSETPERSIST: ::Ioctl = 0x800454cb; +pub const TUNSETOWNER: ::Ioctl = 0x800454cc; +pub const TUNSETLINK: ::Ioctl = 0x800454cd; +pub const TUNSETGROUP: ::Ioctl = 0x800454ce; +pub const TUNGETFEATURES: ::Ioctl = 0x400454cf; +pub const TUNSETOFFLOAD: ::Ioctl = 0x800454d0; +pub const TUNSETTXFILTER: ::Ioctl = 0x800454d1; +pub const TUNGETIFF: ::Ioctl = 0x400454d2; +pub const TUNGETSNDBUF: ::Ioctl = 0x400454d3; +pub const TUNSETSNDBUF: ::Ioctl = 0x800454d4; +pub const TUNGETVNETHDRSZ: ::Ioctl = 0x400454d7; +pub const TUNSETVNETHDRSZ: ::Ioctl = 0x800454d8; +pub const TUNSETQUEUE: ::Ioctl = 0x800454d9; +pub const TUNSETIFINDEX: ::Ioctl = 0x800454da; +pub const TUNSETVNETLE: ::Ioctl = 0x800454dc; +pub const TUNGETVNETLE: ::Ioctl = 0x400454dd; +/* The TUNSETVNETBE and TUNGETVNETBE ioctls are for cross-endian support on + * little-endian hosts. Not all kernel configurations support them, but all + * configurations that support SET also support GET. + */ +pub const TUNSETVNETBE: ::Ioctl = 0x800454de; +pub const TUNGETVNETBE: ::Ioctl = 0x400454df; +pub const TUNSETSTEERINGEBPF: ::Ioctl = 0x400454e0; +pub const TUNSETFILTEREBPF: ::Ioctl = 0x400454e1; + pub const TIOCM_LE: ::c_int = 0x001; pub const TIOCM_DTR: ::c_int = 0x002; pub const TIOCM_RTS: ::c_int = 0x004; @@ -246,6 +275,9 @@ cfg_if! { pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x80046602; pub const FS_IOC32_GETVERSION: ::Ioctl = 0x40047601; pub const FS_IOC32_SETVERSION: ::Ioctl = 0x80047602; + pub const TUNATTACHFILTER: ::Ioctl = 0x800854d5; + pub const TUNDETACHFILTER: ::Ioctl = 0x800854d6; + pub const TUNGETFILTER: ::Ioctl = 0x400854db; } else if #[cfg(target_arch = "sparc64")] { pub const FS_IOC_GETFLAGS: ::Ioctl = 0x40086601; pub const FS_IOC_SETFLAGS: ::Ioctl = 0x80086602; @@ -255,5 +287,8 @@ cfg_if! { pub const FS_IOC32_SETFLAGS: ::Ioctl = 0x80046602; pub const FS_IOC32_GETVERSION: ::Ioctl = 0x40047601; pub const FS_IOC32_SETVERSION: ::Ioctl = 0x80047602; + pub const TUNATTACHFILTER: ::Ioctl = 0x801054d5; + pub const TUNDETACHFILTER: ::Ioctl = 0x801054d6; + pub const TUNGETFILTER: ::Ioctl = 0x401054db; } } diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index b28c33f2c1d41..39bb5dc56ad75 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -1298,6 +1298,29 @@ pub const REG_EEND: ::c_int = 14; pub const REG_ESIZE: ::c_int = 15; pub const REG_ERPAREN: ::c_int = 16; +cfg_if! { + if #[cfg(any(target_arch = "x86", + target_arch = "x86_64", + target_arch = "arm", + target_arch = "aarch64", + target_arch = "loongarch64", + target_arch = "riscv64", + target_arch = "s390x"))] { + pub const TUNSETCARRIER: ::Ioctl = 0x400454e2; + pub const TUNGETDEVNETNS: ::Ioctl = 0x54e3; + } else if #[cfg(any(target_arch = "mips", + target_arch = "mips64", + target_arch = "powerpc", + target_arch = "powerpc64", + target_arch = "sparc", + target_arch = "sparc64"))] { + pub const TUNSETCARRIER: ::Ioctl = 0x800454e2; + pub const TUNGETDEVNETNS: ::Ioctl = 0x200054e3; + } else { + // Unknown target_arch + } +} + extern "C" { pub fn fgetspent_r( fp: *mut ::FILE, diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 40d0cf0ab974f..4bfe41d6469d5 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -2148,6 +2148,7 @@ pub const IFLA_INFO_SLAVE_KIND: ::c_ushort = 4; pub const IFLA_INFO_SLAVE_DATA: ::c_ushort = 5; // linux/if_tun.h +/* TUNSETIFF ifr flags */ pub const IFF_TUN: ::c_int = 0x0001; pub const IFF_TAP: ::c_int = 0x0002; pub const IFF_NAPI: ::c_int = 0x0010;