Age | Commit message (Collapse) | Author |
|
This commit adds support for the signal timer mechanism in POSIX, the
mirror to timerfd on Linux.
Resolves #1424
Signed-off-by: Brian L. Troutwine <brian@troutwine.us>
|
|
Constify most functions that can be constified. The exceptions are
mostly accessors for structs that have no const constructor.
|
|
Previously, there was no way to create a TimeSpec in a const context
because all creation was through traits. This adds two utility
functions to create a const TimeSpec from a libc::timespec or a
std::time::Duration
|
|
|
|
See https://github.com/rust-lang/libc/issues/1848 in which this type is
changing from i32 to i64; the change is being announced via this
deprecation.
|
|
|
|
Removed support for timerfd on Android as it seems to have been deprecated? See https://android.googlesource.com/platform/development/+/73a5a3b/ndk/platforms/android-20/include/sys/timerfd.h or https://github.com/rust-lang/libc/issues/1589
Removed the public status of `TimerSpec`, as it should not be exposed to the user.
Implemented `FromRawFd` for `TimerFd` as it already implements `AsRawFd`.
Addressed comments from the latest code review:
- Removed upper bound assertions on timer expirations in tests.
- Made the main example runnable and added code to show how to wait for the timer.
- Refactored `ClockId` to use `libc_enum`.
- Added comments for all public parts of the module.
- Wrapped to 80 cols.
- Changed the size of the buffer in the tests to the minimum required.
* Ran rustfmt.
* Added a `From` implementation for `libc::timespec` -> `TimeSpec`.
* Reworked the example with the new changes and changed the timer from 5 to 1 second.
* Added a constructor for a 0-initialized `TimerSpec`.
* Added a new method to get the timer configured expiration (based on timerfd_gettime).
* Added an helper method to unset the expiration of the timer.
* Added a `wait` method to actually read from the timer.
* Renamed `settime` into just `set`.
* Refactored the tests and added a new one that tests both the `unset` and the `get` method.
Modified CHANGELOG.
|
|
repr(transparent) is required in order to safely cast between an FFI
type and its NewType. This commit applies that attribute to PollFd,
EpollEvent, IpMembershipRequest, Ipv6MembershipRequest, TimeVal, and
IoVec.
Fixes #1241
|
|
|
|
|
|
Derive Clone, Copy, Eq, Hash, and PartialEq for all types. Not all
traits are supported by all types, which is why many are missing
some.
|
|
On some platforms the alignment of cmsg_data could be less than the
alignment of the messages that it contains. That led to unaligned
reads
on those platforms. This change fixes the issue by always copying the
message contents into aligned objects. The change is not 100%
backwards
compatible when using recvmsg. Users may have to replace code like
this:
```rust
if let ControlMessage::ScmRights(&fds) = cmsg {
```
with this:
```rust
if let ControlMessageOwned::ScmRights(fds) = cmsg {
```
Fixes #999
|
|
try! is not available in Rust 2018
|
|
This allows handling the return values of other public functions
(such as TimeVal's tv_sec and tv_usec) without having to pull in
these types from libc (which is ugly if a project is trying to
use nix exclusively to avoid libc's unsafety).
|
|
|
|
POSIX AIO is a standard for asynchronous file I/O. Read, write, and
fsync operations can all take place in the background, with completion
notification delivered by a signal, by a new thread, by kqueue, or not
at all. This commit supports all standard AIO functions. However,
lio_listio is disabled on macos because it doesn't seem to work, even
though the syscall is present.
The SigEvent class, used for AIO notifications among other things, is
also added.
Also, impl AsRef for TimeVal and TimeSpec
|
|
Also, fix the TimeSpec::cmp and TimeVal::cmp methods, and fix some
formatting
|
|
Also, add trait TimeValLike, so some code can be shared between TimeSpec
and TimeVal.
|
|
|
|
By exposing its members, nix allowed users to create denormalized
TimeVals, which don't work with the derived() Eq and Ord methods.
Better to make TimeVal opaque, so it will always be normalized.
|
|
|
|
|
|
|
|
|