diff options
| author | bors <bors@rust-lang.org> | 2017-01-04 04:28:15 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-01-04 04:28:15 +0000 |
| commit | 01677eeef2d3536b07dced43d062f4e486fe695c (patch) | |
| tree | 254a5c725fd5e0380175dd8746abb0f491748d20 /src/libstd/sys/redox/syscall | |
| parent | a68622c899883b9871b71d5ed600166e2254d230 (diff) | |
| parent | c6858a1429895f27b4daafde9295deb494e2e29c (diff) | |
| download | rust-01677eeef2d3536b07dced43d062f4e486fe695c.tar.gz rust-01677eeef2d3536b07dced43d062f4e486fe695c.zip | |
Auto merge of #38707 - redox-os:master, r=brson
Add socket timeout and ttl support in `sys::redox` This adds support for `read_timeout`, `write_timeout`, and `ttl` on `TcpStream`, `TcpListener`, and `UdpSocket` in the `sys::redox` module. The DNS lookup has been set to use a 5 second timeout by default.
Diffstat (limited to 'src/libstd/sys/redox/syscall')
| -rw-r--r-- | src/libstd/sys/redox/syscall/data.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/libstd/sys/redox/syscall/data.rs b/src/libstd/sys/redox/syscall/data.rs index ac3946672a3..a6b0ada72b8 100644 --- a/src/libstd/sys/redox/syscall/data.rs +++ b/src/libstd/sys/redox/syscall/data.rs @@ -84,3 +84,22 @@ pub struct TimeSpec { pub tv_sec: i64, pub tv_nsec: i32, } + +impl Deref for TimeSpec { + type Target = [u8]; + fn deref(&self) -> &[u8] { + unsafe { + slice::from_raw_parts(self as *const TimeSpec as *const u8, + mem::size_of::<TimeSpec>()) as &[u8] + } + } +} + +impl DerefMut for TimeSpec { + fn deref_mut(&mut self) -> &mut [u8] { + unsafe { + slice::from_raw_parts_mut(self as *mut TimeSpec as *mut u8, + mem::size_of::<TimeSpec>()) as &mut [u8] + } + } +} |
