Skip to content

Commit

Permalink
Auto merge of #475 - asomers:timespec, r=fiveop
Browse files Browse the repository at this point in the history
Timespec

Make TimeVal an opaque Newtype, and add another Newtype for Timespec.
  • Loading branch information
homu committed Dec 2, 2016
2 parents 5be9967 + 24eefcc commit f78bfd3
Show file tree
Hide file tree
Showing 4 changed files with 394 additions and 62 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased]

### Added
- Added struct `TimeSpec`
([#475](https://github.com/nix-rust/nix/pull/475))
- Added complete definitions for all kqueue-related constants on all supported
OSes
([#415](https://github.com/nix-rust/nix/pull/415))
Expand All @@ -22,6 +24,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
([#457](https://github.com/nix-rust/nix/pull/457))

### Changed
- Changed `TimeVal` into an opaque Newtype
([#475](https://github.com/nix-rust/nix/pull/475))
- `kill`'s signature, defined in `::nix::sys::signal`, changed, so that the
signal parameter has type `T: Into<Option<Signal>>`. `None` as an argument
for that parameter will result in a 0 passed to libc's `kill`, while a
Expand Down
10 changes: 5 additions & 5 deletions src/sys/select.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::ptr::null_mut;
use std::os::unix::io::RawFd;
use libc::c_int;
use libc::{c_int, timeval};
use {Errno, Result};
use sys::time::TimeVal;

Expand Down Expand Up @@ -56,16 +56,15 @@ impl FdSet {
}

mod ffi {
use libc::c_int;
use sys::time::TimeVal;
use libc::{c_int, timeval};
use super::FdSet;

extern {
pub fn select(nfds: c_int,
readfds: *mut FdSet,
writefds: *mut FdSet,
errorfds: *mut FdSet,
timeout: *mut TimeVal) -> c_int;
timeout: *mut timeval) -> c_int;
}
}

Expand All @@ -77,7 +76,8 @@ pub fn select(nfds: c_int,
let readfds = readfds.map(|set| set as *mut FdSet).unwrap_or(null_mut());
let writefds = writefds.map(|set| set as *mut FdSet).unwrap_or(null_mut());
let errorfds = errorfds.map(|set| set as *mut FdSet).unwrap_or(null_mut());
let timeout = timeout.map(|tv| tv as *mut TimeVal).unwrap_or(null_mut());
let timeout = timeout.map(|tv| tv as *mut TimeVal as *mut timeval)
.unwrap_or(null_mut());

let res = unsafe {
ffi::select(nfds, readfds, writefds, errorfds, timeout)
Expand Down
Loading

0 comments on commit f78bfd3

Please sign in to comment.