diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-05-17 00:56:00 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-05-20 23:06:54 -0700 |
| commit | 19dc3b50bd63489988eb8fc83d25b08ca83df151 (patch) | |
| tree | e5e2cdf9ce3389bdf871f3c99128a9b992de63a6 /src/libnative | |
| parent | 1ba7bd10c9c537687ca393eca0b323569309b83a (diff) | |
| download | rust-19dc3b50bd63489988eb8fc83d25b08ca83df151.tar.gz rust-19dc3b50bd63489988eb8fc83d25b08ca83df151.zip | |
core: Stabilize the mem module
Excluding the functions inherited from the cast module last week (with marked
stability levels), these functions received the following treatment.
* size_of - this method has become #[stable]
* nonzero_size_of/nonzero_size_of_val - these methods have been removed
* min_align_of - this method is now #[stable]
* pref_align_of - this method has been renamed without the
`pref_` prefix, and it is the "default alignment" now. This decision is in line
with what clang does (see url linked in comment on function). This function
is now #[stable].
* init - renamed to zeroed and marked #[stable]
* uninit - marked #[stable]
* move_val_init - renamed to overwrite and marked #[stable]
* {from,to}_{be,le}{16,32,64} - all functions marked #[stable]
* swap/replace/drop - marked #[stable]
* size_of_val/min_align_of_val/align_of_val - these functions are marked
#[unstable], but will continue to exist in some form. Concerns have been
raised about their `_val` prefix.
[breaking-change]
Diffstat (limited to 'src/libnative')
| -rw-r--r-- | src/libnative/io/file_win32.rs | 4 | ||||
| -rw-r--r-- | src/libnative/io/net.rs | 12 | ||||
| -rw-r--r-- | src/libnative/io/pipe_win32.rs | 8 | ||||
| -rw-r--r-- | src/libnative/io/process.rs | 6 | ||||
| -rw-r--r-- | src/libnative/io/timer_unix.rs | 6 | ||||
| -rw-r--r-- | src/libnative/io/util.rs | 6 |
6 files changed, 21 insertions, 21 deletions
diff --git a/src/libnative/io/file_win32.rs b/src/libnative/io/file_win32.rs index 3222c912dd0..3bfd70a0a8b 100644 --- a/src/libnative/io/file_win32.rs +++ b/src/libnative/io/file_win32.rs @@ -118,7 +118,7 @@ impl rtio::RtioFileStream for FileDesc { fn pread(&mut self, buf: &mut [u8], offset: u64) -> Result<int, IoError> { let mut read = 0; - let mut overlap: libc::OVERLAPPED = unsafe { mem::init() }; + let mut overlap: libc::OVERLAPPED = unsafe { mem::zeroed() }; overlap.Offset = offset as libc::DWORD; overlap.OffsetHigh = (offset >> 32) as libc::DWORD; let ret = unsafe { @@ -135,7 +135,7 @@ impl rtio::RtioFileStream for FileDesc { fn pwrite(&mut self, buf: &[u8], mut offset: u64) -> Result<(), IoError> { let mut cur = buf.as_ptr(); let mut remaining = buf.len(); - let mut overlap: libc::OVERLAPPED = unsafe { mem::init() }; + let mut overlap: libc::OVERLAPPED = unsafe { mem::zeroed() }; while remaining > 0 { overlap.Offset = offset as libc::DWORD; overlap.OffsetHigh = (offset >> 32) as libc::DWORD; diff --git a/src/libnative/io/net.rs b/src/libnative/io/net.rs index 40b66cc526f..6ba92009c39 100644 --- a/src/libnative/io/net.rs +++ b/src/libnative/io/net.rs @@ -68,7 +68,7 @@ fn ip_to_inaddr(ip: ip::IpAddr) -> InAddr { fn addr_to_sockaddr(addr: ip::SocketAddr) -> (libc::sockaddr_storage, uint) { unsafe { - let storage: libc::sockaddr_storage = mem::init(); + let storage: libc::sockaddr_storage = mem::zeroed(); let len = match ip_to_inaddr(addr.ip) { InAddr(inaddr) => { let storage: *mut libc::sockaddr_in = mem::transmute(&storage); @@ -120,7 +120,7 @@ fn setsockopt<T>(fd: sock_t, opt: libc::c_int, val: libc::c_int, pub fn getsockopt<T: Copy>(fd: sock_t, opt: libc::c_int, val: libc::c_int) -> IoResult<T> { unsafe { - let mut slot: T = mem::init(); + let mut slot: T = mem::zeroed(); let mut len = mem::size_of::<T>() as libc::socklen_t; let ret = c::getsockopt(fd, opt, val, &mut slot as *mut _ as *mut _, @@ -152,7 +152,7 @@ fn sockname(fd: sock_t, *mut libc::socklen_t) -> libc::c_int) -> IoResult<ip::SocketAddr> { - let mut storage: libc::sockaddr_storage = unsafe { mem::init() }; + let mut storage: libc::sockaddr_storage = unsafe { mem::zeroed() }; let mut len = mem::size_of::<libc::sockaddr_storage>() as libc::socklen_t; unsafe { let storage = &mut storage as *mut libc::sockaddr_storage; @@ -221,7 +221,7 @@ pub fn init() { let _guard = LOCK.lock(); if !INITIALIZED { - let mut data: c::WSADATA = mem::init(); + let mut data: c::WSADATA = mem::zeroed(); let ret = c::WSAStartup(0x202, // version 2.2 &mut data); assert_eq!(ret, 0); @@ -497,7 +497,7 @@ impl TcpAcceptor { try!(util::await(self.fd(), Some(self.deadline), util::Readable)); } unsafe { - let mut storage: libc::sockaddr_storage = mem::init(); + let mut storage: libc::sockaddr_storage = mem::zeroed(); let storagep = &mut storage as *mut libc::sockaddr_storage; let size = mem::size_of::<libc::sockaddr_storage>(); let mut size = size as libc::socklen_t; @@ -622,7 +622,7 @@ impl rtio::RtioSocket for UdpSocket { impl rtio::RtioUdpSocket for UdpSocket { fn recvfrom(&mut self, buf: &mut [u8]) -> IoResult<(uint, ip::SocketAddr)> { let fd = self.fd(); - let mut storage: libc::sockaddr_storage = unsafe { mem::init() }; + let mut storage: libc::sockaddr_storage = unsafe { mem::zeroed() }; let storagep = &mut storage as *mut _ as *mut libc::sockaddr; let mut addrlen: libc::socklen_t = mem::size_of::<libc::sockaddr_storage>() as libc::socklen_t; diff --git a/src/libnative/io/pipe_win32.rs b/src/libnative/io/pipe_win32.rs index af80c7174f2..5acb48a5f39 100644 --- a/src/libnative/io/pipe_win32.rs +++ b/src/libnative/io/pipe_win32.rs @@ -86,8 +86,8 @@ use libc; use std::c_str::CString; -use std::intrinsics; use std::io; +use std::mem; use std::os::win32::as_utf16_p; use std::os; use std::ptr; @@ -345,7 +345,7 @@ impl rtio::RtioPipe for UnixStream { } let mut bytes_read = 0; - let mut overlapped: libc::OVERLAPPED = unsafe { intrinsics::init() }; + let mut overlapped: libc::OVERLAPPED = unsafe { mem::zeroed() }; overlapped.hEvent = self.read.get_ref().handle(); // Pre-flight check to see if the reading half has been closed. This @@ -417,7 +417,7 @@ impl rtio::RtioPipe for UnixStream { } let mut offset = 0; - let mut overlapped: libc::OVERLAPPED = unsafe { intrinsics::init() }; + let mut overlapped: libc::OVERLAPPED = unsafe { mem::zeroed() }; overlapped.hEvent = self.write.get_ref().handle(); while offset < buf.len() { @@ -633,7 +633,7 @@ impl UnixAcceptor { // someone on the other end connects. This function can "fail" if a // client connects after we created the pipe but before we got down // here. Thanks windows. - let mut overlapped: libc::OVERLAPPED = unsafe { intrinsics::init() }; + let mut overlapped: libc::OVERLAPPED = unsafe { mem::zeroed() }; overlapped.hEvent = self.event.handle(); if unsafe { libc::ConnectNamedPipe(handle, &mut overlapped) == 0 } { let mut err = unsafe { libc::GetLastError() }; diff --git a/src/libnative/io/process.rs b/src/libnative/io/process.rs index 0eebd3380e6..04911bc5f1b 100644 --- a/src/libnative/io/process.rs +++ b/src/libnative/io/process.rs @@ -896,8 +896,8 @@ fn waitpid(pid: pid_t, deadline: u64) -> IoResult<p::ProcessExit> { // self-pipe plus the old handler registered (return value of sigaction). fn register_sigchld() -> (libc::c_int, c::sigaction) { unsafe { - let mut old: c::sigaction = mem::init(); - let mut new: c::sigaction = mem::init(); + let mut old: c::sigaction = mem::zeroed(); + let mut new: c::sigaction = mem::zeroed(); new.sa_handler = sigchld_handler; new.sa_flags = c::SA_NOCLDSTOP; assert_eq!(c::sigaction(c::SIGCHLD, &new, &mut old), 0); @@ -916,7 +916,7 @@ fn waitpid(pid: pid_t, deadline: u64) -> IoResult<p::ProcessExit> { messages: Receiver<Req>, (read_fd, old): (libc::c_int, c::sigaction)) { util::set_nonblocking(input, true).unwrap(); - let mut set: c::fd_set = unsafe { mem::init() }; + let mut set: c::fd_set = unsafe { mem::zeroed() }; let mut tv: libc::timeval; let mut active = Vec::<(libc::pid_t, Sender<p::ProcessExit>, u64)>::new(); let max = cmp::max(input, read_fd) + 1; diff --git a/src/libnative/io/timer_unix.rs b/src/libnative/io/timer_unix.rs index 2c5b7984827..ed218022b2e 100644 --- a/src/libnative/io/timer_unix.rs +++ b/src/libnative/io/timer_unix.rs @@ -87,17 +87,17 @@ pub enum Req { // returns the current time (in milliseconds) pub fn now() -> u64 { unsafe { - let mut now: libc::timeval = mem::init(); + let mut now: libc::timeval = mem::zeroed(); assert_eq!(c::gettimeofday(&mut now, ptr::null()), 0); return (now.tv_sec as u64) * 1000 + (now.tv_usec as u64) / 1000; } } fn helper(input: libc::c_int, messages: Receiver<Req>, _: ()) { - let mut set: c::fd_set = unsafe { mem::init() }; + let mut set: c::fd_set = unsafe { mem::zeroed() }; let mut fd = FileDesc::new(input, true); - let mut timeout: libc::timeval = unsafe { mem::init() }; + let mut timeout: libc::timeval = unsafe { mem::zeroed() }; // active timers are those which are able to be selected upon (and it's a // sorted list, and dead timers are those which have expired, but ownership diff --git a/src/libnative/io/util.rs b/src/libnative/io/util.rs index 0d032f9f4bc..fe7a58a5e68 100644 --- a/src/libnative/io/util.rs +++ b/src/libnative/io/util.rs @@ -89,7 +89,7 @@ pub fn connect_timeout(fd: net::sock_t, // to use select() with a timeout. -1 if os::errno() as int == INPROGRESS as int || os::errno() as int == WOULDBLOCK as int => { - let mut set: c::fd_set = unsafe { mem::init() }; + let mut set: c::fd_set = unsafe { mem::zeroed() }; c::fd_set(&mut set, fd); match await(fd, &mut set, timeout_ms) { 0 => Err(timeout("connection timed out")), @@ -137,13 +137,13 @@ pub fn connect_timeout(fd: net::sock_t, pub fn await(fd: net::sock_t, deadline: Option<u64>, status: SocketStatus) -> IoResult<()> { - let mut set: c::fd_set = unsafe { mem::init() }; + let mut set: c::fd_set = unsafe { mem::zeroed() }; c::fd_set(&mut set, fd); let (read, write) = match status { Readable => (&set as *_, ptr::null()), Writable => (ptr::null(), &set as *_), }; - let mut tv: libc::timeval = unsafe { mem::init() }; + let mut tv: libc::timeval = unsafe { mem::zeroed() }; match retry(|| { let now = ::io::timer::now(); |
