diff options
-rw-r--r-- | libc-test/build.rs | 61 | ||||
-rw-r--r-- | libc-test/semver/redox.txt | 11 | ||||
-rw-r--r-- | src/unix/bsd/freebsdlike/freebsd/freebsd14/x86_64.rs | 7 | ||||
-rw-r--r-- | src/unix/haiku/mod.rs | 2 | ||||
-rw-r--r-- | src/unix/newlib/mod.rs | 3 | ||||
-rw-r--r-- | src/unix/newlib/vita/mod.rs | 175 | ||||
-rw-r--r-- | src/unix/redox/mod.rs | 36 | ||||
-rw-r--r-- | src/windows/mod.rs | 18 |
8 files changed, 261 insertions, 52 deletions
diff --git a/libc-test/build.rs b/libc-test/build.rs index 0a8b175c34..e23b0d0a37 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -3290,7 +3290,7 @@ fn test_linux(target: &str) { "linux/netfilter_ipv6/ip6_tables.h", "linux/netlink.h", // FIXME: requires Linux >= 5.6: - [!musl && !sparc64]: "linux/openat2.h", + [!musl]: "linux/openat2.h", [!musl]: "linux/ptrace.h", "linux/quota.h", "linux/random.h", @@ -3402,7 +3402,11 @@ fn test_linux(target: &str) { return true; } // FIXME: musl CI has old headers - if (musl || sparc64) && ty.starts_with("uinput_") { + if musl && ty.starts_with("uinput_") { + return true; + } + // FIXME: sparc64 CI has old headers + if sparc64 && (ty == "uinput_ff_erase" || ty == "uinput_abs_setup") { return true; } // FIXME(https://github.com/rust-lang/libc/issues/1558): passing by @@ -3457,9 +3461,6 @@ fn test_linux(target: &str) { // FIXME: requires >= 5.4 kernel headers "sockaddr_can" if musl => true, - // FIXME: Unignore once we update Ubuntu to 22.04 - "mallinfo2" if sparc64 => true, - "ptrace_rseq_configuration" if sparc64 => true, "sctp_initmsg" | "sctp_sndrcvinfo" | "sctp_sndinfo" | "sctp_rcvinfo" | "sctp_nxtinfo" | "sctp_prinfo" | "sctp_authinfo" => true, @@ -3504,7 +3505,7 @@ fn test_linux(target: &str) { return true; } } - if musl || sparc64 { + if musl { // FIXME: Requires >= 5.4.1 kernel headers if name.starts_with("J1939") || name.starts_with("RTEXT_FILTER_") @@ -3601,7 +3602,7 @@ fn test_linux(target: &str) { | "UINPUT_VERSION" | "SW_MAX" | "SW_CNT" - if mips || ppc64 || riscv64 || sparc64 => true, + if mips || ppc64 || riscv64 => true, // FIXME: Not currently available in headers on ARM, MIPS and musl. "NETLINK_GET_STRICT_CHK" if arm || mips || musl => true, @@ -3670,24 +3671,24 @@ fn test_linux(target: &str) { | "RESOLVE_IN_ROOT" | "RESOLVE_NO_MAGICLINKS" | "RESOLVE_NO_SYMLINKS" - | "RESOLVE_NO_XDEV" if musl || sparc64 => true, + | "RESOLVE_NO_XDEV" if musl => true, // FIXME: requires Linux >= 5.4: | "CAN_J1939" - | "CAN_NPROTO" if musl || sparc64 => true, + | "CAN_NPROTO" if musl => true, // FIXME: requires Linux >= 5.6 - "GRND_INSECURE" if musl || sparc64 => true, + "GRND_INSECURE" if musl => true, // FIXME: requires Linux >= 5.7: - "MREMAP_DONTUNMAP" if musl || sparc64 => true, + "MREMAP_DONTUNMAP" if musl => true, // FIXME: Requires more recent kernel headers (5.9 / 5.11): | "CLOSE_RANGE_UNSHARE" - | "CLOSE_RANGE_CLOEXEC" if musl || sparc64 => true, + | "CLOSE_RANGE_CLOEXEC" if musl => true, // FIXME: requires Linux >= 5.12: - "MPOL_F_NUMA_BALANCING" if musl || sparc64 => true, + "MPOL_F_NUMA_BALANCING" if musl => true, // FIXME: Requires more recent kernel headers | "NFNL_SUBSYS_COUNT" // bumped in v5.14 @@ -3699,39 +3700,13 @@ fn test_linux(target: &str) { | "NFULA_VLAN_UNSPEC" // v5.4+ | "RTNLGRP_NEXTHOP" // linux v5.3+ | "RTNLGRP_BRVLAN" // linux v5.6+ - if musl || sparc64 => true, - - // FIXME: Unignore once we update Ubuntu to 22.04 - | "VMADDR_CID_LOCAL" - | "STATX_MNT_ID" - | "SYS_close_range" - | "SYS_openat2" - | "SYS_pidfd_getfd" - | "SYS_faccessat2" - | "SYS_process_madvise" - | "SYS_epoll_pwait2" - | "SYS_mount_setattr" - | "SYS_quotactl_fd" - | "SYS_landlock_create_ruleset" - | "SYS_landlock_add_rule" - | "SYS_landlock_restrict_self" - | "SYS_process_mrelease" - | "IFLA_PROP_LIST" - | "IFLA_ALT_IFNAME" - | "IFLA_PERM_ADDRESS" - | "IFLA_PROTO_DOWN_REASON" - | "STATX_ATTR_MOUNT_ROOT" - | "STATX_ATTR_VERITY" - | "STATX_ATTR_DAX" - if sparc64 => true, - // Added in Linux 5.13 - "PTRACE_GET_RSEQ_CONFIGURATION" if sparc64 => true, + if musl => true, | "MADV_COLD" | "MADV_PAGEOUT" | "MADV_POPULATE_READ" | "MADV_POPULATE_WRITE" - if sparc64 || musl => true, + if musl => true, // FIXME: Requires more recent kernel headers | "IFLA_PARENT_DEV_NAME" // linux v5.13+ @@ -3745,7 +3720,7 @@ fn test_linux(target: &str) { "SCTP_FUTURE_ASSOC" | "SCTP_CURRENT_ASSOC" | "SCTP_ALL_ASSOC" | "SCTP_PEER_ADDR_THLDS_V2" => true, // linux 5.5+ // FIXME: Requires more recent kernel headers - "HWTSTAMP_TX_ONESTEP_P2P" if sparc64 || musl => true, // linux v5.6+ + "HWTSTAMP_TX_ONESTEP_P2P" if musl => true, // linux v5.6+ _ => false, } @@ -3939,6 +3914,8 @@ fn test_linux(target: &str) { "fpreg_t" if s390x => true, "sockaddr_un" | "sembuf" | "ff_constant_effect" if mips32 && (gnu || musl) => true, + + // The test doesn't work on some env: "ipv6_mreq" | "ip_mreq_source" | "sockaddr_in6" diff --git a/libc-test/semver/redox.txt b/libc-test/semver/redox.txt index 4b6e126ea6..cd07660cc4 100644 --- a/libc-test/semver/redox.txt +++ b/libc-test/semver/redox.txt @@ -137,8 +137,8 @@ SO_PEERCRED SO_PEERSEC SO_PRIORITY SO_PROTOCOL -SO_REUSEPORT SO_RCVBUFFORCE +SO_REUSEPORT SO_SNDBUFFORCE TCFLSH TCGETS @@ -180,6 +180,7 @@ bsearch chroot clearerr difftime +endpwent endservent epoll_create epoll_create1 @@ -189,12 +190,17 @@ epoll_wait explicit_bzero fchdir fmemopen +getdtablesize +getgrgid_r +getgrnam_r +getgrouplist getline +getpwent +getpwnam_r getrlimit getrusage getservbyport getservent -getdtablesize killpg lockf madvise @@ -206,6 +212,7 @@ pipe2 pthread_condattr_setclock qsort reallocarray +setpwent setrlimit setservent strcasecmp diff --git a/src/unix/bsd/freebsdlike/freebsd/freebsd14/x86_64.rs b/src/unix/bsd/freebsdlike/freebsd/freebsd14/x86_64.rs index 7bf2534455..01d0b4328d 100644 --- a/src/unix/bsd/freebsdlike/freebsd/freebsd14/x86_64.rs +++ b/src/unix/bsd/freebsdlike/freebsd/freebsd14/x86_64.rs @@ -3,3 +3,10 @@ pub const PROC_KPTI_CTL_ENABLE_ON_EXEC: ::c_int = 1; pub const PROC_KPTI_CTL_DISABLE_ON_EXEC: ::c_int = 2; pub const PROC_KPTI_STATUS: ::c_int = ::PROC_PROCCTL_MD_MIN + 1; pub const PROC_KPTI_STATUS_ACTIVE: ::c_int = 0x80000000; +pub const PROC_LA_CTL: ::c_int = ::PROC_PROCCTL_MD_MIN + 2; +pub const PROC_LA_STATUS: ::c_int = ::PROC_PROCCTL_MD_MIN + 3; +pub const PROC_LA_CTL_LA48_ON_EXEC: ::c_int = 1; +pub const PROC_LA_CTL_LA57_ON_EXEC: ::c_int = 2; +pub const PROC_LA_CTL_DEFAULT_ON_EXEC: ::c_int = 3; +pub const PROC_LA_STATUS_LA48: ::c_int = 0x01000000; +pub const PROC_LA_STATUS_LA57: ::c_int = 0x02000000; diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index 2fa3327834..c1a38f1b36 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -2055,7 +2055,7 @@ extern "C" { ) -> ::c_int; } -#[link(name = "unix")] +#[link(name = "gnu")] extern "C" { pub fn memmem( source: *const ::c_void, diff --git a/src/unix/newlib/mod.rs b/src/unix/newlib/mod.rs index 1477a60402..d46844268f 100644 --- a/src/unix/newlib/mod.rs +++ b/src/unix/newlib/mod.rs @@ -730,6 +730,9 @@ cfg_if! { } else if #[cfg(target_os = "horizon")] { mod horizon; pub use self::horizon::*; + } else if #[cfg(target_os = "vita")] { + mod vita; + pub use self::vita::*; } else if #[cfg(target_arch = "arm")] { mod arm; pub use self::arm::*; diff --git a/src/unix/newlib/vita/mod.rs b/src/unix/newlib/vita/mod.rs new file mode 100644 index 0000000000..801a408b99 --- /dev/null +++ b/src/unix/newlib/vita/mod.rs @@ -0,0 +1,175 @@ +pub type clock_t = ::c_long; + +pub type c_char = i8; +pub type wchar_t = u32; + +pub type c_long = i32; +pub type c_ulong = u32; + +s! { + pub struct sockaddr { + pub sa_family: ::sa_family_t, + pub sa_data: [::c_char; 14], + } + + pub struct sockaddr_in6 { + pub sin6_family: ::sa_family_t, + pub sin6_port: ::in_port_t, + pub sin6_flowinfo: u32, + pub sin6_addr: ::in6_addr, + pub sin6_scope_id: u32, + } + + pub struct sockaddr_in { + pub sin_family: ::sa_family_t, + pub sin_port: ::in_port_t, + pub sin_addr: ::in_addr, + pub sin_zero: [u8; 8], + } + + pub struct sockaddr_un { + pub sun_len: ::c_uchar, + pub sun_family: ::sa_family_t, + pub sun_path: [::c_char; 104usize], + } + + pub struct sockaddr_storage { + pub ss_family: ::sa_family_t, + pub __ss_padding: [u8; 26], + } + + + pub struct sched_param { + pub sched_priority: ::c_int, + } +} + +pub const AF_UNIX: ::c_int = 1; +pub const AF_INET6: ::c_int = 23; + +pub const FIONBIO: ::c_ulong = 0x8004667e; + +pub const POLLIN: ::c_short = 1; +pub const POLLPRI: ::c_short = 2; +pub const POLLOUT: ::c_short = 4; +pub const POLLERR: ::c_short = 8; +pub const POLLHUP: ::c_short = 16; +pub const POLLNVAL: ::c_short = 32; + +pub const RTLD_DEFAULT: *mut ::c_void = 0 as *mut ::c_void; + +pub const SOL_SOCKET: ::c_int = 0xffff; + +pub const MSG_OOB: ::c_int = 0x1; +pub const MSG_PEEK: ::c_int = 0x2; +pub const MSG_DONTROUTE: ::c_int = 0x4; +pub const MSG_WAITALL: ::c_int = 0x8; +pub const MSG_DONTWAIT: ::c_int = 0x10; +pub const MSG_NOSIGNAL: ::c_int = 0x20; +pub const MSG_TRUNC: ::c_int = 0x0100; +pub const MSG_CTRUNC: ::c_int = 0x0200; + +pub const UTIME_OMIT: c_long = -1; +pub const AT_FDCWD: ::c_int = -2; + +pub const O_DIRECTORY: ::c_int = 0x200000; +pub const O_NOFOLLOW: ::c_int = 0x100000; + +pub const AT_EACCESS: ::c_int = 1; +pub const AT_SYMLINK_NOFOLLOW: ::c_int = 2; +pub const AT_SYMLINK_FOLLOW: ::c_int = 4; +pub const AT_REMOVEDIR: ::c_int = 8; + +pub const SIGHUP: ::c_int = 1; +pub const SIGINT: ::c_int = 2; +pub const SIGQUIT: ::c_int = 3; +pub const SIGILL: ::c_int = 4; +pub const SIGTRAP: ::c_int = 5; +pub const SIGABRT: ::c_int = 6; +pub const SIGEMT: ::c_int = 7; +pub const SIGFPE: ::c_int = 8; +pub const SIGKILL: ::c_int = 9; +pub const SIGBUS: ::c_int = 10; +pub const SIGSEGV: ::c_int = 11; +pub const SIGSYS: ::c_int = 12; +pub const SIGPIPE: ::c_int = 13; +pub const SIGALRM: ::c_int = 14; +pub const SIGTERM: ::c_int = 15; + +pub const EAI_BADFLAGS: ::c_int = -1; +pub const EAI_NONAME: ::c_int = -2; +pub const EAI_AGAIN: ::c_int = -3; +pub const EAI_FAIL: ::c_int = -4; +pub const EAI_NODATA: ::c_int = -5; +pub const EAI_FAMILY: ::c_int = -6; +pub const EAI_SOCKTYPE: ::c_int = -7; +pub const EAI_SERVICE: ::c_int = -8; +pub const EAI_ADDRFAMILY: ::c_int = -9; +pub const EAI_MEMORY: ::c_int = -10; +pub const EAI_SYSTEM: ::c_int = -11; +pub const EAI_OVERFLOW: ::c_int = -12; + +pub const _SC_PAGESIZE: ::c_int = 8; +pub const _SC_GETPW_R_SIZE_MAX: ::c_int = 51; +pub const PTHREAD_STACK_MIN: ::size_t = 200; + +extern "C" { + pub fn futimens(fd: ::c_int, times: *const ::timespec) -> ::c_int; + pub fn writev(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int) -> ::ssize_t; + pub fn readv(fd: ::c_int, iov: *const ::iovec, iovcnt: ::c_int) -> ::ssize_t; + + pub fn pthread_create( + native: *mut ::pthread_t, + attr: *const ::pthread_attr_t, + f: extern "C" fn(_: *mut ::c_void) -> *mut ::c_void, + value: *mut ::c_void, + ) -> ::c_int; + + pub fn pthread_attr_getschedparam( + attr: *const ::pthread_attr_t, + param: *mut sched_param, + ) -> ::c_int; + + pub fn pthread_attr_setschedparam( + attr: *mut ::pthread_attr_t, + param: *const sched_param, + ) -> ::c_int; + + pub fn pthread_attr_getprocessorid_np( + attr: *const ::pthread_attr_t, + processor_id: *mut ::c_int, + ) -> ::c_int; + + pub fn pthread_attr_setprocessorid_np( + attr: *mut ::pthread_attr_t, + processor_id: ::c_int, + ) -> ::c_int; + + pub fn pthread_getschedparam( + native: ::pthread_t, + policy: *mut ::c_int, + param: *mut ::sched_param, + ) -> ::c_int; + + pub fn pthread_setschedparam( + native: ::pthread_t, + policy: ::c_int, + param: *const ::sched_param, + ) -> ::c_int; + + pub fn pthread_condattr_getclock( + attr: *const ::pthread_condattr_t, + clock_id: *mut ::clockid_t, + ) -> ::c_int; + + pub fn pthread_condattr_setclock( + attr: *mut ::pthread_condattr_t, + clock_id: ::clockid_t, + ) -> ::c_int; + + pub fn pthread_getprocessorid_np() -> ::c_int; + + pub fn getentropy(buf: *mut ::c_void, buflen: ::size_t) -> ::c_int; +} + +pub use crate::unix::newlib::generic::{sigset_t, stat}; diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs index ccd3d779fa..d946f46524 100644 --- a/src/unix/redox/mod.rs +++ b/src/unix/redox/mod.rs @@ -528,6 +528,10 @@ pub const POLLOUT: ::c_short = 0x004; pub const POLLERR: ::c_short = 0x008; pub const POLLHUP: ::c_short = 0x010; pub const POLLNVAL: ::c_short = 0x020; +pub const POLLRDNORM: ::c_short = 0x040; +pub const POLLRDBAND: ::c_short = 0x080; +pub const POLLWRNORM: ::c_short = 0x100; +pub const POLLWRBAND: ::c_short = 0x200; // pthread.h pub const PTHREAD_MUTEX_NORMAL: ::c_int = 0; @@ -996,6 +1000,28 @@ extern "C" { pub fn pipe2(fds: *mut ::c_int, flags: ::c_int) -> ::c_int; pub fn getdtablesize() -> ::c_int; + // grp.h + pub fn getgrgid_r( + gid: ::gid_t, + grp: *mut ::group, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut ::group, + ) -> ::c_int; + pub fn getgrnam_r( + name: *const ::c_char, + grp: *mut ::group, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut ::group, + ) -> ::c_int; + pub fn getgrouplist( + user: *const ::c_char, + group: ::gid_t, + groups: *mut ::gid_t, + ngroups: *mut ::c_int, + ) -> ::c_int; + // malloc.h pub fn memalign(align: ::size_t, size: ::size_t) -> *mut ::c_void; @@ -1028,6 +1054,16 @@ extern "C" { ) -> ::c_int; // pwd.h + pub fn getpwent() -> *mut passwd; + pub fn setpwent(); + pub fn endpwent(); + pub fn getpwnam_r( + name: *const ::c_char, + pwd: *mut passwd, + buf: *mut ::c_char, + buflen: ::size_t, + result: *mut *mut passwd, + ) -> ::c_int; pub fn getpwuid_r( uid: ::uid_t, pwd: *mut passwd, diff --git a/src/windows/mod.rs b/src/windows/mod.rs index 7f2f1ded19..26bff7f7a6 100644 --- a/src/windows/mod.rs +++ b/src/windows/mod.rs @@ -278,13 +278,17 @@ impl ::Clone for fpos_t { } // Special handling for all print and scan type functions because of https://github.com/rust-lang/libc/issues/2860 -#[cfg_attr( - all(windows, target_env = "msvc"), - link(name = "legacy_stdio_definitions") -)] -extern "C" { - pub fn printf(format: *const c_char, ...) -> ::c_int; - pub fn fprintf(stream: *mut FILE, format: *const c_char, ...) -> ::c_int; +cfg_if! { + if #[cfg(not(feature = "rustc-dep-of-std"))] { + #[cfg_attr( + all(windows, target_env = "msvc"), + link(name = "legacy_stdio_definitions") + )] + extern "C" { + pub fn printf(format: *const c_char, ...) -> ::c_int; + pub fn fprintf(stream: *mut FILE, format: *const c_char, ...) -> ::c_int; + } + } } extern "C" { |