Commit Graph

2282 Commits

Author SHA1 Message Date
Patrick Mooney 5675256b80 Add timer interface for illumos and Solaris 2021-01-22 04:21:43 +00:00
Sergio Lopez 81c3e9835d Add preadv and pwritev for macOS
Add declarations for the preadv and pwritev system calls, introduced
in macOS 11.0 (Big Sur).

Signed-off-by: Sergio Lopez <slp@redhat.com>
2021-01-21 16:26:32 +01:00
Amanieu d'Antras 062a415aed Add support for the ILP32 variant of AArch64
This commit also fixes mutex initializers on big-endian.
2021-01-20 16:40:07 +00:00
Sébastien Marie cf0793a926 openbsd: make WIFCONTINUED() safe 2021-01-16 17:54:22 +00:00
Yuki Okushi 66500eeb18 Move structs to `s_no_extra_traits` 2021-01-07 18:10:00 +09:00
Yuki Okushi a39cf0d704 Define some consts on 1.25 ot higher 2021-01-07 16:11:21 +09:00
Damian Jarek 1581af0304 Define basic Linux SocketCAN constants and types
Add definitions from `linux/can.h`, which is a "base" header for remainder
of SocketCAN functionality.

Signed-off-by: Damian Jarek <damian.jarek93@gmail.com>
2021-01-07 09:22:43 +09:00
bors 6deb8a935a Auto merge of #2020 - joshtriplett:ifla, r=JohnTitor
Add more IFLA_ values
2021-01-05 19:40:36 +00:00
Josh Triplett 2076d1cd3f Add more IFLA_ values 2021-01-05 11:39:47 -08:00
bors 2ec333c3b6 Auto merge of #2008 - bsteinb:macos-aarch64-mcontext, r=JohnTitor
Make test suite pass on macOS on aarch64

While working on #2007 I tried to run `cargo test` in `libc-test`, which failed, because the definition of `__darwin_mcontext64` was incomplete (see #1990). This adds definitions for the exception state and the floating point state as well.

