File tree 2 files changed +7
-10
lines changed
2 files changed +7
-10
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,6 @@ export memmove;
12
12
#[ abi = "rust-intrinsic" ]
13
13
native mod rusti {
14
14
fn addr_of < T > ( val : T ) -> * T ;
15
- fn ptr_offset < T > ( ptr : * T , count : libc:: uintptr_t ) -> * T ;
16
15
fn memcpy < T > ( dst : * T , src : * T , count : libc:: uintptr_t ) ;
17
16
fn memmove < T > ( dst : * T , src : * T , count : libc:: uintptr_t ) ;
18
17
}
@@ -29,14 +28,14 @@ fn mut_addr_of<T>(val: T) -> *mutable T unsafe {
29
28
30
29
#[ doc = "Calculate the offset from a pointer" ]
31
30
#[ inline( always) ]
32
- fn offset < T > ( ptr : * T , count : uint ) -> * T {
33
- ret rusti :: ptr_offset ( ptr, count) ;
31
+ fn offset < T > ( ptr : * T , count : uint ) -> * T unsafe {
32
+ ( ptr as uint + count * sys :: size_of :: < T > ( ) ) as * T
34
33
}
35
34
36
35
#[ doc = "Calculate the offset from a mutable pointer" ]
37
36
#[ inline( always) ]
38
37
fn mut_offset < T > ( ptr : * mutable T , count : uint ) -> * mutable T {
39
- ret rusti :: ptr_offset ( ptr as * T , count) as * mutable T ;
38
+ ( ptr as uint + count * sys :: size_of :: < T > ( ) ) as * mutable T
40
39
}
41
40
42
41
Original file line number Diff line number Diff line change @@ -74,11 +74,6 @@ export vec_len;
74
74
export unsafe;
75
75
export u8;
76
76
77
- #[ abi = "rust-intrinsic" ]
78
- native mod rusti {
79
- fn vec_len < T > ( & & v: [ const T ] ) -> libc:: size_t ;
80
- }
81
-
82
77
#[ abi = "cdecl" ]
83
78
native mod rustrt {
84
79
fn vec_reserve_shared < T > ( t : * sys:: type_desc ,
@@ -122,7 +117,10 @@ fn reserve<T>(&v: [const T], n: uint) {
122
117
123
118
#[ doc = "Returns the length of a vector" ]
124
119
#[ inline( always) ]
125
- pure fn len < T > ( v : [ const T ] ) -> uint { unchecked { rusti : : vec_len ( v) } }
120
+ pure fn len < T > ( & & v: [ const T ] ) -> uint unsafe {
121
+ let repr: * * unsafe :: vec_repr = :: unsafe:: reinterpret_cast ( addr_of ( v) ) ;
122
+ ( * * repr) . fill / sys:: size_of :: < T > ( )
123
+ }
126
124
127
125
#[ doc = "
128
126
Creates and initializes an immutable vector.
You can’t perform that action at this time.
0 commit comments