diff options
-rw-r--r-- | .github/workflows/bors.yml | 3 | ||||
-rw-r--r-- | libc-test/build.rs | 5 | ||||
-rw-r--r-- | libc-test/semver/linux-gnu.txt | 6 | ||||
-rw-r--r-- | libc-test/semver/linux-musl.txt | 5 | ||||
-rw-r--r-- | libc-test/semver/linux.txt | 20 | ||||
-rw-r--r-- | libc-test/semver/openbsd.txt | 8 | ||||
-rw-r--r-- | libc-test/semver/windows.txt | 4 | ||||
-rw-r--r-- | src/unix/bsd/mod.rs | 3 | ||||
-rw-r--r-- | src/unix/bsd/netbsdlike/openbsd/mod.rs | 12 | ||||
-rw-r--r-- | src/unix/linux_like/linux/gnu/mod.rs | 11 | ||||
-rw-r--r-- | src/unix/linux_like/linux/mod.rs | 87 | ||||
-rw-r--r-- | src/unix/linux_like/linux/musl/mod.rs | 10 | ||||
-rw-r--r-- | src/unix/mod.rs | 16 | ||||
-rw-r--r-- | src/unix/solarish/mod.rs | 23 | ||||
-rw-r--r-- | src/windows/mod.rs | 8 |
15 files changed, 203 insertions, 18 deletions
diff --git a/.github/workflows/bors.yml b/.github/workflows/bors.yml index 89850c8cc4..116a01b05e 100644 --- a/.github/workflows/bors.yml +++ b/.github/workflows/bors.yml @@ -130,7 +130,8 @@ jobs: # aarch64-linux-android, aarch64-unknown-linux-gnu, aarch64-unknown-linux-musl, - arm-linux-androideabi, + # FIXME: The emulator gets stuck. + # arm-linux-androideabi, arm-unknown-linux-gnueabihf, arm-unknown-linux-musleabihf, asmjs-unknown-emscripten, diff --git a/libc-test/build.rs b/libc-test/build.rs index 2fc7cc4540..d5bf3ea61b 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -2887,6 +2887,7 @@ fn test_linux(target: &str) { "linux/if_ether.h", "linux/if_tun.h", "linux/input.h", + "linux/ipv6.h", "linux/keyctl.h", "linux/magic.h", "linux/memfd.h", @@ -3479,7 +3480,9 @@ fn test_linux(target: &str) { (struct_ == "user_fpsimd_struct" && field == "vregs") || // Linux >= 5.11 tweaked the `svm_zero` field of the `sockaddr_vm` struct. // https://github.com/torvalds/linux/commit/dc8eeef73b63ed8988224ba6b5ed19a615163a7f - (struct_ == "sockaddr_vm" && field == "svm_zero") + (struct_ == "sockaddr_vm" && field == "svm_zero") || + // the `ifr_ifru` field is an anonymous union + (struct_ == "ifreq" && field == "ifr_ifru") }); cfg.skip_roundtrip(move |s| match s { diff --git a/libc-test/semver/linux-gnu.txt b/libc-test/semver/linux-gnu.txt index 6b43d6202b..a4289ad849 100644 --- a/libc-test/semver/linux-gnu.txt +++ b/libc-test/semver/linux-gnu.txt @@ -653,4 +653,8 @@ utmpname utmpx utmpxname euidaccess -eaccess
\ No newline at end of file +eaccess +asctime_r +ctime_r +strftime +strptime
\ No newline at end of file diff --git a/libc-test/semver/linux-musl.txt b/libc-test/semver/linux-musl.txt index 96d04e0d90..c00934af10 100644 --- a/libc-test/semver/linux-musl.txt +++ b/libc-test/semver/linux-musl.txt @@ -49,4 +49,7 @@ pwritev64 reallocarray timex euidaccess -eaccess
\ No newline at end of file +eaccess +asctime_r +strftime +strptime
\ No newline at end of file diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index dc4bead28d..d8fa593c67 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -2168,38 +2168,56 @@ SIOCADDRT SIOCDARP SIOCDELMULTI SIOCDELRT +SIOCDIFADDR SIOCDRARP +SIOCETHTOOL SIOCGARP SIOCGIFADDR +SIOCGIFBR SIOCGIFBRDADDR SIOCGIFCONF +SIOCGIFCOUNT SIOCGIFDSTADDR SIOCGIFENCAP SIOCGIFFLAGS SIOCGIFHWADDR +SIOCGIFINDEX SIOCGIFMAP SIOCGIFMEM SIOCGIFMETRIC SIOCGIFMTU SIOCGIFNAME SIOCGIFNETMASK +SIOCGIFPFLAGS SIOCGIFSLAVE +SIOCGIFTXQLEN SIOCGRARP +SIOCGSKNS +SIOGIFINDEX +SIOCGMIIPHY +SIOCGMIIREG SIOCSARP SIOCSIFADDR +SIOCSIFBR SIOCSIFBRDADDR SIOCSIFDSTADDR SIOCSIFENCAP SIOCSIFFLAGS SIOCSIFHWADDR +SIOCSIFHWBROADCAST SIOCSIFLINK SIOCSIFMAP SIOCSIFMEM SIOCSIFMETRIC SIOCSIFMTU SIOCSIFNETMASK +SIOCSIFPFLAGS SIOCSIFSLAVE +SIOCSIFTXQLEN +SIOCSMIIREG SIOCSRARP +SIOCOUTQNSD +SIOCWANDEV SI_LOAD_SHIFT SND_CNT SND_MAX @@ -2971,6 +2989,8 @@ idtype_t if_freenameindex if_nameindex ifaddrs +ifreq +in6_ifreq in6_pktinfo in6_rtmsg in_pktinfo diff --git a/libc-test/semver/openbsd.txt b/libc-test/semver/openbsd.txt index cf9d73c586..bdfd1b7744 100644 --- a/libc-test/semver/openbsd.txt +++ b/libc-test/semver/openbsd.txt @@ -446,12 +446,20 @@ KI_MAXLOGNAME KI_NGROUPS KI_WMESGLEN LC_ALL +LC_ALL_MASK LC_COLLATE +LC_COLLATE_MASK LC_CTYPE +LC_CTYPE_MASK +LC_GLOBAL_LOCALE LC_MESSAGES +LC_MESSAGES_MASK LC_MONETARY +LC_MONETARY_MASK LC_NUMERIC +LC_NUMERIC_MASK LC_TIME +LC_TIME_MASK LOG_AUTHPRIV LOG_CRON LOG_FTP diff --git a/libc-test/semver/windows.txt b/libc-test/semver/windows.txt index ddb97a8d8e..1ddf031b14 100644 --- a/libc-test/semver/windows.txt +++ b/libc-test/semver/windows.txt @@ -261,6 +261,8 @@ popen printf ptrdiff_t putchar +putenv +putenv_s puts raise rand @@ -340,6 +342,8 @@ wexecve wexecvp wexecvpe wopen +wputenv +wputenv_s write wrmdir wsetlocale diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 20e203bde3..50177015a9 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -37,6 +37,7 @@ s! { #[cfg(not(any(target_os = "macos", target_os = "ios", + target_os = "tvos", target_os = "watchos", target_os = "netbsd", target_os = "openbsd")))] @@ -887,7 +888,7 @@ extern "C" { } cfg_if! { - if #[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos"))] { + if #[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))] { mod apple; pub use self::apple::*; } else if #[cfg(any(target_os = "openbsd", target_os = "netbsd"))] { diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs index 506306e9f7..f63ad9e638 100644 --- a/src/unix/bsd/netbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs @@ -1643,6 +1643,18 @@ pub const MNT_WAIT: ::c_int = 1; pub const MNT_NOWAIT: ::c_int = 2; pub const MNT_LAZY: ::c_int = 3; +pub const LC_COLLATE_MASK: ::c_int = 1 << ::LC_COLLATE; +pub const LC_CTYPE_MASK: ::c_int = 1 << ::LC_CTYPE; +pub const LC_MONETARY_MASK: ::c_int = 1 << ::LC_MONETARY; +pub const LC_NUMERIC_MASK: ::c_int = 1 << ::LC_NUMERIC; +pub const LC_TIME_MASK: ::c_int = 1 << ::LC_TIME; +pub const LC_MESSAGES_MASK: ::c_int = 1 << ::LC_MESSAGES; + +const _LC_LAST: ::c_int = 7; +pub const LC_ALL_MASK: ::c_int = (1 << _LC_LAST) - 2; + +pub const LC_GLOBAL_LOCALE: ::locale_t = -1isize as ::locale_t; + const_fn! { {const} fn _ALIGN(p: usize) -> usize { (p + _ALIGNBYTES) & !_ALIGNBYTES diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 21e7619db5..3506d922dd 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -1335,6 +1335,17 @@ extern "C" { pub fn euidaccess(pathname: *const ::c_char, mode: ::c_int) -> ::c_int; pub fn eaccess(pathname: *const ::c_char, mode: ::c_int) -> ::c_int; + + pub fn asctime_r(tm: *const ::tm, buf: *mut ::c_char) -> *mut ::c_char; + pub fn ctime_r(timep: *const time_t, buf: *mut ::c_char) -> *mut ::c_char; + + pub fn strftime( + s: *mut ::c_char, + max: ::size_t, + format: *const ::c_char, + tm: *const ::tm, + ) -> ::size_t; + pub fn strptime(s: *const ::c_char, format: *const ::c_char, tm: *mut ::tm) -> *mut ::c_char; } extern "C" { diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 43f6399e44..15174bc306 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -603,6 +603,21 @@ s! { pub src_length: ::__u64, pub dest_offset: ::__u64, } + + pub struct __c_anonymous_ifru_map { + pub mem_start: ::c_ulong, + pub mem_end: ::c_ulong, + pub base_addr: ::c_ushort, + pub irq: ::c_uchar, + pub dma: ::c_uchar, + pub port: ::c_uchar, + } + + pub struct in6_ifreq { + pub ifr6_addr: ::in6_addr, + pub ifr6_prefixlen: u32, + pub ifr6_ifindex: ::c_int, + } } s_no_extra_traits! { @@ -690,6 +705,32 @@ s_no_extra_traits! { #[cfg(not(all(target_arch = "x86_64", target_pointer_width = "32")))] pad: [::c_long; 4], } + + #[cfg(libc_union)] + pub union __c_anonymous_ifr_ifru { + pub ifru_addr: ::sockaddr, + pub ifru_dstaddr: ::sockaddr, + pub ifru_broadaddr: ::sockaddr, + pub ifru_netmask: ::sockaddr, + pub ifru_hwaddr: ::sockaddr, + pub ifru_flags: ::c_short, + pub ifru_ifindex: ::c_int, + pub ifru_metric: ::c_int, + pub ifru_mtu: ::c_int, + pub ifru_map: __c_anonymous_ifru_map, + pub ifru_slave: [::c_char; ::IFNAMSIZ], + pub ifru_newname: [::c_char; ::IFNAMSIZ], + pub ifru_data: *mut ::c_char, + } + + pub struct ifreq { + /// interface name, e.g. "en0" + pub ifr_name: [::c_char; ::IFNAMSIZ], + #[cfg(libc_union)] + pub ifr_ifru: __c_anonymous_ifr_ifru, + #[cfg(not(libc_union))] + pub ifr_ifru: ::sockaddr, + } } s_no_extra_traits! { @@ -1063,6 +1104,34 @@ cfg_if! { self.mq_curmsgs.hash(state); } } + #[cfg(libc_union)] + impl ::fmt::Debug for __c_anonymous_ifr_ifru { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("ifr_ifru") + .field("ifru_addr", unsafe { &self.ifru_addr }) + .field("ifru_dstaddr", unsafe { &self.ifru_dstaddr }) + .field("ifru_broadaddr", unsafe { &self.ifru_broadaddr }) + .field("ifru_netmask", unsafe { &self.ifru_netmask }) + .field("ifru_hwaddr", unsafe { &self.ifru_hwaddr }) + .field("ifru_flags", unsafe { &self.ifru_flags }) + .field("ifru_ifindex", unsafe { &self.ifru_ifindex }) + .field("ifru_metric", unsafe { &self.ifru_metric }) + .field("ifru_mtu", unsafe { &self.ifru_mtu }) + .field("ifru_map", unsafe { &self.ifru_map }) + .field("ifru_slave", unsafe { &self.ifru_slave }) + .field("ifru_newname", unsafe { &self.ifru_newname }) + .field("ifru_data", unsafe { &self.ifru_data }) + .finish() + } + } + impl ::fmt::Debug for ifreq { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { + f.debug_struct("ifreq") + .field("ifr_name", &self.ifr_name) + .field("ifr_ifru", &self.ifr_ifru) + .finish() + } + } } } @@ -2552,6 +2621,24 @@ pub const SIOCGIFSLAVE: ::c_ulong = 0x00008929; pub const SIOCSIFSLAVE: ::c_ulong = 0x00008930; pub const SIOCADDMULTI: ::c_ulong = 0x00008931; pub const SIOCDELMULTI: ::c_ulong = 0x00008932; +pub const SIOCGIFINDEX: ::c_ulong = 0x00008933; +pub const SIOGIFINDEX: ::c_ulong = SIOCGIFINDEX; +pub const SIOCSIFPFLAGS: ::c_ulong = 0x00008934; +pub const SIOCGIFPFLAGS: ::c_ulong = 0x00008935; +pub const SIOCDIFADDR: ::c_ulong = 0x00008936; +pub const SIOCSIFHWBROADCAST: ::c_ulong = 0x00008937; +pub const SIOCGIFCOUNT: ::c_ulong = 0x00008938; +pub const SIOCGIFBR: ::c_ulong = 0x00008940; +pub const SIOCSIFBR: ::c_ulong = 0x00008941; +pub const SIOCGIFTXQLEN: ::c_ulong = 0x00008942; +pub const SIOCSIFTXQLEN: ::c_ulong = 0x00008943; +pub const SIOCETHTOOL: ::c_ulong = 0x00008946; +pub const SIOCGMIIPHY: ::c_ulong = 0x00008947; +pub const SIOCGMIIREG: ::c_ulong = 0x00008948; +pub const SIOCSMIIREG: ::c_ulong = 0x00008949; +pub const SIOCWANDEV: ::c_ulong = 0x0000894A; +pub const SIOCOUTQNSD: ::c_ulong = 0x0000894B; +pub const SIOCGSKNS: ::c_ulong = 0x0000894C; pub const SIOCDARP: ::c_ulong = 0x00008953; pub const SIOCGARP: ::c_ulong = 0x00008954; pub const SIOCSARP: ::c_ulong = 0x00008955; diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 894f377acf..32d3578218 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -757,6 +757,16 @@ extern "C" { pub fn euidaccess(pathname: *const ::c_char, mode: ::c_int) -> ::c_int; pub fn eaccess(pathname: *const ::c_char, mode: ::c_int) -> ::c_int; + + pub fn asctime_r(tm: *const ::tm, buf: *mut ::c_char) -> *mut ::c_char; + + pub fn strftime( + s: *mut ::c_char, + max: ::size_t, + format: *const ::c_char, + tm: *const ::tm, + ) -> ::size_t; + pub fn strptime(s: *const ::c_char, format: *const ::c_char, tm: *mut ::tm) -> *mut ::c_char; } cfg_if! { diff --git a/src/unix/mod.rs b/src/unix/mod.rs index ecc693e3db..16b69bb86b 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -356,6 +356,7 @@ cfg_if! { extern {} } else if #[cfg(any(target_os = "macos", target_os = "ios", + target_os = "tvos", target_os = "watchos", target_os = "android", target_os = "openbsd"))] { @@ -1030,7 +1031,12 @@ extern "C" { pub fn getrusage(resource: ::c_int, usage: *mut rusage) -> ::c_int; #[cfg_attr( - any(target_os = "macos", target_os = "ios", target_os = "watchos"), + any( + target_os = "macos", + target_os = "ios", + target_os = "tvos", + target_os = "watchos" + ), link_name = "realpath$DARWIN_EXTSN" )] pub fn realpath(pathname: *const ::c_char, resolved: *mut ::c_char) -> *mut ::c_char; @@ -1197,7 +1203,12 @@ extern "C" { link_name = "__res_init" )] #[cfg_attr( - any(target_os = "macos", target_os = "ios", target_os = "watchos"), + any( + target_os = "macos", + target_os = "ios", + target_os = "tvos", + target_os = "watchos" + ), link_name = "res_9_init" )] pub fn res_init() -> ::c_int; @@ -1483,6 +1494,7 @@ cfg_if! { pub use self::linux_like::*; } else if #[cfg(any(target_os = "macos", target_os = "ios", + target_os = "tvos", target_os = "watchos", target_os = "freebsd", target_os = "dragonfly", diff --git a/src/unix/solarish/mod.rs b/src/unix/solarish/mod.rs index c5da62be04..d01deefbf3 100644 --- a/src/unix/solarish/mod.rs +++ b/src/unix/solarish/mod.rs @@ -3147,18 +3147,7 @@ extern "C" { pub fn sysinfo(command: ::c_int, buf: *mut ::c_char, count: ::c_long) -> ::c_int; pub fn faccessat(fd: ::c_int, path: *const ::c_char, amode: ::c_int, flag: ::c_int) -> ::c_int; -} -#[link(name = "sendfile")] -extern "C" { - pub fn sendfile(out_fd: ::c_int, in_fd: ::c_int, off: *mut ::off_t, len: ::size_t) - -> ::ssize_t; - pub fn sendfilev( - fildes: ::c_int, - vec: *const sendfilevec_t, - sfvcnt: ::c_int, - xferred: *mut ::size_t, - ) -> ::ssize_t; // #include <link.h> #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] pub fn dl_iterate_phdr( @@ -3205,6 +3194,18 @@ extern "C" { pub fn backtrace_symbols_fd(buffer: *const *mut ::c_void, size: ::c_int, fd: ::c_int); } +#[link(name = "sendfile")] +extern "C" { + pub fn sendfile(out_fd: ::c_int, in_fd: ::c_int, off: *mut ::off_t, len: ::size_t) + -> ::ssize_t; + pub fn sendfilev( + fildes: ::c_int, + vec: *const sendfilevec_t, + sfvcnt: ::c_int, + xferred: *mut ::size_t, + ) -> ::ssize_t; +} + #[link(name = "lgrp")] extern "C" { pub fn lgrp_init(view: lgrp_view_t) -> lgrp_cookie_t; diff --git a/src/windows/mod.rs b/src/windows/mod.rs index acb0de9895..916019b1f2 100644 --- a/src/windows/mod.rs +++ b/src/windows/mod.rs @@ -509,6 +509,14 @@ extern "C" { pub fn aligned_malloc(size: size_t, alignment: size_t) -> *mut c_void; #[link_name = "_aligned_free"] pub fn aligned_free(ptr: *mut ::c_void); + #[link_name = "_putenv"] + pub fn putenv(envstring: *const ::c_char) -> ::c_int; + #[link_name = "_wputenv"] + pub fn wputenv(envstring: *const ::wchar_t) -> ::c_int; + #[link_name = "_putenv_s"] + pub fn putenv_s(envstring: *const ::c_char, value_string: *const ::c_char) -> ::errno_t; + #[link_name = "_wputenv_s"] + pub fn wputenv_s(envstring: *const ::wchar_t, value_string: *const ::wchar_t) -> ::errno_t; } extern "system" { |