* 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.
Add a tier-3 CI check for x86_64-unknown-dragonfly, and fix the
compilation errors needed to compile with --features=all-apis.
This builds on top of #409!
* 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.
Wrap long lines that were hidden from rustfmt by macros, be consistent
about trailing commas in `cfg`s, alphabetize operands to `any`/`all`,
and add some comments.
* Fix compilation on arm-linux-androideabi.
arm-linux-androideabi's `st_dev` is 64-bit, even though its `dev_t` is
32-bit.
* Move qemu arguments into qemu_args for mipsel and mips64el.
The cache script needs the name of the qemu binary without the args, so
always split the args into a separate variable.
* `linux_execfn` is unavailable on 32-bit Android.
* Fix types for non-x86 32-bit Android.
* Add aarch64-apple-ios as a cross target to CI.
* 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`.
And similar for `dup3`.
The idea behind using `&OwnedFd` is that `dup2`'s second operand isn't like a
normal borrow. It effectively closes the old file descriptor, and creates a
new one with the same index. This could break assumptions of classes that have
an `AsFd` to allow users to do special I/O operations, but which don't expect
users can close and reopen their file descriptor as some completely unrelated
resource.
However, the existence of things like [`FilelikeView`], as well as the
`ManuallyDrop` pattern, mean that `&OwnedFd` doesn't actually prevent
users from using `dup2` on a `BorrowedFd`.
With sunfishcode/io-lifetimes#32 though, `&mut OwnedFd` would be
sufficient, because it removes the `DerefMut` implementation.
So change `rustix` stance to be that `dup2` requires `&mut OwnedFd`.
This means that it's no longer possible to pass the same file descriptor
to both operands of `dup2` or `dup3` with safe Rust, which means it's not
possible to observe the difference in behavior in that case, so remove
the `dup3.rs` test.
[`FilelikeView`]: https://docs.rs/io-lifetimes/latest/io_lifetimes/views/struct.FilelikeView.html
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.
* 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.
* Implement a new `rustix::termios` module.
Implement a new termios module, containing tcdrain, tcflow, tcflush,
tcgetpgrp, tcgetsid, tcsendbreak, tcsetattr, tcsetpgrp, tcsetwinsize,
and all the cf* functions.
This also renames APIs like `ioctl_tcgets` to more POSIX-like names,
like `tcgetattr`.
* Put the termios API under a "termios" cargo feature.
In anticipation of #250, put the "termios" API under a "termios" feature.
* Move `isatty` into the termios API module.
* Make `RawMode` on x86 Android be `c_uint`.
Android's `mode_t` is `u16`, which is different than its `stat`'s
`st_mode`.
* Move `ttyname` into the `termios` module.
Make `ttyname` conditional on the "procfs" feature, regardless of which
backend is enabled. This makes it easier to switch backends without
having to worry about which APIs are in use.
This contains a few fixes for building rustix in io_lifetimes_use_std
mode, which tells io-lifetimes to be a passthrough for the I/O safety
types and traits in nightly std rather than using its own.
With rust-lang/rust#93888 now in nightly, and sunfishcode/io-lifetimes#18 now
in io-lifetimes 0.5.2, we can now simplify the `AsFd` pattern from
`fn foo<Fd: AsFd>(fd: &Fd)` to `fn foo<Fd: AsFd>(fd: Fd)`, without the `&`.
This also follows the emerging convention in std, as seen in the new
[`fchown`] function.
This means that users can now pass `BorrowedFd` values directly to
functions that expect `AsFd` arguments, without having to write an
extra `&` when passing them.
[`fchown`]: https://doc.rust-lang.org/nightly/std/os/unix/fs/fn.fchown.html
And while here, simplify the code to use `println!` to print "hello
world", which we can do now that it's no longer running within the
test harness process.
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.
And have it export only the types and traits that rustix uses. This
makes it easier to provide a consistent interface whether the fd
types and traits are defined by the standard library or by Rustix
itself.
Also, move `getcwd` into the `process` module, since it's reading an
attribute of the current process. This is admittadly subjective, since
`cwd()` is in `fs`, but I think it makes more sense this way because
`cwd()` is just a way to let `*at` functions behave like their non-`at`
counterparts, while `getcwd` is typically used to record the path for
later use or for use outside the process.