Added dup3() support on FreeBSD, NetBSD, OpenBSD and Solaris
Added `dup3()` support on FreeBSD, NetBSD, OpenBSD and Solaris.
The `dup3()` API is present in:
- FreeBSD 10.0 an later.
- NetBSD 6.0 and later.
- OpenBSD 5.7 and later.
- Solaris 11.4 and later.
Arch specific ptrace commands for BSDs
This PR is to add architecture specific ptrace requests etc.
Don't merge this yet if it passes I want to go over the other BSDs and architectures to see if I've missed anything I'm just creating the PR to get that initial CI approval that it's right as I expect this bit to be more fiddly.
Add ptrace for non-apple BSDs
So yesterday I did a PR for ptrace for apple, I've now gone through the ptrace header files for the other BSDs supported by libc and added ptrace + constants for all of them.
Given the lack of ptrace in any of them I don't know if the test has to be changed at all for the new functions so I'll tackle any CI errors that come up if and as they appear.
Added ptrace constants for apple
I noticed the ptrace constants were missing for apple so I've added them referencing this [header](https://opensource.apple.com/source/xnu/xnu-792.13.8/bsd/sys/ptrace.h). This doesn't add any new functions just constants so I haven't added any tests which seems to be correct.
Revisit work on cvoid
At the recommendation of @SimonSapin [here](https://github.com/rust-lang/rust/issues/53856#issuecomment-422932721), I have revisited the build script to check whether `core::ffi::c_void` resolves, instead of relying on a particular `rustc` version. This allows use on `1.30.x` builds with `core::ffi::c_void`.
I also noticed that `c_void` is defined twice in this crate, once in `lib.rs` and again in `switch.rs`. This instead defines `c_void` for every target except `wasm32`. As far as I can tell, this shouldn't actually change functionality on any existing targets.
Add ftok on MacOS
Provide a symbol for the `ftok` function declared in sys/ipc.h, for completeness and to allow calling `ftok` to generate the key value for `shmat`.
Add fcntl constants for advisory locking on BSDs
For range-based locking POSIX fcntl locks are needed. This adds the
constants F_RDLCK, F_UNLCK, and F_WRLCK for FreeBSD, NetBSD, OpenBSD,
DragonFlyBSD, and macOS/iOS. Fortunately these values are defined the same across these platforms.
For range-based locking POSIX fcntl locks are needed. This adds the
constants F_RDLCK, F_UNLCK, and F_WRLCK for FreeBSD, NetBSD, OpenBSD,
DragonFlyBSD, and macOS/iOS. Fortunately these values are defined the same across these platforms.
Expose futimens and utimensat on FreeBSD and DragonFly
Should have sent this out with #1084 but I didn't notice then that these were missing (see https://github.com/nix-rust/nix/pull/944).
Haven't been able to test these locally as I do not have access to these platforms. Will rely on CI to verify these for me.
Add fallocate64 and posix_fallocate64 bindings
These are necessary for large file support on 32-bit platforms,
following the same pattern as 74825222cf ("Add bindings for
-D_FILE_OFFSET_BITS=64").
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
These are necessary for large file support on 32-bit platforms,
following the same pattern as 74825222cf ("Add bindings for
-D_FILE_OFFSET_BITS=64").
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Re-export core::ffi::c_void if it exists
This is the second part of the implementation of [RFC 2521](https://github.com/rust-lang/rfcs/pull/2521), replacing the definition of `c_void` in libc with a re-export of the type from `core::ffi::c_void` on builds it exists for.
This uses the re-export for rustc version `1.31.0` or greater, as `1.30.x` was the current nightly when [the PR for the changes to libcore and libstd](https://github.com/rust-lang/rust/pull/53910) was merged, so I'm assuming the first nightly they will appear in will be `1.31.0`; is this acceptable?
cc rust-lang/rust#53856
Theoretically test statics
There are none of them in `libc` except for `__progname` on Android, but
that one cannot be tested because it's not present in any header files.
Add new FreeBSD socket option SO_REUSEPORT_LB.
FreeBSD 12, which is scheduled to be released soon, has a new socket option SO_REUSEPORT_LB.
From setsockopt man page:
SO_REUSEPORT_LB allows completely duplicate bindings by multiple
processes if they all set SO_REUSEPORT_LB before binding the port.
Incoming TCP and UDP connections are distributed among the sharing
processes based on a hash function of local port number, foreign IP
address and port number. A maximum of 256 processes can share one socket.