@@ -53,7 +53,7 @@ impl Thread {
53
53
54
54
let stack_size = cmp:: max ( stack, min_stack_size ( & attr) ) ;
55
55
match pthread_attr_setstacksize ( & mut attr,
56
- stack_size as libc :: size_t ) {
56
+ stack_size) {
57
57
0 => { }
58
58
n => {
59
59
assert_eq ! ( n, libc:: EINVAL ) ;
@@ -64,7 +64,6 @@ impl Thread {
64
64
let page_size = os:: page_size ( ) ;
65
65
let stack_size = ( stack_size + page_size - 1 ) &
66
66
( -( page_size as isize - 1 ) as usize - 1 ) ;
67
- let stack_size = stack_size as libc:: size_t ;
68
67
assert_eq ! ( libc:: pthread_attr_setstacksize( & mut attr,
69
68
stack_size) , 0 ) ;
70
69
}
@@ -264,12 +263,8 @@ pub mod guard {
264
263
// Rellocate the last page of the stack.
265
264
// This ensures SIGBUS will be raised on
266
265
// stack overflow.
267
- let result = mmap ( stackaddr,
268
- psize as libc:: size_t ,
269
- PROT_NONE ,
270
- MAP_PRIVATE | MAP_ANON | MAP_FIXED ,
271
- -1 ,
272
- 0 ) ;
266
+ let result = mmap ( stackaddr, psize, PROT_NONE ,
267
+ MAP_PRIVATE | MAP_ANON | MAP_FIXED , -1 , 0 ) ;
273
268
274
269
if result != stackaddr || result == MAP_FAILED {
275
270
panic ! ( "failed to allocate a guard page" ) ;
@@ -293,8 +288,8 @@ pub mod guard {
293
288
294
289
#[ cfg( target_os = "macos" ) ]
295
290
pub unsafe fn current ( ) -> Option < usize > {
296
- Some ( ( libc:: pthread_get_stackaddr_np ( libc:: pthread_self ( ) ) as libc :: size_t -
297
- libc:: pthread_get_stacksize_np ( libc:: pthread_self ( ) ) ) as usize )
291
+ Some ( ( libc:: pthread_get_stackaddr_np ( libc:: pthread_self ( ) ) as usize -
292
+ libc:: pthread_get_stacksize_np ( libc:: pthread_self ( ) ) ) )
298
293
}
299
294
300
295
#[ cfg( any( target_os = "openbsd" , target_os = "bitrig" ) ) ]
@@ -306,10 +301,10 @@ pub mod guard {
306
301
let extra = if cfg ! ( target_os = "bitrig" ) { 3 } else { 1 } * os:: page_size ( ) ;
307
302
Some ( if libc:: pthread_main_np ( ) == 1 {
308
303
// main thread
309
- current_stack. ss_sp as usize - current_stack. ss_size as usize + extra
304
+ current_stack. ss_sp as usize - current_stack. ss_size + extra
310
305
} else {
311
306
// new thread
312
- current_stack. ss_sp as usize - current_stack. ss_size as usize
307
+ current_stack. ss_sp as usize - current_stack. ss_size
313
308
} )
314
309
}
315
310
@@ -335,11 +330,11 @@ pub mod guard {
335
330
& mut size) , 0 ) ;
336
331
337
332
ret = if cfg ! ( target_os = "freebsd" ) {
338
- Some ( stackaddr as usize - guardsize as usize )
333
+ Some ( stackaddr as usize - guardsize)
339
334
} else if cfg ! ( target_os = "netbsd" ) {
340
335
Some ( stackaddr as usize )
341
336
} else {
342
- Some ( stackaddr as usize + guardsize as usize )
337
+ Some ( stackaddr as usize + guardsize)
343
338
} ;
344
339
}
345
340
assert_eq ! ( libc:: pthread_attr_destroy( & mut attr) , 0 ) ;
@@ -358,8 +353,8 @@ fn min_stack_size(attr: *const libc::pthread_attr_t) -> usize {
358
353
weak ! ( fn __pthread_get_minstack( * const libc:: pthread_attr_t) -> libc:: size_t) ;
359
354
360
355
match __pthread_get_minstack. get ( ) {
361
- None => libc:: PTHREAD_STACK_MIN as usize ,
362
- Some ( f) => unsafe { f ( attr) as usize } ,
356
+ None => libc:: PTHREAD_STACK_MIN ,
357
+ Some ( f) => unsafe { f ( attr) } ,
363
358
}
364
359
}
365
360
@@ -368,7 +363,7 @@ fn min_stack_size(attr: *const libc::pthread_attr_t) -> usize {
368
363
#[ cfg( all( not( target_os = "linux" ) ,
369
364
not( target_os = "netbsd" ) ) ) ]
370
365
fn min_stack_size ( _: * const libc:: pthread_attr_t ) -> usize {
371
- libc:: PTHREAD_STACK_MIN as usize
366
+ libc:: PTHREAD_STACK_MIN
372
367
}
373
368
374
369
#[ cfg( target_os = "netbsd" ) ]
0 commit comments