@@ -15,7 +15,7 @@ pub type SegmentId = u32;
15
15
pub struct SegmentReader {
16
16
pub arena : ArenaPtr ,
17
17
pub ptr : * const Word ,
18
- pub size : WordCount
18
+ pub size : WordCount32
19
19
}
20
20
21
21
impl SegmentReader {
@@ -45,7 +45,7 @@ impl SegmentBuilder {
45
45
pub fn new ( arena : * mut BuilderArena ,
46
46
id : SegmentId ,
47
47
ptr : * mut Word ,
48
- size : WordCount ) -> SegmentBuilder {
48
+ size : WordCount32 ) -> SegmentBuilder {
49
49
SegmentBuilder {
50
50
reader : SegmentReader {
51
51
arena : BuilderArenaPtr ( arena) ,
@@ -57,21 +57,21 @@ impl SegmentBuilder {
57
57
}
58
58
}
59
59
60
- pub fn get_word_offset_to ( & mut self , ptr : * mut Word ) -> WordCount {
60
+ pub fn get_word_offset_to ( & mut self , ptr : * mut Word ) -> WordCount32 {
61
61
let this_addr : uint = self . reader . ptr . to_uint ( ) ;
62
62
let ptr_addr : uint = ptr. to_uint ( ) ;
63
63
assert ! ( ptr_addr >= this_addr) ;
64
64
let result = ( ptr_addr - this_addr) / BYTES_PER_WORD ;
65
- return result;
65
+ return result as u32 ;
66
66
}
67
67
68
68
#[ inline]
69
- pub fn current_size ( & self ) -> WordCount {
70
- ptr_sub ( self . pos , self . reader . ptr )
69
+ pub fn current_size ( & self ) -> WordCount32 {
70
+ ptr_sub ( self . pos , self . reader . ptr ) as u32
71
71
}
72
72
73
73
#[ inline]
74
- pub fn allocate ( & mut self , amount : WordCount ) -> Option < * mut Word > {
74
+ pub fn allocate ( & mut self , amount : WordCount32 ) -> Option < * mut Word > {
75
75
if amount > self . reader . size - self . current_size ( ) {
76
76
return None ;
77
77
} else {
@@ -82,7 +82,7 @@ impl SegmentBuilder {
82
82
}
83
83
84
84
#[ inline]
85
- pub fn get_ptr_unchecked ( & self , offset : WordCount ) -> * mut Word {
85
+ pub fn get_ptr_unchecked ( & self , offset : WordCount32 ) -> * mut Word {
86
86
unsafe {
87
87
:: std:: mem:: transmute ( self . reader . ptr . offset ( offset as int ) )
88
88
}
@@ -119,7 +119,7 @@ impl ReaderArena {
119
119
segment0 : SegmentReader {
120
120
arena : Null ,
121
121
ptr : unsafe { segments[ 0 ] . unsafe_get ( 0 ) } ,
122
- size : segments[ 0 ] . len ( )
122
+ size : segments[ 0 ] . len ( ) as u32
123
123
} ,
124
124
more_segments : Vec :: new ( ) ,
125
125
cap_table : Vec :: new ( ) ,
@@ -137,7 +137,7 @@ impl ReaderArena {
137
137
let segment_reader = SegmentReader {
138
138
arena : arena_ptr,
139
139
ptr : unsafe { segment. unsafe_get ( 0 ) } ,
140
- size : segment. len ( )
140
+ size : segment. len ( ) as u32
141
141
} ;
142
142
more_segment_readers. push ( segment_reader) ;
143
143
}
@@ -167,7 +167,7 @@ pub struct BuilderArena {
167
167
pub more_segments : Vec < Box < SegmentBuilder > > ,
168
168
pub allocation_strategy : message:: AllocationStrategy ,
169
169
pub owned_memory : Vec < * mut Word > ,
170
- pub next_size : uint ,
170
+ pub next_size : u32 ,
171
171
pub cap_table : Vec < Option < Box < ClientHook +Send > > > ,
172
172
pub fail_fast : bool ,
173
173
}
@@ -181,7 +181,7 @@ impl Drop for BuilderArena {
181
181
}
182
182
183
183
pub enum FirstSegment < ' a > {
184
- NumWords ( uint ) ,
184
+ NumWords ( u32 ) ,
185
185
ZeroedWords ( & ' a mut [ Word ] )
186
186
}
187
187
@@ -191,15 +191,15 @@ impl BuilderArena {
191
191
first_segment : FirstSegment ,
192
192
fail_fast : bool ) -> Box < BuilderArena > {
193
193
194
- let ( first_segment, num_words, owned_memory) : ( * mut Word , uint , Vec < * mut Word > ) = unsafe {
194
+ let ( first_segment, num_words, owned_memory) : ( * mut Word , u32 , Vec < * mut Word > ) = unsafe {
195
195
match first_segment {
196
196
NumWords ( n) => {
197
197
let ptr = :: std:: mem:: transmute (
198
198
libc:: calloc ( n as libc:: size_t ,
199
199
BYTES_PER_WORD as libc:: size_t ) ) ;
200
200
( ptr, n, vec ! ( ptr) )
201
201
}
202
- ZeroedWords ( w) => ( w. as_mut_ptr ( ) , w. len ( ) , Vec :: new ( ) )
202
+ ZeroedWords ( w) => ( w. as_mut_ptr ( ) , w. len ( ) as u32 , Vec :: new ( ) )
203
203
} } ;
204
204
205
205
let mut result = box BuilderArena {
@@ -225,7 +225,7 @@ impl BuilderArena {
225
225
result
226
226
}
227
227
228
- pub fn allocate_owned_memory ( & mut self , minimum_size : WordCount ) -> ( * mut Word , WordCount ) {
228
+ pub fn allocate_owned_memory ( & mut self , minimum_size : WordCount32 ) -> ( * mut Word , WordCount32 ) {
229
229
let size = :: std:: cmp:: max ( minimum_size, self . next_size ) ;
230
230
let new_words : * mut Word = unsafe {
231
231
:: std:: mem:: transmute ( libc:: calloc ( size as libc:: size_t ,
@@ -242,7 +242,7 @@ impl BuilderArena {
242
242
243
243
244
244
#[ inline]
245
- pub fn allocate ( & mut self , amount : WordCount ) -> ( * mut SegmentBuilder , * mut Word ) {
245
+ pub fn allocate ( & mut self , amount : WordCount32 ) -> ( * mut SegmentBuilder , * mut Word ) {
246
246
unsafe {
247
247
match self . segment0 . allocate ( amount) {
248
248
Some ( result) => { return ( ( & mut self . segment0 ) as * mut SegmentBuilder , result) }
@@ -285,18 +285,18 @@ impl BuilderArena {
285
285
if self . more_segments . len ( ) == 0 {
286
286
:: std:: slice:: raw:: buf_as_slice :: < Word , T > (
287
287
self . segment0 . reader . ptr ,
288
- self . segment0 . current_size ( ) ,
288
+ self . segment0 . current_size ( ) as uint ,
289
289
|v| cont ( [ v] ) )
290
290
} else {
291
291
let mut result = Vec :: new ( ) ;
292
292
result. push ( :: std:: mem:: transmute (
293
293
:: std:: raw:: Slice { data : self . segment0 . reader . ptr ,
294
- len : self . segment0 . current_size ( ) } ) ) ;
294
+ len : self . segment0 . current_size ( ) as uint } ) ) ;
295
295
296
296
for seg in self . more_segments . iter ( ) {
297
297
result. push ( :: std:: mem:: transmute (
298
298
:: std:: raw:: Slice { data : seg. reader . ptr ,
299
- len : seg. current_size ( ) } ) ) ;
299
+ len : seg. current_size ( ) as uint } ) ) ;
300
300
}
301
301
cont ( result. as_slice ( ) )
302
302
}
0 commit comments