Skip to content

Commit 9ca2005

Browse files
committed
rt: Remove size_of and align_of functions. Now written in Rust
1 parent a9f7cbe commit 9ca2005

File tree

3 files changed

+4
-18
lines changed

3 files changed

+4
-18
lines changed

src/lib/sys.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ native mod rustrt {
1616
// available outside this crate. Otherwise it's
1717
// visible-in-crate, but not re-exported.
1818
fn last_os_error() -> str;
19-
fn size_of(td: *type_desc) -> uint;
20-
fn align_of(td: *type_desc) -> uint;
2119
fn refcount<T>(t: @T) -> uint;
2220
fn do_gc();
2321
fn unsupervise();
@@ -52,17 +50,17 @@ Function: size_of
5250
5351
Returns the size of a type
5452
*/
55-
fn size_of<T>() -> uint {
56-
ret rustrt::size_of(get_type_desc::<T>());
53+
fn size_of<T>() -> uint unsafe {
54+
ret (*get_type_desc::<T>()).size;
5755
}
5856

5957
/*
6058
Function: align_of
6159
6260
Returns the alignment of a type
6361
*/
64-
fn align_of<T>() -> uint {
65-
ret rustrt::align_of(get_type_desc::<T>());
62+
fn align_of<T>() -> uint unsafe {
63+
ret (*get_type_desc::<T>()).align;
6664
}
6765

6866
/*

src/rt/rust_builtin.cpp

-10
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,6 @@ void squareroot(double *input, double *output) {
7575
*output = sqrt(*input);
7676
}
7777

78-
extern "C" CDECL size_t
79-
size_of(type_desc *t) {
80-
return t->size;
81-
}
82-
83-
extern "C" CDECL size_t
84-
align_of(type_desc *t) {
85-
return t->align;
86-
}
87-
8878
extern "C" CDECL void
8979
leak(void *thing) {
9080
// Do nothing. Call this with move-mode in order to say "Don't worry rust,

src/rt/rustrt.def.in

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
__morestack
2-
align_of
32
chan_id_send
43
check_claims
54
debug_box
@@ -50,7 +49,6 @@ rust_task_sleep
5049
rust_get_task
5150
set_min_stack
5251
sched_threads
53-
size_of
5452
squareroot
5553
start_task
5654
vec_reserve_shared

0 commit comments

Comments
 (0)