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
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.
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`
```
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.
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.
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.
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.
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.
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).
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>
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`.
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`.
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.
These syscalls were added recently, and therefore have consistent
numbers across different architetures (other than the weird offsetting
on some 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.
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.
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.
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.
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>
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.
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.
At time of writing, illumos systems do not provide an implementation of
the openpty() and forkpty() wrappers provided on some other UNIX
systems. While we expect to grow an implementation, it seems prudent to
provide a compatibility routine here first to unblock illumos support in
the popular nix crate.
This series of routines allows the caller to determine the credentials
of another process by pid, or of the process on the remote end of a UNIX
domain socket. The ucred_t is an opaque object with accessor routines,
and must be freed through ucred_free(3C) after use.
This change addresses two style errors found in PR review:
* indent and linebreak in CMSG_NXTHDR
* prefer `0 as *mut cmsghdr` over `core::ptr::nul_mut()`
This change defines and implements functions for the Fuchsia platform
corresponding to the C library CMSG_* macros, used for processing socket
control messages sent or received using the recv_msg(2)/send_msg(2)
syscalls.
In Linux we replaced VMADDR_CID_RESERVED with VMADDR_CID_LOCAL
in commit ef343b35d46667668a099655fca4a5b2e43a5dfe.
It is available since Linux v5.6, and it can be used to do
local communication if supported.
This patch deprecates VMADDR_CID_RESERVED for backward
compatibility.
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Initially the EPOLLEXCLUSIVE definition was hidden on the illumos
platform as it lacked explicit support. After further review, it was
concluded that EPOLLEXCLUSIVE can safely be considered a no-op, when not
fully implemented by the OS, making it safe for use on illumos.
The new ARM-based platform doesn't need these as there's no legacy
constraints.
Tested via
**demo.c**
```c
int main() {
fstat(0, NULL);
fstatat(0, NULL, NULL, 0);
lstat(NULL, NULL);
stat(NULL, NULL);
readdir(NULL);
readdir_r(NULL, NULL, NULL);
}
```
**Compilation**
```none
% SDKROOT=/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk MACOSX_DEPLOYMENT_TARGET=11.5 cc -arch arm64 demo.c
% nm a.out
0000000100008030 d __dyld_private
0000000100000000 T __mh_execute_header
U _fstat
U _fstatat
U _lstat
0000000100003e64 T _main
U _readdir
U _readdir_r
U _stat
U dyld_stub_binder
```
This has also been experimentally compiled on a Developer Transition Kit.
This adds various WASI libc definitions to the Rust libc bindings that I
needed while porting some applications to WASI.
It also removes the `pause` binding since newer versions of WASI libc
have removed this function as well. (WASI currently has no syscall with
this functionality.)
sys/stat.h is a machine-independent header, but it has ifdefs for i386.
The version that was called x86_64.rs should be used on powerpc64 too,
but I don't have a machine to test that on.
Hi,
Could you add some missing Haiku constants (i'm guessing they were added after Haiku port was last updated)?
These are defined in `unistd.h`: 194a45c6b4/headers/posix/unistd.h (L134-L137)
In particular:
Add timerfd constants and functions, from sys/timerfd.h.
Add EFD_SEMAPHORE and group all EFD_ constants together.
Add sigtimedwait function, from signal.h.
Add missing fallocate constants and functions, from linux/falloc.h and fcntl.h.
Add xattr functions, from sys/xattr.h.
Add SCHED_ and SEEK_ constants, from linux/sched.h and bits/seek_constants.h.
Add rlimit functions, from sys/resource.h.
Add RENAME_ constants, from stdio.h.
Add ino64_t type, from sys/types.h.