Commit Graph

60 Commits

Author SHA1 Message Date
Dan Gohman 4e2599b729 Run the tests on Rust 1.48, and check compilation of tests and examples on more targets (#465)
* Fix the tests to run on 1.48.

This puts the benchmarks behind a `criterion` cfg, so add
`--cfg=criterion` to RUSTFLAGS when running cargo bench.

An MSRV of 1.48 enables us to support users such as async-io, which also
has an MSRV of 1.48.

* Add a rust-version field.

This prints a warning under Rust 1.48, but only when rustix is the
top-level build; when rustix is a dependency, it doesn't warn, so this
seems ok.
2022-12-01 11:42:09 -08:00
Dan Gohman 8fca74091c Tidy up cfgs. 2022-11-28 08:58:36 -08:00
Dan Gohman 8b5196283a Fix test compilation when "threads" or "procfs" aren't enabled. 2022-11-18 08:19:32 -08:00
niluxv 760c0b517c Add part of the FreeBSD procctl API (#429) 2022-11-07 07:39:44 -08:00
Dan Gohman b72d4291d2 Add a proc_self_status function for reading /proc/self/status on Linux.
Fixes #423.
2022-10-12 13:27:49 -07:00
Dan Gohman a4434a6c12 Fix various compilation errors on haiku. (#411)
This builds on top of #407!
2022-09-25 18:20:34 -07:00
Koutheir Attouchi e328c738bc Add support for prctl(). 2022-09-16 07:14:37 -07:00
Dan Gohman 26baf41126 Add a Result to getpgid, and add getpgrp. (#386)
* Add a `Result` to `getpgid`, and add `getpgrp`.

Add a `Result` return type to `getpgid`, as it can fail if there's no
process with the given pid.

And, add a a `getpgrp` function, which is similar to `getpgid`, but
doesn't take a pid argument and always operates on the current process,
which means it doesn't need a `Result` return type.

* Use `getpgid` on platforms which don't have a `getpgrp` syscall.
2022-07-26 05:49:50 -07:00
carbotaniuman ad5b66e657 Add getpgid (#380)
* Add getpgid
2022-07-12 20:41:40 -07:00
Dan Gohman ec92ea492e Fix miscellaneous clippy lints. 2022-07-07 07:38:07 -07:00
Dan Gohman e82a2c1ea5 Implement statvfs and fstatvfs. (#375)
* Implement `statvfs` and `fstatvfs`.

On libc, just go with whatever the libc `statvfs` gives us. On
linux_raw, translate the fields from `statfs` in the manner of
libc implementations.

* Preserve as much of the `f_fsid` field as possible.

* Document the relationship between `statfs` and `statvfs`.

* Add a `StatVfsMountFlags` type for the `f_flag` field.
2022-07-03 22:23:37 -07:00
Dan Gohman 11630efc0d Add more cfg's to fix the build with various combinations of features. 2022-06-13 15:49:17 -07:00
Dan Gohman 6c6a86c6fa Avoid using .init_array and __environ on non-musl non-glibc platforms. (#339)
* Avoid using `.init_array` and `__environ` on non-musl non-glibc platforms.

Don't assume that non-musl non-glibc platforms have `.init_array` and
`__environ`; use an explicit `init` function on such platforms, and add a
`debug_assert` to check that it's called.

* Add a safety comment.

* Move the auxv functions into a new top-level "param" module.

"param" is short for "process parameter".

* Use `CStr` instead of `ZStr`.
2022-06-03 06:28:23 -07:00
Dan Gohman ffd2ef83a4 Remove ZStr and ZString. (#337)
* Remove `ZStr` and `ZString`.

Use `CStr` and `CString` instead, now that nightly has then in core and
alloc, respectively.

Fixes #336.

* Enable "core_c_str" on nightly to use core::ffi::CStr.

* Don't test --no-default-features on stable.

--no-default-features disables "std", and building without "std" will
require nightly now.

* `CString` and `NulError` are in alloc.

* Add comments to the relevant Cargo.toml features.

* rustfmt
2022-05-27 07:37:16 -07:00
Dan Gohman 0483d272e9 Tidy up more comments. 2022-05-16 09:03:19 -07:00
Dan Gohman a84a2db5a1 Remove some unneeded unused_imports attributes. 2022-05-16 04:00:59 -07:00
Dan Gohman 243e8c5197 Rename rustix::io::Error to rustix::io::Errno.
Fixes #254.
2022-05-16 04:00:10 -07:00
Dan Gohman 99fd6e5ccc Fix y2038 bugs in the libc backend on glibc platforms.
Add support for glibc's y2038 APIs in the libc backend.

The musl and android targets are not y2038 compatible on 32-bit
platforms, however in musl's case, this will be fixed when Rust itself
is updated to musl 1.2, and in android's case, this is because android
itself does not intend to be y2038-compatible on 32-bit platforms.

This strengthen's rustix's y2038 stance to: support y2038 compatibility
on platforms which have support for this.
2022-05-08 06:40:10 -07:00
Dan Gohman a946a14762 Put net, time, and other parts of the API behind feature flags (#297)
* Introduce API features.

* Don't use doc_cfg on internal modules.

* Don't compile the net code when the "net" feature is not present.

* Don't compile the runtime code when the "runtime" feature is not present.

* Don't compile the thread code when the "thread" feature is not present.

* Don't compile the time code when the "time" feature is not present.

* Don't compile the fs code when the "fs" feature is not present.

* Don't compile the rand code when the "rand" feature is not present.

* Split an "mm" feature out of the "io" module.

* Make some parts of "process"' implementation conditional.

* "Inline" the use declarations in src/imp/linux_raw/fs/mod.rs.

* Export `Timespec` and `ClockId` in `crate::thread`.

* io_uring depends on types from fs and net.

* Re-export Timespec etc. in crate::fs and crate::thread.

This makes it easier to disable crate::time when the time module is not
enabled.

* Ensure that tests and examples compile when features are disabled.

* Fix compilation.
2022-05-02 10:54:40 -07:00
Dan Gohman 78fc85f6d7 Don't pass BorrowedFd by reference.
Functions that take `<Fd: AsFd>` parameters can take `BorrowedFd`
arguments by value; it's not necessary to pass `BorrowedFd` values
by reference anymore.
2022-04-29 07:03:05 -07:00
Dan Gohman f2fe80a1cd Fix another place in the test_priorities test.
Fix another place in the test_priorities test that needs the same fix
as in b276eab4b6.
2022-04-12 20:16:40 -07:00
Dan Gohman b276eab4b6 Miscellaneous fixes.
This patch contains three fixes:
 - Fix a missing documentation comment on s390x.
 - Remove an unnecessary ptr2int cast which would break strict-provenance.
 - Adjust test_priorities to work even if run with the lowest priority.
2022-04-12 19:13:48 -07:00
Dan Gohman 3bf8c71ac1 Refactoring in preparation for introducing feature flags (#272)
* Internal tidying: move more implementation details out of mod.rs files.

To make mod.rs files tidier, move some implementation details out of
mod.rs files and into the underlying source files.

This is also a first step towards #250.

* Be consistent about using `c::` instead of `libc::`.

* Add more constants to linux_raw's `c` module.

This reduces the need for verbose `linux_raw_sys::general::` qualifiers
in many places, and eliminates some differences between the libc and
linux_raw code paths.

* Make statx available on all Linux platforms by using `weak_or_syscall`.

This fixes unused-type errors, and also eliminates a public API
difference between glibc and musl.

And, it requires teaching the `syscall` macro how to pass `BorrowedFd`
values to `syscall` calls.

* Provide a definition of `struct statx` for non-glibc.

Musl and Android don't have a public `struct statx`, so provide a manual
declaration for them. And, add a `StatxTimestamp` for working with
`Statx`.

* Define `StatxFlags` for non-glibc, and add the `MNT_ID` flag.

* Add SYS_statx definitions for Android.

* Fix compilation on wasm32-wasi.

* Fix c_long.

* Fix a warning.

* Fix compilation on x86_64-uwp-windows-msvc.
2022-04-10 20:53:44 -07:00
Dan Gohman 8e1d553539 Preserve provenance in weak! and related macros. 2022-04-01 07:40:50 -07:00
Dan Gohman 40a77b783b rustfmt 2022-03-08 09:22:06 -08:00
Dan Gohman 07264e399e Add convenience predicates to Pid, Gid, and Uid.
Add `is_init` and `is_root` convenience methods to `Pid`, `Gid`, and
`Uid`.
2022-03-08 09:08:20 -08:00
Dan Gohman f3be1866f8 Add a clock_ticks_per_second function.
This exposes `sysconf(_SC_CLK_TCK)`.
2022-03-07 07:02:55 -08:00
Dan Gohman 929ed6379b Fix a race condition in the rlimit test. 2022-02-16 17:49:59 -08:00
Dan Gohman df1c27d1de Fix test_linux_hwcap to work on old libc versions.
Use `weak!` to detect support for `getauxval` so that we can test on
platforms which don't have it.
2022-01-31 18:38:34 -08:00
Dan Gohman d5503146d8 Handle Error::NOSYS in tests for Linux-specific syscalls.
Linux 2.6.32 doesn't support `prlimit64` or `memfd_create`, so handle
`Error::NOSYS` gracefully in tests.
2022-01-31 18:38:34 -08:00
Dan Gohman 645e05f465 Enable CpuSet::count on Android (#204)
* Enable `CpuSet::count` on Android.
2022-01-31 09:08:09 -08:00
Dan Gohman 42de227bbe Implement setrlimit and prlimit. (#191)
rustix already had the types defined for `getrlimit`, so this just adds
the new `setrlimit` and Linux-specific `prlimit`.
2022-01-25 13:26:00 -08:00
Dan Gohman f7e4c56df5 Write more comments.
Make a pass over the crate adding and cleanup up comments and doc aliases.
2022-01-19 12:44:26 -08:00
Dan Gohman bea37b349b Implement proc_self_maps, proc_self_pagemap, and proc_self_fdinfo.
Add support for opening files within procfs, and add public APIs for
accessing `/proc/self/maps`, `/proc/self/pagemap`, and
`proc/self/<fd>/fdinfo`.
2022-01-19 12:43:34 -08:00
Dan Gohman 0b0865048e Remove the test_wait test.
This test is dangerous as it can end up waiting for unrelated child
processes. In theory, we could fix this by spawning a separate process
that we completely control and running the test within that process,
but for now, just disable the test.
2022-01-12 10:31:53 -08:00
Dan Gohman 71a3f2d4d3 Make Pid a non-zero type. (#136)
Make `Pid` a non-zero type and use `Option<Pid>` in places where a pid
value can be zero.  This lets `fork`'s API use an `Option` instead of a
sentry value, which is cleaner.
2021-12-03 19:59:05 -08:00
Dan Gohman 4ef8c6a1d6 Rename rsix to rustix.
Fixes #98.
2021-11-04 15:16:20 -07:00
Dan Gohman b38dc07ed3 Code reorganization. 2021-11-04 05:26:22 -07:00
Dan Gohman 57b7f4f628 Winsock support.
The Windows Winsock API provides an API similar enough to POSIX-style
sockets that it's supportable within rsix.
2021-11-02 04:19:27 -07:00
nivkner ce404ec155 Add waitpid (#92)
* add waitpid

* add test for waitpid
2021-10-23 16:13:40 -07:00
Your Name ba243f182c replace OsString with CString in getcwd 2021-10-20 06:01:12 -07:00
Your Name 304cad2696 replace OsStr with CStr in Uname 2021-10-20 06:01:12 -07:00
Dan Gohman feb5ecb218 Fix a few typos in comments. 2021-10-11 06:58:05 -07:00
matt rice 102c5ffb67 Fix tests under 1.51. 2021-09-21 07:12:42 -07:00
Dan Gohman 8c271b197b Implement membarrier. 2021-09-17 13:25:28 -07:00
Dan Gohman 15cca7ab07 Fix a warning. 2021-09-15 11:58:14 -07:00
Dan Gohman b9be500a56 Move the working_directory test to tests/process too. 2021-09-14 17:13:10 -07:00
Dan Gohman 6ecdefa396 Test that rsix's page size matches libc's page size. 2021-09-03 09:56:19 -07:00
Dan Gohman 57c2e618bb Rewrite the nice test for FreeBSD. 2021-09-03 09:56:19 -07:00
Dan Gohman 2536139687 Implement nice, getpriority, and setpriority. 2021-09-02 15:59:07 -07:00