Skip to content

Commit d8d1b8f

Browse files
committed
auto merge of #9896 : brson/rust/stdmem, r=alexcrichton
This is progress toward removing std::sys.
2 parents 51709fc + 34d376f commit d8d1b8f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+288
-269
lines changed

doc/po/ja/rust.md.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1842,7 +1842,7 @@ msgid ""
18421842
"The type parameters can also be explicitly supplied in a trailing [path]"
18431843
"(#paths) component after the function name. This might be necessary if there "
18441844
"is not sufficient context to determine the type parameters. For example, "
1845-
"`sys::size_of::<u32>() == 4`."
1845+
"`mem::size_of::<u32>() == 4`."
18461846
msgstr ""
18471847

18481848
#. type: Plain text

doc/po/ja/tutorial-ffi.md.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ msgid ""
327327
"impl<T: Send> Unique<T> {\n"
328328
" pub fn new(value: T) -> Unique<T> {\n"
329329
" unsafe {\n"
330-
" let ptr = malloc(std::sys::size_of::<T>() as size_t) as *mut T;\n"
330+
" let ptr = malloc(std::mem::size_of::<T>() as size_t) as *mut T;\n"
331331
" assert!(!ptr::is_null(ptr));\n"
332332
" // `*ptr` is uninitialized, and `*ptr = value` would attempt to destroy it\n"
333333
" intrinsics::move_val_init(&mut *ptr, value);\n"

doc/po/rust.md.pot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1842,7 +1842,7 @@ msgid ""
18421842
"The type parameters can also be explicitly supplied in a trailing [path]"
18431843
"(#paths) component after the function name. This might be necessary if there "
18441844
"is not sufficient context to determine the type parameters. For example, "
1845-
"`sys::size_of::<u32>() == 4`."
1845+
"`mem::size_of::<u32>() == 4`."
18461846
msgstr ""
18471847

18481848
#. type: Plain text

doc/po/tutorial-ffi.md.pot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ msgid ""
327327
"impl<T: Send> Unique<T> {\n"
328328
" pub fn new(value: T) -> Unique<T> {\n"
329329
" unsafe {\n"
330-
" let ptr = malloc(std::sys::size_of::<T>() as size_t) as *mut T;\n"
330+
" let ptr = malloc(std::mem::size_of::<T>() as size_t) as *mut T;\n"
331331
" assert!(!ptr::is_null(ptr));\n"
332332
" // `*ptr` is uninitialized, and `*ptr = value` would attempt to destroy it\n"
333333
" intrinsics::move_val_init(&mut *ptr, value);\n"

