Skip to content

Commit 985acfd

Browse files
committed
Merge libsync into libstd
This patch merges the `libsync` crate into `libstd`, undoing part of the facade. This is in preparation for ultimately merging `librustrt`, as well as the upcoming rewrite of `sync`. Because this removes the `libsync` crate, it is a: [breaking-change] However, all uses of `libsync` should be able to reroute through `std::sync` and `std::comm` instead.
1 parent 54c628c commit 985acfd

File tree

20 files changed

+103
-159
lines changed

20 files changed

+103
-159
lines changed

mk/crates.mk

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
################################################################################
5151

5252
TARGET_CRATES := libc std flate arena term \
53-
serialize sync getopts collections test time rand \
53+
serialize getopts collections test time rand \
5454
log regex graphviz core rbml alloc rustrt \
5555
unicode
5656
HOST_CRATES := syntax rustc rustc_trans rustdoc regex_macros fmt_macros \
@@ -63,7 +63,7 @@ DEPS_libc := core
6363
DEPS_unicode := core
6464
DEPS_alloc := core libc native:jemalloc
6565
DEPS_rustrt := alloc core libc collections native:rustrt_native
66-
DEPS_std := core libc rand alloc collections rustrt sync unicode \
66+
DEPS_std := core libc rand alloc collections rustrt unicode \
6767
native:rust_builtin native:backtrace
6868
DEPS_graphviz := std
6969
DEPS_syntax := std term serialize log fmt_macros arena libc
@@ -81,7 +81,6 @@ DEPS_glob := std
8181
DEPS_serialize := std log
8282
DEPS_rbml := std log serialize
8383
DEPS_term := std log
84-
DEPS_sync := core alloc rustrt collections
8584
DEPS_getopts := std
8685
DEPS_collections := core alloc unicode
8786
DEPS_num := std

src/etc/licenseck.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,9 @@
3838
"rt/isaac/randport.cpp", # public domain
3939
"rt/isaac/rand.h", # public domain
4040
"rt/isaac/standard.h", # public domain
41-
"libsync/mpsc_queue.rs", # BSD
42-
"libsync/spsc_queue.rs", # BSD
43-
"libsync/mpmc_bounded_queue.rs", # BSD
44-
"libsync/mpsc_intrusive.rs", # BSD
41+
"libstd/sync/mpsc_queue.rs", # BSD
42+
"libstd/sync/spsc_queue.rs", # BSD
43+
"libstd/sync/mpmc_bounded_queue.rs", # BSD
4544
"test/bench/shootout-binarytrees.rs", # BSD
4645
"test/bench/shootout-chameneos-redux.rs", # BSD
4746
"test/bench/shootout-fannkuch-redux.rs", # BSD

src/libsync/comm/mod.rs renamed to src/libstd/comm/mod.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -338,12 +338,11 @@ macro_rules! test (
338338

339339
extern crate rustrt;
340340

341-
use std::prelude::*;
341+
use prelude::*;
342342

343343
use comm::*;
344344
use super::*;
345-
use super::super::*;
346-
use std::task;
345+
use task;
347346

348347
$(#[$a])* #[test] fn f() { $b }
349348
}
@@ -1019,9 +1018,9 @@ impl<T: Send> Drop for Receiver<T> {
10191018

10201019
#[cfg(test)]
10211020
mod test {
1022-
use std::prelude::*;
1021+
use prelude::*;
10231022

1024-
use std::os;
1023+
use os;
10251024
use super::*;
10261025

10271026
pub fn stress_factor() -> uint {
@@ -1554,8 +1553,8 @@ mod test {
15541553

15551554
#[cfg(test)]
15561555
mod sync_tests {
1557-
use std::prelude::*;
1558-
use std::os;
1556+
use prelude::*;
1557+
use os;
15591558

15601559
pub fn stress_factor() -> uint {
15611560
match os::getenv("RUST_TEST_STRESS") {

src/libsync/comm/oneshot.rs renamed to src/libstd/comm/oneshot.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use core::mem;
4444
use rustrt::local::Local;
4545
use rustrt::task::{Task, BlockedTask};
4646

47-
use atomic;
47+
use sync::atomic;
4848
use comm::Receiver;
4949

5050
// Various states you can find a port in.

src/libsync/comm/select.rs renamed to src/libstd/comm/select.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,9 @@ impl Iterator<*mut Handle<'static, ()>> for Packets {
325325
#[cfg(test)]
326326
#[allow(unused_imports)]
327327
mod test {
328-
use std::prelude::*;
328+
use prelude::*;
329329

330-
use super::super::*;
330+
use super::*;
331331

332332
// Don't use the libstd version so we can pull in the right Select structure
333333
// (std::comm points at the wrong one)

src/libsync/comm/shared.rs renamed to src/libstd/comm/shared.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ use rustrt::mutex::NativeMutex;
3030
use rustrt::task::{Task, BlockedTask};
3131
use rustrt::thread::Thread;
3232

33-
use atomic;
34-
use mpsc_queue as mpsc;
33+
use sync::atomic;
34+
use sync::mpsc_queue as mpsc;
3535

3636
const DISCONNECTED: int = int::MIN;
3737
const FUDGE: int = 1024;

src/libsync/comm/stream.rs renamed to src/libstd/comm/stream.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ use rustrt::local::Local;
3131
use rustrt::task::{Task, BlockedTask};
3232
use rustrt::thread::Thread;
3333

34-
use atomic;
34+
use sync::atomic;
35+
use sync::spsc_queue as spsc;
3536
use comm::Receiver;
36-
use spsc_queue as spsc;
3737

3838
const DISCONNECTED: int = int::MIN;
3939
#[cfg(test)]

src/libsync/comm/sync.rs renamed to src/libstd/comm/sync.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,14 @@ pub use self::Failure::*;
3939
use self::Blocker::*;
4040

4141
use alloc::boxed::Box;
42-
use collections::Vec;
42+
use vec::Vec;
4343
use core::mem;
4444
use core::cell::UnsafeCell;
4545
use rustrt::local::Local;
4646
use rustrt::mutex::{NativeMutex, LockGuard};
4747
use rustrt::task::{Task, BlockedTask};
4848

49-
use atomic;
49+
use sync::atomic;
5050

5151
pub struct Packet<T> {
5252
/// Only field outside of the mutex. Just done for kicks, but mainly because

src/libstd/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ extern crate unicode;
124124
extern crate core;
125125
extern crate "collections" as core_collections;
126126
extern crate "rand" as core_rand;
127-
extern crate "sync" as core_sync;
128127
extern crate libc;
129128
extern crate rustrt;
130129

@@ -173,8 +172,6 @@ pub use rustrt::c_str;
173172

174173
pub use unicode::char;
175174

176-
pub use core_sync::comm;
177-
178175
/* Exported macros */
179176

180177
pub mod macros;
@@ -236,6 +233,7 @@ pub mod hash;
236233

237234
pub mod task;
238235
pub mod sync;
236+
pub mod comm;
239237

240238
#[cfg(unix)]
241239
#[path = "sys/unix/mod.rs"] mod sys;

src/libsync/atomic.rs renamed to src/libstd/sync/atomic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ impl<T: Send> Drop for AtomicOption<T> {
178178

179179
#[cfg(test)]
180180
mod test {
181-
use std::prelude::*;
181+
use prelude::*;
182182
use super::*;
183183

184184
#[test]

0 commit comments

Comments
 (0)