`libc-test` still does not pass, because I use the type `[u128; 32]` for the `__v` field of `__darwin_arm_neon_state64` (in C it is `__uint128_t __v[32]`. `ctest2` does not translate `u128` to `__uint128_t` and the generated C code does not compile. Any ideas for working around this?
2021-01-05 11:12:12 +00:00
Benedikt Steinbusch ee84dae71c move declarations of mcontext_t and ucontext_t 2021-01-05 11:23:48 +01:00
bors a98a649bc3 Auto merge of #2019 - kolapapa:mipsel-uclibc, r=JohnTitor
Add EPOLLEXCLUSIVE && EPOLLWAKEUP
2021-01-05 04:00:03 +00:00
kolapapa 46af3376bd Add EPOLLEXCLUSIVE && EPOLLWAKEUP 2021-01-04 14:42:14 +08:00
Alan Somers f40f3068a0 aio functions do not require librt on FreeBSD
On FreeBSD, the aio_ functions require librt _only_ if they use
SIGEV_THREAD completion notification.  However, due to Rust's originally
poor support for C unions, libc doesn't even expose some of the fields of
struct sigevent that SIGEV_THREAD requires.  Accordingly, there is no
need to link librt to programs using aio via libc.

This change partially reverts 8c23f77704
from PR #1630 .

While I'm here, fix the linkage of lio_listio on DragonflyBSD.  It
_does_ require librt.
2021-01-03 11:06:05 -07:00
Benedikt Steinbusch d377b52d73 fix glob symbol name on macOS aarch64 2021-01-01 03:11:34 +01:00
Benedikt Steinbusch ea2bc2c065 add new constants for macOS Big Sur 2021-01-01 02:48:07 +01:00
Benedikt Steinbusch 3fc0015790 fix values of constants on macOS aarch64 2021-01-01 02:46:37 +01:00
Benedikt Steinbusch bdc755b487 add declaration of max_align_t for macOS on aarch64 2021-01-01 02:41:26 +01:00
Benedikt Steinbusch 42fe29064e provide declaration of boolean_t for macOS on aarch64 2021-01-01 02:41:26 +01:00
Benedikt Steinbusch a15491e325 move declaration of __darwin_mcontext64 etc. into align.rs 2021-01-01 01:54:37 +01:00
Benedikt Steinbusch 2ec0e61663 use [u64; 2] with manual alignment instead of u128 2021-01-01 01:25:29 +01:00
Benedikt Steinbusch 10347e8604 provide complete definition of __darwin_mcontext64 on aarch64 2021-01-01 01:25:29 +01:00
bors 7e7452fa28 Auto merge of #2013 - Thomasdezeeuw:freebsd-constants, r=JohnTitor
Add SO_DOMAIN constants to FreeBSD
2020-12-29 11:42:28 +00:00
Thomas de Zeeuw 01f7008527 Add SO_DOMAIN constant to FreeBSD 2020-12-29 12:04:13 +01:00
bors c9e8bab1e0 Auto merge of #2007 - bsteinb:macos-aarch64-symbols, r=JohnTitor
Fix symbols names on macOS aarch64

libSystem on macOS Big Sur on aarch64 exports these symbols without the `$suffix`es. See also: https://github.com/GuillaumeGomez/sysinfo/issues/372
2020-12-28 22:37:15 +00:00
Benedikt Steinbusch ecffd09397 fix symbols names on macOS aarch64 2020-12-23 21:44:37 +01:00
dylni d116ee592d Define CLD_ constants for more targets 2020-12-21 21:31:14 -05:00
bors c7b9771cee Auto merge of #1999 - Jakob-Naucke:fix-statfs-magic-s390x, r=JohnTitor
Declare statfs MAGIC constants as c_uint on s390x

Hi, I work in container development on Linux on Z at IBM.
On s390x (IBM Z) in GNU/Linux, a statfs `f_type` is 4 bytes wide, contrary to 8 bytes on most architectures.
This is already implemented in libc:
```sh
$ grep -r f_type src/unix/linux_like/linux/gnu/b64 | uniq
src/unix/linux_like/linux/gnu/b64/sparc64/mod.rs:        pub f_type: ::__fsword_t,
src/unix/linux_like/linux/gnu/b64/aarch64/mod.rs:        pub f_type: ::__fsword_t,
src/unix/linux_like/linux/gnu/b64/powerpc64/mod.rs:        pub f_type: ::__fsword_t,
src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs:        pub f_type: ::c_long,
src/unix/linux_like/linux/gnu/b64/mips64/mod.rs:        pub f_type: ::c_long,
src/unix/linux_like/linux/gnu/b64/s390x.rs:        pub f_type: ::c_uint,             # s390x is uint
src/unix/linux_like/linux/gnu/b64/x86_64/mod.rs:        pub f_type: ::__fsword_t,
```
However, the `*_MAGIC` constants (such as `EXT4_SUPER_MAGIC`) in `src/unix/linux_like/linux/gnu/mod.rs` are defined as `c_long`, when they should be `c_uint` on s390x.
This ends up biting me [here](https://github.com/kata-containers/cgroups-rs/blob/master/src/hierarchies.rs#L231).
Thus, I suggest the attached change to only define these constants for architectures other than s390x and instead define them as uint for s390x.
This is safe since none of the constants are any wider than 32bit.
Please let me know if you think this could be done more elegantly.
2020-12-21 15:36:35 +00:00
Jakob Naucke 3d09b9f67c
Declare statfs MAGIC constants as c_uint on s390x
Previously, statfs MAGIC constants like EXT4_SUPER_MAGIC were defined as c_long
for linux-gnu, whereas a statfs f_type is a c_uint on s390x. This commit
exempts these definitions from s390x and instead defines these constants as
c_uint on s390x. This is safe as none of these constants are wider than 32bit.

Signed-off-by: Jakob Naucke <jakob.naucke@ibm.com>
2020-12-21 11:08:00 +01:00
Luca Barbato 0b861016eb Populate mcontext_t on aarch64-linux-musl
It is used by wasmtime.
2020-12-19 06:36:17 +01:00
Ondrej Perutka 6df758a249 Fix missing dl lib on armv5te-unknown-linux-uclibceabi 2020-12-18 11:51:35 +01:00
bors f26757a8fd Auto merge of #1998 - dylni:make-si-status-method-more-compatible, r=JohnTitor
Make si_status method more compatible

Now that [this PR](https://github.com/rust-lang/libc/pull/1858/files) has been merged, `siginfo_t::si_status` is a method for some targets and a field on others. This PR adds the method on targets that already expose the field, which lets the method be used without target detection.

I think this change is backward compatible, but it would be better if someone else could confirm that. The struct would now have a method and a field with the same name on some targets. If that's incompatible, another method could be added that accesses the field or calls the method depending on the target, but this is cleaner.
2020-12-17 07:29:33 +00:00
bors 80eb0cf292 Auto merge of #1992 - victorhsieh:master, r=JohnTitor
Android: make statfs64.f_fsid public

This has been the case since the initial commit
a36da11fb9. But there is no reason to hide
this struct member specifically.
2020-12-17 05:40:34 +00:00
dylni 29b4faed15 Make si_status method more compatible 2020-12-17 00:21:54 -05:00
bors 0ec925dfe5 Auto merge of #1990 - JohnTitor:arm-macos-state64, r=JohnTitor
Fix `thread_state64` on `aarch64-apple-darwin`

Fixes #1977
2020-12-12 23:19:02 +00:00
whitequark 4f47a74be1
Declare `O_RSYNC` for Android.
Bionic defines it to be `O_SYNC`.
2020-12-12 15:30:46 +00:00
whitequark 8b6fb595d7
Declare `seekdir` and `telldir` for Android.
These declarations are the same as those for other platforms.
2020-12-12 07:00:30 +00:00
kolapapa 1f5debf70e restore the type of the parameter flags of getnameinfo to c_int 2020-12-10 19:15:22 +08:00
Victor Hsieh 53d7168806 Android: correct statfs64.f_fsid type & visibility
The visibility has been not public since the initial commit[1]. But there
is no reason to hide this struct member specifically.

The type has also been "__fsid_t" in Android's bionic[2], so fix that as
well. This makes it consistent with statfs.f_fsid nicely.

[1] a36da11fb9
[2] https://cs.android.com/search?q=file:bionic%2Flibc%20f_fsid
2020-12-09 09:35:59 -08:00
Jack Lloyd 3635a90210 Add the Aarch64 HWCAP_ values for Android 2020-12-07 14:01:19 -05:00
Jack Lloyd 7f9ed8cee1 Add getauxval for 64-bit Android 2020-12-07 13:13:26 -05:00
Yuki Okushi 990659966e Fix `thread_state64` on `aarch64-apple-darwin` 2020-12-07 12:27:24 +09:00
David Craven 53a8be9696 Address review comments. 2020-12-03 17:33:05 +01:00
David Craven d7a80e0a1f Followup to #1649. 2020-12-03 14:38:07 +01:00
bors 8e62c98274 Auto merge of #1982 - Thomasdezeeuw:freebsd-getrandom, r=JohnTitor
Add getrandom to FreeBSD

Introduced in FreeBSD 12.0.

Manual page: https://www.freebsd.org/cgi/man.cgi?query=getrandom.

Not sure if the constants should be `c_int`, just matching the `flags` argument in the function, in c they're macros.
2020-11-27 07:30:39 +00:00
Joshua M. Clulow 6b78ca9e72 add missing TCP socket options for illumos
The socket2 crate now depends on TCP_MAXSEG, and the rest of the options
may as well come along for the ride.
2020-11-25 16:34:58 -08:00
bors 84c12a458a Auto merge of #1979 - kolapapa:uclibc-dnslookup, r=JohnTitor
add `getnameinfo` && `EAI_NODATA` in uclibc

when compiling `dns-lookup v1.0.5` in target `mipsel-unknown-linux-uclibc`
```shell
error[E0432]: unresolved import `libc::getnameinfo`
error[E0531]: cannot find unit struct, unit variant or constant `EAI_NODATA` in crate `c`
```
2020-11-25 02:51:32 +00:00
bors 5598401c18 Auto merge of #1972 - zonyitoo:master, r=JohnTitor
Add IPV6_BINDANY on FreeBSD

https://github.com/freebsd/freebsd/blob/master/sys/netinet6/in6.h#L493
2020-11-24 19:53:33 +00:00
bors f4bd085cb8 Auto merge of #1970 - KentaTada:add-sockoptions-consts-aarch64, r=JohnTitor
Add constants of socket options on aarch64

Signed-off-by: Kenta Tada <Kenta.Tada@sony.com>
2020-11-24 18:31:05 +00:00
Thomas de Zeeuw 99b3635079 Add getrandom to FreeBSD
Introduced in FreeBSD 12.0.

Manual page: https://www.freebsd.org/cgi/man.cgi?query=getrandom.
2020-11-24 11:08:27 +01:00
kolapapa 2e14399344
Update src/unix/uclibc/mod.rs
change `getnameinfo` flags type to `c_uint`

Co-authored-by: Yuki Okushi <huyuumi.dev@gmail.com>
2020-11-23 21:11:53 +08:00
Yuki Okushi ce0787f047 Fix link warnings on rustdoc 2020-11-23 21:56:37 +09:00
kolapapa 105ef736fb add `getnameinfo` && `EAI_NODATA` in uclibc 2020-11-23 17:10:09 +08:00
zonyitoo 9578fa1942 Add IPV6_BINDANY on FreeBSD 2020-11-07 12:08:32 +08:00
Kenta Tada 4ecb610fa2 Add constants of socket options on aarch64
Signed-off-by: Kenta Tada <Kenta.Tada@sony.com>
2020-11-05 23:15:18 +09:00
Maarten de Vries 36affa26b8 Implement accept4 on Android as raw syscall.
This avoids relying on Android 5.0 / API level 21. The Linux kernel used
by Android supports the syscall (except in truly ancient Android
versions), but the Android libc did not expose a wrapper.
2020-11-03 10:17:51 +01:00
Tudor Sidea f3aab7a7ec Adding dl_iterate_phdr function to uclibc
Adding dl_iterate_phdr function and related structs and types to the
uclibc module as per the file include/link.h found in the uClibc-ng
repository as of version 1.0.36. This is necessary in order for rust to
work with a new target armv7-unknown-linux-uclibceabihf.
2020-10-31 17:57:12 +02:00
Jason King 9cd5c4be8d Add additional TCP options; fix TCP_KEEPIDLE 2020-10-30 00:42:56 +00:00
Jason King c35cc0a188 Add additional solarish TCP options 2020-10-30 00:32:04 +00:00
bors 727d0ed7cc Auto merge of #1962 - coolreader18:redox-sock, r=JohnTitor
Update redox socket constants
2020-10-29 06:01:55 +00:00
Noah 0358ea8b36
Add sys/file.h constants 2020-10-28 14:54:30 -05:00
Noah cfde22846d
Add NI_* constants 2020-10-27 22:41:11 -05:00
0e4ef622 a44cc0071a
Add endservent, getservbyport, getservent, setservent 2020-10-27 20:39:55 -05:00
Noah 0b694e466b
Update redox socket constants 2020-10-27 20:21:13 -05:00
Lzu Tao 42dce281b2 Add dl_iterate_phdr for openbsd 2020-10-27 18:03:33 +07:00
Lzu Tao 6711eefc8c Add dl_iterate_phdr for netbsd 2020-10-27 18:03:33 +07:00
Lzu Tao 89c90cd298 Add dl_iterate_phdr for freebsd 2020-10-27 09:59:37 +07:00
bors 2d0d4747c4 Auto merge of #1958 - JohnTitor:fix-dragonfly-build, r=nagisa
Allow `deprecated` attribute on `f!` macros to fix dragonfly build

Fixes #1957
cc `@nagisa` I think this should resolve the build :)
2020-10-25 05:02:11 +00:00
bors 6ca151e678 Auto merge of #1956 - JohnTitor:time64, r=JohnTitor
Add a deprecation note to `time_t` on musl

cc #1848
2020-10-25 03:15:05 +00:00
Yuki Okushi d40c7ebdf6 Allow deprecated `time_t` on musl 2020-10-25 11:16:26 +09:00
Yuki Okushi e471884df5 Add a deprecation note to `time_t` on musl 2020-10-25 11:16:26 +09:00
Yuki Okushi d371bdcc1e Fix `deprecated` attribute for `__error` 2020-10-25 10:37:49 +09:00
bors e0a4fb0397 Auto merge of #1902 - george-hopkins:mptcp, r=JohnTitor
linux: Add definitions for Multipath TCP

The Linux kernel recently gained support for [Multipath TCP](https://en.wikipedia.org/wiki/Multipath_TCP), a protocol which builds upon TCP. This patch adds `IPPROTO_MPTCP` to open new sockets and `TCP_ULP` to query the upper layer protocol of traditional TCP sockets (which is set to `mptcp` for all underlying connections)

Source: [tcp: Define IPPROTO_MPTCP](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=faf391c3826cd29feae02078ca2022d2f912f7cc)

cc #1896
2020-10-24 23:20:17 +00:00
George Hopkins 7f2619fdf9
Apply suggestions from code review
Co-authored-by: Yuki Okushi <huyuumi.dev@gmail.com>
2020-10-24 19:19:56 +02:00
brian-cook e90e708724 Bring the MUSL version of siginfo_t up-to-date. 2020-10-23 16:19:50 -05:00
Kenta Tada 1f97fa1db0 Add constants of socket options
Signed-off-by: Kenta Tada <Kenta.Tada@sony.com>
2020-10-23 16:21:21 +09:00
Fredrik Fornwall 90b2f51207 Add lockf() operations to Android
Reference:
https://github.com/aosp-mirror/platform_bionic/blob/master/libc/include/bits/lockf.h#L39-L46
2020-10-22 00:24:46 +02:00
George Hopkins 2a212c84fb linux: Add definitions for Multipath TCP
We leave IPPROTO_MAX as is for the time being. However, in recent
kernel releases IPPROTO_MAX is actually higher and reflects the
addition of IPPROTO_MPTCP.
2020-10-21 07:22:41 +02:00
Yuki Okushi 419a976810
Rollup merge of #1944 - nroi:include-sendfile64, r=JohnTitor
Include sendfile64() for Linux

`sendfile` uses the `off_t` type, which is platform dependent. On 64-bit architectures, I can pass an `off64_t` as the third argument to `libc::sendfile`, but on 32-bit architectures, this does not compile. `sendfile64` on the other hand uses a 64-bit wide offset even on 32-bit architectures, so that `off64_t` can be used.

Excerpt from `man 2 sendfile`:

> The original Linux sendfile() system call was not designed to handle large file offsets. Consequently, Linux 2.4 added sendfile64(), with a wider type for the offset argument.

I hope that supporting Linux versions below 2.4 is not a requirement for libc.
2020-10-21 07:18:52 +09:00
Fabian Muscariello a8c1d9746e Include sendfile64() for Linux 2020-10-20 16:35:09 +02:00
Kenta Tada 8b68710f94 Add definitions for Linux debug related MAGIC
Signed-off-by: Kenta Tada <Kenta.Tada@sony.com>
2020-10-20 23:22:16 +09:00
Yuki Okushi 2c99f4bebc Fix build for `sparc-unknown-linux-gnu` 2020-10-20 14:05:05 +09:00
bors 17b70c1f9b Auto merge of #1832 - qwandor-google:master, r=JohnTitor
Android: Add preadv and pwritev.

From sys/uio.h. Note that preadv64/pwritev64 are already included in
src/unix/linux_like/mod.rs.
2020-10-19 16:33:07 +00:00
Andrew Walbran d04bb8e23e Android: Add preadv and pwritev.
From sys/uio.h. Note that preadv64/pwritev64 are already included in
src/unix/linux_like/mod.rs.
Also fix parameter names of process_vm_[readv,writev] to match Bionic
header.
2020-10-19 12:24:27 +01:00
DarcInc 16e0a0bf5f Adding nmount to freebsd and removing fdatasync from freebsd 10 2020-10-18 21:46:15 -04:00
bors 582c5cf0c0 Auto merge of #1703 - eduardosm:remove-af_alg_iv-as_slice, r=JohnTitor
Add deprecation notice to `af_alg_iv::as_slice` and trait implementations that depend on it

These trait implementations exposed an unsound API (see https://github.com/rust-lang/libc/issues/1501).
2020-10-16 17:00:24 +00:00
Eduardo Sánchez Muñoz d73e8a3d86 af_alg_iv: Move the deprecated attribute to the struct definition and specify version. 2020-10-16 11:41:15 +02:00
rupansh-arch 86b92f37fc android: process_vm*: fix return type 2020-10-16 05:24:37 +05:30
rupansh-arch 8624caf9ab expose process_vm_readv, process_vm_writev for android
Signed-off-by: rupansh-arch <rupanshsekar@hotmail.com>
2020-10-16 05:24:37 +05:30
Eduardo Sánchez Muñoz 5b221b2179 Re-add trait implementations of `af_alg_iv` and mark them as deprecated. 2020-10-15 22:40:43 +02:00
Eduardo Sánchez Muñoz 4b6ffb7aaf Remove `af_alg_iv::as_slice` and trait implementations that depend on it
These trait implementations exposed an unsound API (see
https://github.com/rust-lang/libc/issues/1501)
2020-10-15 22:23:07 +02:00
Max Blachman a6c451d17f add clock_nanosleep to freebsd 12 and netbsd 2020-10-15 10:11:43 -07:00
Robert Collins e9c6804523 Add missing NetBSD RLIMIT_ constants 2020-10-10 20:37:47 +02:00
Yuki Okushi a410c35f11
Merge pull request #1914 from db48x/add-clearerr 2020-10-08 04:34:01 +09:00
Daniel Brooks e4eec2a1c5 add clearerr 2020-10-07 04:35:31 -07:00
Andrew Walbran 4f40b35cca Android: Add VMADDR_ constants. 2020-10-07 11:56:56 +01:00
Patrick Mooney 8f57688dde pthread_getattr_np is not present on illumos 2020-10-04 18:47:00 +00:00
Yuki Okushi 458f49c8e6
Merge pull request #1894 from alistair23/alistair/rv32 2020-10-02 08:58:32 +09:00
Josh Triplett 2ae4135cbd
Merge pull request #1889 from LinkTed/master
Add more constants for Linux like OS
2020-10-01 12:00:24 -07:00
Alistair Francis bdfd01599e unix: riscv32: Move type defines inside confif
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
2020-10-01 07:15:39 -07:00
Josh Triplett 3e9945eb04
Merge pull request #1897 from Aaron1011/feature/sys-pidfd-open-clone3
Add SYS_pidfd_open and SYS_clone3
2020-09-30 20:14:47 -07:00
Alistair Francis c6c9181874 unix: riscv32: Fix CI failure
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
2020-09-30 18:58:05 -07:00
Alistair Francis 6801218fd4 linux: riscv32: Add support for the 64-bit time_t RV32 glibc port
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
2020-09-30 07:29:38 -07:00
Yuki Okushi 9c17cad7f0
Merge pull request #1899 from joshtriplett/support-static-glibc 2020-09-30 17:18:45 +09:00
Yuki Okushi b3f8975d3e
Merge pull request #1903 from bartelsielski/master
Add struct ip_mreqn to more Linux targets
2020-09-30 15:47:38 +09:00
Yuki Okushi bffed84b3f
Merge pull request #1904 from glaubitz/sparc-linux
Fix type definition for c_char on sparc-unknown-linux-gnu
2020-09-30 12:43:57 +09:00
Yuki Okushi 8cdddfd6b8
Merge pull request #1905 from qwandor-google/vsock
Android: Add vsock constants and struct.
2020-09-30 12:40:51 +09:00
Andrew Walbran 37357abbfc Android: Add vsock constants and struct. 2020-09-29 13:41:00 +01:00
John Paul Adrian Glaubitz 772a3acfa6 Fix type definition for c_char on sparc-unknown-linux-gnu
On sparc-unknown-linux-gnu, char is signed, not unsigned.
2020-09-27 23:27:30 +02:00
Bartel Sielski f64da93c68 Add struct ip_mreqn to more Linux targets
Support was previously added to gnu x86_64 and all musl targets but
others were not included because of a roundtrip issue [1].

This commit adds support for the ip_mreqn struct on all Linux GNU
targets which did not have the roundtrip issue.

[1]: https://github.com/rust-lang/libc/issues/1558

Signed-off-by: Bartel Sielski <bartel.sielski@gmail.com>
2020-09-25 15:50:23 +02:00
Josh Triplett 5bf6ee5d8e Consolidate handling of libdl, and handle crt-static
Move the link line for `libdl` up to `src/unix/mod.rs`, making it easier
to see all the libraries `libc` links to.

This also makes `libdl` respect `target-feature=+crt-static`.
2020-09-21 01:15:03 -07:00
Josh Triplett e005f4cad5 Consolidate handling of libutil, and handle crt-static
The two library blocks that specify `#[link(name = "util")]` do not
actually reference any functions in `libutil`; the functions that do use
`libutil` don't have any reference to it. And having two library blocks
specify it results in two separate inclusions of `-lutil` on the linker
command line. Move the link lines up to `src/unix/mod.rs`, making it
easier to see all the libraries `libc` links to.

This also makes `libutil` respect `target-feature=+crt-static`.
2020-09-21 01:15:00 -07:00
Josh Triplett ac0a783953 Add support for building with static glibc
This will need corresponding changes in rust-lang/rust to activate, but
this will make it possible to make those changes.

Note that despite the apparent redundancy in config directives, the link
directives cannot be simplified any further. Attempting to factor out
the checks for `target_feature = "crt-static"` does not work.
2020-09-21 01:14:06 -07:00
Aaron Hill 8e58e82c02
Add SYS_pidfd_open and SYS_clone3
These syscalls were added recently, and therefore have consistent
numbers across different architetures (other than the weird offsetting
on some platforms).
2020-09-17 06:05:23 -04:00
Matt Schulte d66df29623 Add UIO_MAXIOV constant to uclibc
!1880 added UIO_MAXIOV to libc, but did not add it to uclibc. This
causes build breaks for std against uclibc.
2020-09-16 21:28:07 -07:00
Daniil Bondarev 773f5562ba Use safe_f! consistently across platforms
The pr #1870 introduced safe_f! macro, which made some functions like
WIFEXITED and WEXITSTATUS const and safe on linux_like platform only,
which causes inconsistency when trying to use those functions in crates
compiled across multiple platforms, as using unsafe on those functions
will generate unused_unsafe warning on linux platforms and lack of
unsafe block will fail compilation on non-linux platforms.

To avoid the inconsistency, this commit applies the same macro for all
the same functions on other platforms too.
2020-09-12 23:38:06 -07:00
LinkTed c6e695f3fa Add more constants for Linux like OS 2020-09-11 19:25:05 +02:00
Yuki Okushi 59544d95bc
Merge pull request #1887 from psumbera/master
add pthread_getattr_np() and pthread_attr_getstack() for Solaris
2020-09-10 14:11:16 +09:00
Petr Sumbera 9f6a7ceee8 add pthread_getattr_np() and pthread_attr_getstack() support for illumos and Solaris systems 2020-09-09 16:30:56 +02:00
MeiK 7cc22dbabd Add getitimer and setitimer for macOS
Add getitimer and setitimer for macOS
2020-09-03 18:31:25 +08:00
Yuki Okushi af7749c1e5
Merge pull request #1882 from alindima/master
Add missing syscall numbers for aarch64-musl
2020-09-02 13:41:23 +09:00
Yuki Okushi d21380bb50
Merge pull request #1881 from JohnColanduoni/apple-o-symlink
Add support for Apple's O_SYMLINK flag
2020-09-02 13:36:04 +09:00
Yuki Okushi f19436de85
Merge pull request #1880 from Thomasdezeeuw/io-max-consts
Add IOV_MAX and UIO_MAXIOV constants
2020-09-02 13:34:08 +09:00
Yuki Okushi 75ab4a0124
Merge pull request #1875 from cmusser/master 2020-09-02 13:31:54 +09:00
alindima a75f9347e1 Add missing syscall numbers for aarch64-musl 2020-08-31 11:03:01 +03:00
John Colanduoni abd18481b7 Add support for Apple's O_SYMLINK flag 2020-08-29 19:41:16 -07:00
Thomas de Zeeuw 41fb480527 Add IOV_MAX and UIO_MAXIOV constants
These constant can be used to determine the maximum number of iovecs can
be passed to functions like readv/writev.

Linux like uses UIO_MAXIOV, while the BSD family uses IOV_MAX.
2020-08-28 15:03:50 +02:00
Chuck Musser 2e3748a53c Restore the __error() function, but add a deprecation warning. 2020-08-23 19:23:21 -07:00
Chuck Musser c354c216ff Dragonfly: expose __errno_location() rather than define __error().
Expose __errno_location() (introduced in DragonFlyBSD 5.8), which
returns the current thread's errno value. This is similar to Linux
and avoids having a separate module that defines both errno (which
depends on the thread_local feature) and an __error() function.
2020-08-23 09:37:00 -07:00
Niels Sascha Reedijk 43ad09ee63 Haiku: add [get/set]priority()
These methods were added in Haiku R1 beta 2.
2020-08-22 21:57:11 +00:00
Daniil Bondarev ce5cb03544 Added clock_getcpuclockid to more targets
Previously clock_getcpuclockid was enabled only on linux, with this
change it is enabled on all linux_like and freebsdlike.
2020-08-21 22:12:48 -07:00
Yuki Okushi ace7ba86e5
Merge pull request #1870 from joshtriplett/safe-functions 2020-08-21 04:23:12 +09:00
Josh Triplett 5a1df22a78 Make some inline functions like WIFEXITED and WEXITSTATUS const and safe 2020-08-19 23:32:39 -07:00
Josh Triplett b1144cc924 libc can't use derive(Copy,Clone) because it doesn't work in rustc 2020-08-19 22:58:10 -07:00
Jed Brown 3f9f49aacd add fmemopen, open_memstream, and open_wmemstream for POSIX.1-2008
Skip test on aarch64 due to https://github.com/rust-lang/libc/issues/1765
2020-08-19 19:08:00 -06:00
Yuki Okushi 50318f7665
Merge pull request #1863 from ifreund/aarch64-musl-ucontext_t
Add ucontext_t for aarch64-unknown-linux-musl
2020-08-20 04:25:29 +09:00
Isaac Freund 2259b0b154
Add ucontext_t for aarch64-unknown-linux-musl 2020-08-19 10:18:21 +02:00
Yuki Okushi b1793090f4
Merge pull request #1861 from joshtriplett/p_pidfd 2020-08-19 07:45:41 +09:00
Josh Triplett e709b3f78a Define P_PIDFD, used with waitid
Linux defines a waitid type `P_PIDFD`, for use with process file
descriptors (`pidfd`). Add that constant.

In libc-test, add linux/wait.h to the Linux-specific and
Android-specific headers, to get the definition. Exclude it on Android
and musl for now, though, as the versions in CI don't have it yet.
2020-08-18 14:11:08 -07:00
Yuki Okushi c6c865ef5e
Merge pull request #1862 from fornwall/android-regex 2020-08-17 00:06:30 +09:00
Yuki Okushi 83b3730444
Merge pull request #1859 from joshtriplett/w_exitcode 2020-08-14 15:50:20 +09:00
Fredrik Fornwall faecad7f01 Expose regex.h for Android 2020-08-12 10:17:18 +02:00
Yuki Okushi 6ff0689d88
Merge pull request #1858 from joshtriplett/siginfo-pid-uid
Expose si_pid and si_uid from siginfo_t as functions
2020-08-11 16:05:55 +09:00
Yuki Okushi 67005e0625
Merge pull request #1860 from joshtriplett/cld
Add CLD_ constants
2020-08-11 15:59:18 +09:00
Josh Triplett 57298d0637 Add W_STOPCODE to construct a stop code
On Linux, `sys/wait.h` defines a `W_STOPCODE` macro to construct a stop
code from the signal number of a stopping signal. Provide an equivalent
function.

Suggested-by: Ivan Tham <pickfire@riseup.net>
2020-08-10 20:23:03 -07:00
Josh Triplett a4178c59ee siginfo: Provide functions for si_utime and si_stime
The SIGCHLD variant of the siginfo structure also provides fields for
user and system time; expose those as well.
2020-08-10 20:20:30 -07:00
Josh Triplett e3bce7511b siginfo: In the struct used to access sifields, don't name the first 3 fields
The first 3 fields of `siginfo_t` have different orders on MIPS. When
casting `siginfo_t` to a different type to access the fields of the
`sifields` union, avoid giving names to the first three fields, since
they're only present for memory layout and shouldn't be accessed from
the casted structure type.
2020-08-10 20:16:50 -07:00
Josh Triplett 13d0cdb68f Expose si_pid, si_uid, and si_status from siginfo_t as functions
On Linux, siginfo_t cannot expose these fields directly due to
https://github.com/rust-lang/libc/issues/716 , so expose them as
functions, just like si_addr and si_value.

In order to get alignment correct on both 32-bit and 64-bit
architectures, define an sifields union that includes a pointer field,
to ensure that it has the same alignment as a pointer.
2020-08-10 01:24:22 -07:00
Josh Triplett 220505181f Add CLD_ constants
These constants appear in the si_code field of a SIGCHLD signal or
waitid-returned siginfo value.
2020-08-09 16:59:09 -07:00
Josh Triplett 631da86c92 Add W_EXITCODE to construct an exit code
On Linux, `sys/wait.h` defines a `W_EXITCODE` macro to construct an exit
code from a return value and a signal number. Provide an equivalent
function.
2020-08-09 16:40:54 -07:00