about summary refs log tree commit diff
path: root/src/libstd/sys
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-02-23 20:47:30 +0000
committerbors <bors@rust-lang.org>2015-02-23 20:47:30 +0000
commit91a5a1ab4ad054c8dccf49f6f409542f82683cfc (patch)
tree1c2a90b8e1aac6793a0fbf6350778a5b9ac65dae /src/libstd/sys
parentf0f7ca27de6b4e03f30012656dad270cda55a363 (diff)
parentee6f2a1ad6ab79ed954cd96fff6eaddcdfb6a043 (diff)
downloadrust-91a5a1ab4ad054c8dccf49f6f409542f82683cfc.tar.gz
rust-91a5a1ab4ad054c8dccf49f6f409542f82683cfc.zip
Auto merge of #22724 - Manishearth:rollup, r=alexcrichton
Seems to pass `check-stage1`, but I had to tweak some things so it's going through the test gauntlet again.
Diffstat (limited to 'src/libstd/sys')
-rw-r--r--src/libstd/sys/common/helper_thread.rs6
-rw-r--r--src/libstd/sys/common/thread.rs2
-rw-r--r--src/libstd/sys/unix/thread.rs7
-rw-r--r--src/libstd/sys/windows/thread.rs7
-rw-r--r--src/libstd/sys/windows/thread_local.rs6
5 files changed, 16 insertions, 12 deletions
diff --git a/src/libstd/sys/common/helper_thread.rs b/src/libstd/sys/common/helper_thread.rs
index dc1ae85efe0..5faaa928ee9 100644
--- a/src/libstd/sys/common/helper_thread.rs
+++ b/src/libstd/sys/common/helper_thread.rs
@@ -22,8 +22,8 @@
 
 use prelude::v1::*;
 
+use boxed;
 use cell::UnsafeCell;
-use mem;
 use ptr;
 use rt;
 use sync::{StaticMutex, StaticCondvar};
@@ -88,7 +88,7 @@ impl<M: Send> Helper<M> {
             let _guard = self.lock.lock().unwrap();
             if !*self.initialized.get() {
                 let (tx, rx) = channel();
-                *self.chan.get() = mem::transmute(box tx);
+                *self.chan.get() = boxed::into_raw(box tx);
                 let (receive, send) = helper_signal::new();
                 *self.signal.get() = send as uint;
 
@@ -132,7 +132,7 @@ impl<M: Send> Helper<M> {
             let mut guard = self.lock.lock().unwrap();
 
             // Close the channel by destroying it
-            let chan: Box<Sender<M>> = mem::transmute(*self.chan.get());
+            let chan: Box<Sender<M>> = Box::from_raw(*self.chan.get());
             *self.chan.get() = ptr::null_mut();
             drop(chan);
             helper_signal::signal(*self.signal.get() as helper_signal::signal);
diff --git a/src/libstd/sys/common/thread.rs b/src/libstd/sys/common/thread.rs
index b725b6c7e6e..731617858e9 100644
--- a/src/libstd/sys/common/thread.rs
+++ b/src/libstd/sys/common/thread.rs
@@ -27,7 +27,7 @@ pub fn start_thread(main: *mut libc::c_void) -> thread::rust_thread_return {
     unsafe {
         stack::record_os_managed_stack_bounds(0, usize::MAX);
         let handler = stack_overflow::Handler::new();
-        let f: Box<Thunk> = mem::transmute(main);
+        let f: Box<Thunk> = Box::from_raw(main as *mut Thunk);
         f.invoke(());
         drop(handler);
         mem::transmute(0 as thread::rust_thread_return)
diff --git a/src/libstd/sys/unix/thread.rs b/src/libstd/sys/unix/thread.rs
index c42d6d0e641..f4791d39da1 100644
--- a/src/libstd/sys/unix/thread.rs
+++ b/src/libstd/sys/unix/thread.rs
@@ -11,6 +11,7 @@
 use core::prelude::*;
 
 use io;
+use boxed;
 use boxed::Box;
 use cmp;
 use mem;
@@ -241,13 +242,15 @@ pub unsafe fn create(stack: uint, p: Thunk) -> io::Result<rust_thread> {
         },
     };
 
-    let arg: *mut libc::c_void = mem::transmute(box p); // must box since sizeof(p)=2*uint
+    // must box since sizeof(p)=2*uint
+    let raw_p = boxed::into_raw(box p);
+    let arg = raw_p as *mut libc::c_void;
     let ret = pthread_create(&mut native, &attr, thread_start, arg);
     assert_eq!(pthread_attr_destroy(&mut attr), 0);
 
     if ret != 0 {
         // be sure to not leak the closure
-        let _p: Box<Box<FnOnce()+Send>> = mem::transmute(arg);
+        let _p: Box<Thunk> = Box::from_raw(raw_p);
         Err(io::Error::from_os_error(ret))
     } else {
         Ok(native)
diff --git a/src/libstd/sys/windows/thread.rs b/src/libstd/sys/windows/thread.rs
index f3a27877e5c..aa22b6b1307 100644
--- a/src/libstd/sys/windows/thread.rs
+++ b/src/libstd/sys/windows/thread.rs
@@ -10,9 +10,9 @@
 
 use prelude::v1::*;
 
+use boxed;
 use cmp;
 use io;
-use mem;
 use ptr;
 use libc;
 use libc::types::os::arch::extra::{LPSECURITY_ATTRIBUTES, SIZE_T, BOOL,
@@ -45,7 +45,8 @@ pub mod guard {
 }
 
 pub unsafe fn create(stack: uint, p: Thunk) -> io::Result<rust_thread> {
-    let arg: *mut libc::c_void = mem::transmute(box p);
+    let raw_p = boxed::into_raw(box p);
+    let arg = raw_p as *mut libc::c_void;
     // FIXME On UNIX, we guard against stack sizes that are too small but
     // that's because pthreads enforces that stacks are at least
     // PTHREAD_STACK_MIN bytes big.  Windows has no such lower limit, it's
@@ -61,7 +62,7 @@ pub unsafe fn create(stack: uint, p: Thunk) -> io::Result<rust_thread> {
 
     if ret as uint == 0 {
         // be sure to not leak the closure
-        let _p: Box<Thunk> = mem::transmute(arg);
+        let _p: Box<Thunk> = Box::from_raw(raw_p);
         Err(io::Error::last_os_error())
     } else {
         Ok(ret)
diff --git a/src/libstd/sys/windows/thread_local.rs b/src/libstd/sys/windows/thread_local.rs
index 0c24ab1fa09..30c483ac52f 100644
--- a/src/libstd/sys/windows/thread_local.rs
+++ b/src/libstd/sys/windows/thread_local.rs
@@ -12,7 +12,7 @@ use prelude::v1::*;
 
 use libc::types::os::arch::extra::{DWORD, LPVOID, BOOL};
 
-use mem;
+use boxed;
 use ptr;
 use rt;
 use sys_common::mutex::{MUTEX_INIT, Mutex};
@@ -133,13 +133,13 @@ unsafe fn init_dtors() {
     if !DTORS.is_null() { return }
 
     let dtors = box Vec::<(Key, Dtor)>::new();
-    DTORS = mem::transmute(dtors);
+    DTORS = boxed::into_raw(dtors);
 
     rt::at_exit(move|| {
         DTOR_LOCK.lock();
         let dtors = DTORS;
         DTORS = ptr::null_mut();
-        mem::transmute::<_, Box<Vec<(Key, Dtor)>>>(dtors);
+        Box::from_raw(dtors);
         assert!(DTORS.is_null()); // can't re-init after destructing
         DTOR_LOCK.unlock();
     });