doc/rust.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,7 @@ with `int`, and require the closure parameter to have type
975975
The type parameters can also be explicitly supplied in a trailing
976976
[path](#paths) component after the function name. This might be necessary
977977
if there is not sufficient context to determine the type parameters. For
978-
example, `sys::size_of::<u32>() == 4`.
978+
example, `mem::size_of::<u32>() == 4`.
979979

980980
Since a parameter type is opaque to the generic function, the set of
981981
operations that can be performed on it is limited. Values of parameter

doc/tutorial-ffi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ impl<T: Send> Unique<T> {
300300
#[inline(never)];
301301
302302
unsafe {
303-
let ptr = malloc(std::sys::size_of::<T>() as size_t) as *mut T;
303+
let ptr = malloc(std::mem::size_of::<T>() as size_t) as *mut T;
304304
assert!(!ptr::is_null(ptr));
305305
// `*ptr` is uninitialized, and `*ptr = value` would attempt to destroy it
306306
intrinsics::move_val_init(&mut *ptr, value);

src/libextra/arena.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ use std::cast::{transmute, transmute_mut, transmute_mut_region};
4242
use std::cast;
4343
use std::num;
4444
use std::ptr;
45-
use std::sys;
45+
use std::mem;
4646
use std::uint;
4747
use std::vec;
4848
use std::unstable::intrinsics;
@@ -123,7 +123,7 @@ unsafe fn destroy_chunk(chunk: &Chunk) {
123123
let (tydesc, is_done) = un_bitpack_tydesc_ptr(*tydesc_data);
124124
let (size, align) = ((*tydesc).size, (*tydesc).align);
125125

126-
let after_tydesc = idx + sys::size_of::<*TyDesc>();
126+
let after_tydesc = idx + mem::size_of::<*TyDesc>();
127127

128128
let start = round_up_to(after_tydesc, align);
129129

@@ -134,7 +134,7 @@ unsafe fn destroy_chunk(chunk: &Chunk) {
134134
}
135135

136136
// Find where the next tydesc lives
137-
idx = round_up_to(start + size, sys::pref_align_of::<*TyDesc>());
137+
idx = round_up_to(start + size, mem::pref_align_of::<*TyDesc>());
138138
}
139139
}
140140

@@ -220,7 +220,7 @@ impl Arena {
220220
let head = transmute_mut_region(&mut self.head);
221221

222222
tydesc_start = head.fill;
223-
after_tydesc = head.fill + sys::size_of::<*TyDesc>();
223+
after_tydesc = head.fill + mem::size_of::<*TyDesc>();
224224
start = round_up_to(after_tydesc, align);
225225
end = start + n_bytes;
226226
}
@@ -230,7 +230,7 @@ impl Arena {
230230
}
231231

232232
let head = transmute_mut_region(&mut self.head);
233-
head.fill = round_up_to(end, sys::pref_align_of::<*TyDesc>());
233+
head.fill = round_up_to(end, mem::pref_align_of::<*TyDesc>());
234234

235235
//debug2!("idx = {}, size = {}, align = {}, fill = {}",
236236
// start, n_bytes, align, head.fill);

src/libstd/at_vec.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use clone::Clone;
1414
use container::Container;
1515
use iter::Iterator;
1616
use option::{Option, Some, None};
17-
use sys;
17+
use mem;
1818
use unstable::raw::Repr;
1919
use vec::{ImmutableVector, OwnedVector};
2020

@@ -26,7 +26,7 @@ use vec::{ImmutableVector, OwnedVector};
2626
pub fn capacity<T>(v: @[T]) -> uint {
2727
unsafe {
2828
let box = v.repr();
29-
(*box).data.alloc / sys::size_of::<T>()
29+
(*box).data.alloc / mem::size_of::<T>()
3030
}
3131
}
3232

@@ -160,7 +160,7 @@ pub mod raw {
160160
use cast::{transmute, transmute_copy};
161161
use libc;
162162
use ptr;
163-
use sys;
163+
use mem;
164164
use uint;
165165
use unstable::intrinsics::{move_val_init, TyDesc};
166166
use unstable::intrinsics;
@@ -176,7 +176,7 @@ pub mod raw {
176176
#[inline]
177177
pub unsafe fn set_len<T>(v: &mut @[T], new_len: uint) {
178178
let repr: *mut Box<Vec<T>> = cast::transmute_copy(v);
179-
(*repr).data.fill = new_len * sys::size_of::<T>();
179+
(*repr).data.fill = new_len * mem::size_of::<T>();
180180
}
181181

182182
/**
@@ -199,7 +199,7 @@ pub mod raw {
199199
unsafe fn push_fast<T>(v: &mut @[T], initval: T) {
200200
let repr: *mut Box<Vec<T>> = cast::transmute_copy(v);
201201
let amt = v.len();
202-
(*repr).data.fill += sys::size_of::<T>();
202+
(*repr).data.fill += mem::size_of::<T>();
203203
let p = ptr::offset(&(*repr).data.data as *T, amt as int) as *mut T;
204204
move_val_init(&mut(*p), initval);
205205
}
@@ -236,7 +236,7 @@ pub mod raw {
236236
unsafe {
237237
if n > (**ptr).data.alloc / (*ty).size {
238238
let alloc = n * (*ty).size;
239-
let total_size = alloc + sys::size_of::<Vec<()>>();
239+
let total_size = alloc + mem::size_of::<Vec<()>>();
240240
if alloc / (*ty).size != n || total_size < alloc {
241241
fail2!("vector size is too large: {}", n);
242242
}

src/libstd/cast.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//! Unsafe casting functions
1212
1313
use ptr::RawPtr;
14-
use sys;
14+
use mem;
1515
use unstable::intrinsics;
1616

1717
/// Casts the value at `src` to U. The two types must have the same length.
@@ -21,7 +21,7 @@ pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
2121
let mut dest: U = intrinsics::uninit();
2222
let dest_ptr: *mut u8 = transmute(&mut dest);
2323
let src_ptr: *u8 = transmute(src);
24-
intrinsics::memcpy32(dest_ptr, src_ptr, sys::size_of::<U>() as u32);
24+
intrinsics::memcpy32(dest_ptr, src_ptr, mem::size_of::<U>() as u32);
2525
dest
2626
}
2727

@@ -32,7 +32,7 @@ pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
3232
let mut dest: U = intrinsics::uninit();
3333
let dest_ptr: *mut u8 = transmute(&mut dest);
3434
let src_ptr: *u8 = transmute(src);
35-
intrinsics::memcpy64(dest_ptr, src_ptr, sys::size_of::<U>() as u64);
35+
intrinsics::memcpy64(dest_ptr, src_ptr, mem::size_of::<U>() as u64);
3636
dest
3737
}
3838

src/libstd/cleanup.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ fn debug_mem() -> bool {
6868
/// Destroys all managed memory (i.e. @ boxes) held by the current task.
6969
pub unsafe fn annihilate() {
7070
use rt::local_heap::local_free;
71-
use sys;
71+
use mem;
7272
use managed;
7373

7474
let mut stats = AnnihilateStats {
@@ -115,7 +115,7 @@ pub unsafe fn annihilate() {
115115
if !uniq {
116116
stats.n_bytes_freed +=
117117
(*((*box).type_desc)).size
118-
+ sys::size_of::<raw::Box<()>>();
118+
+ mem::size_of::<raw::Box<()>>();
119119
local_free(box as *i8);
120120
}
121121
true

0 commit comments

Comments
 (0)