diff options
| author | Flavio Percoco <flaper87@gmail.com> | 2014-12-06 11:39:25 -0500 |
|---|---|---|
| committer | Flavio Percoco <flaper87@gmail.com> | 2014-12-26 17:26:32 +0100 |
| commit | fb803a857000813e4d572900799f0498fb20050b (patch) | |
| tree | a1247d535c6dbb3fcaca0743cda7900481d14053 /src/libstd/sys | |
| parent | c43efee6def9a4a4e943feef0236d3e17b3f581d (diff) | |
| download | rust-fb803a857000813e4d572900799f0498fb20050b.tar.gz rust-fb803a857000813e4d572900799f0498fb20050b.zip | |
Require types to opt-in Sync
Diffstat (limited to 'src/libstd/sys')
| -rw-r--r-- | src/libstd/sys/common/helper_thread.rs | 4 | ||||
| -rw-r--r-- | src/libstd/sys/common/mutex.rs | 1 | ||||
| -rw-r--r-- | src/libstd/sys/unix/c.rs | 6 | ||||
| -rw-r--r-- | src/libstd/sys/unix/mutex.rs | 7 | ||||
| -rw-r--r-- | src/libstd/sys/unix/pipe.rs | 2 | ||||
| -rw-r--r-- | src/libstd/sys/unix/stack_overflow.rs | 2 | ||||
| -rw-r--r-- | src/libstd/sys/unix/tcp.rs | 2 |
7 files changed, 20 insertions, 4 deletions
diff --git a/src/libstd/sys/common/helper_thread.rs b/src/libstd/sys/common/helper_thread.rs index 421778e2012..9df69d8e0d6 100644 --- a/src/libstd/sys/common/helper_thread.rs +++ b/src/libstd/sys/common/helper_thread.rs @@ -59,6 +59,10 @@ pub struct Helper<M> { pub shutdown: UnsafeCell<bool>, } +impl<M:Send> Send for Helper<M> { } + +impl<M:Send> Sync for Helper<M> { } + impl<M: Send> Helper<M> { /// Lazily boots a helper thread, becoming a no-op if the helper has already /// been spawned. diff --git a/src/libstd/sys/common/mutex.rs b/src/libstd/sys/common/mutex.rs index 1a8a92a105a..5869c280517 100644 --- a/src/libstd/sys/common/mutex.rs +++ b/src/libstd/sys/common/mutex.rs @@ -15,6 +15,7 @@ use sys::mutex as imp; /// This is the thinnest cross-platform wrapper around OS mutexes. All usage of /// this mutex is unsafe and it is recommended to instead use the safe wrapper /// at the top level of the crate instead of this type. +#[deriving(Sync)] pub struct Mutex(imp::Mutex); /// Constant initializer for statically allocated mutexes. diff --git a/src/libstd/sys/unix/c.rs b/src/libstd/sys/unix/c.rs index e76f2a2b872..a5796f8dd01 100644 --- a/src/libstd/sys/unix/c.rs +++ b/src/libstd/sys/unix/c.rs @@ -162,6 +162,9 @@ mod signal { sa_restorer: *mut libc::c_void, } + impl ::kinds::Send for sigaction { } + impl ::kinds::Sync for sigaction { } + #[repr(C)] #[cfg(target_word_size = "32")] pub struct sigset_t { @@ -211,6 +214,9 @@ mod signal { sa_resv: [libc::c_int, ..1], } + impl ::kinds::Send for sigaction { } + impl ::kinds::Sync for sigaction { } + #[repr(C)] pub struct sigset_t { __val: [libc::c_ulong, ..32], diff --git a/src/libstd/sys/unix/mutex.rs b/src/libstd/sys/unix/mutex.rs index 2f01c53cb2c..52ed0649694 100644 --- a/src/libstd/sys/unix/mutex.rs +++ b/src/libstd/sys/unix/mutex.rs @@ -8,11 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use cell::UnsafeCell; +use cell::{UnsafeCell, RacyCell}; use sys::sync as ffi; use sys_common::mutex; -pub struct Mutex { inner: UnsafeCell<ffi::pthread_mutex_t> } +#[deriving(Sync)] +pub struct Mutex { inner: RacyCell<ffi::pthread_mutex_t> } #[inline] pub unsafe fn raw(m: &Mutex) -> *mut ffi::pthread_mutex_t { @@ -20,7 +21,7 @@ pub unsafe fn raw(m: &Mutex) -> *mut ffi::pthread_mutex_t { } pub const MUTEX_INIT: Mutex = Mutex { - inner: UnsafeCell { value: ffi::PTHREAD_MUTEX_INITIALIZER }, + inner: RacyCell(UnsafeCell { value: ffi::PTHREAD_MUTEX_INITIALIZER }), }; impl Mutex { diff --git a/src/libstd/sys/unix/pipe.rs b/src/libstd/sys/unix/pipe.rs index 348b7cfad33..8d1010937bc 100644 --- a/src/libstd/sys/unix/pipe.rs +++ b/src/libstd/sys/unix/pipe.rs @@ -210,6 +210,7 @@ impl Clone for UnixStream { // Unix Listener //////////////////////////////////////////////////////////////////////////////// +#[deriving(Sync)] pub struct UnixListener { inner: Inner, path: CString, @@ -252,6 +253,7 @@ pub struct UnixAcceptor { deadline: u64, } +#[deriving(Sync)] struct AcceptorInner { listener: UnixListener, reader: FileDesc, diff --git a/src/libstd/sys/unix/stack_overflow.rs b/src/libstd/sys/unix/stack_overflow.rs index 340f9514241..bcbbb8766b7 100644 --- a/src/libstd/sys/unix/stack_overflow.rs +++ b/src/libstd/sys/unix/stack_overflow.rs @@ -160,7 +160,7 @@ mod imp { pub static SIGSTKSZ: libc::size_t = 8192; - pub static SIG_DFL: sighandler_t = 0i as sighandler_t; + pub const SIG_DFL: sighandler_t = 0i as sighandler_t; // This definition is not as accurate as it could be, {si_addr} is // actually a giant union. Currently we're only interested in that field, diff --git a/src/libstd/sys/unix/tcp.rs b/src/libstd/sys/unix/tcp.rs index 5c99ad1e0ce..60ca76171b1 100644 --- a/src/libstd/sys/unix/tcp.rs +++ b/src/libstd/sys/unix/tcp.rs @@ -29,6 +29,7 @@ pub use sys_common::net::TcpStream; // TCP listeners //////////////////////////////////////////////////////////////////////////////// +#[deriving(Sync)] pub struct TcpListener { pub inner: FileDesc, } @@ -89,6 +90,7 @@ pub struct TcpAcceptor { deadline: u64, } +#[deriving(Sync)] struct AcceptorInner { listener: TcpListener, reader: FileDesc, |
