@@ -50,24 +50,27 @@ impl Thread {
50
50
let p = Box :: into_raw ( Box :: new ( p) ) ;
51
51
let mut native: libc:: pthread_t = mem:: zeroed ( ) ;
52
52
let mut attr: mem:: MaybeUninit < libc:: pthread_attr_t > = mem:: MaybeUninit :: uninit ( ) ;
53
- assert_eq ! ( libc:: pthread_attr_init( ( & raw mut attr) as * mut _ ) , 0 ) ;
54
- let mut attr: libc:: pthread_attr_t = unsafe { attr. assume_init ( ) } ;
53
+ assert_eq ! ( libc:: pthread_attr_init( attr. as_mut_ptr ( ) ) , 0 ) ;
54
+ // let mut attr: libc::pthread_attr_t = unsafe { attr.assume_init() };
55
55
56
56
#[ cfg( target_os = "espidf" ) ]
57
57
if stack > 0 {
58
58
// Only set the stack if a non-zero value is passed
59
59
// 0 is used as an indication that the default stack size configured in the ESP-IDF menuconfig system should be used
60
60
assert_eq ! (
61
- libc:: pthread_attr_setstacksize( & mut attr, cmp:: max( stack, min_stack_size( & attr) ) ) ,
61
+ libc:: pthread_attr_setstacksize(
62
+ attr. as_mut_ptr( ) ,
63
+ cmp:: max( stack, min_stack_size( & attr) )
64
+ ) ,
62
65
0
63
66
) ;
64
67
}
65
68
66
69
#[ cfg( not( target_os = "espidf" ) ) ]
67
70
{
68
- let stack_size = cmp:: max ( stack, min_stack_size ( & attr) ) ;
71
+ let stack_size = cmp:: max ( stack, min_stack_size ( attr. as_ptr ( ) ) ) ;
69
72
70
- match libc:: pthread_attr_setstacksize ( & mut attr, stack_size) {
73
+ match libc:: pthread_attr_setstacksize ( attr. as_mut_ptr ( ) , stack_size) {
71
74
0 => { }
72
75
n => {
73
76
assert_eq ! ( n, libc:: EINVAL ) ;
@@ -78,16 +81,16 @@ impl Thread {
78
81
let page_size = os:: page_size ( ) ;
79
82
let stack_size =
80
83
( stack_size + page_size - 1 ) & ( -( page_size as isize - 1 ) as usize - 1 ) ;
81
- assert_eq ! ( libc:: pthread_attr_setstacksize( & mut attr, stack_size) , 0 ) ;
84
+ assert_eq ! ( libc:: pthread_attr_setstacksize( attr. as_mut_ptr ( ) , stack_size) , 0 ) ;
82
85
}
83
86
} ;
84
87
}
85
88
86
- let ret = libc:: pthread_create ( & mut native, & attr, thread_start, p as * mut _ ) ;
89
+ let ret = libc:: pthread_create ( & mut native, attr. as_ptr ( ) , thread_start, p as * mut _ ) ;
87
90
// Note: if the thread creation fails and this assert fails, then p will
88
91
// be leaked. However, an alternative design could cause double-free
89
92
// which is clearly worse.
90
- assert_eq ! ( libc:: pthread_attr_destroy( & mut attr) , 0 ) ;
93
+ assert_eq ! ( libc:: pthread_attr_destroy( attr. as_mut_ptr ( ) ) , 0 ) ;
91
94
92
95
return if ret != 0 {
93
96
// The thread failed to start and as a result p was not consumed. Therefore, it is
0 commit comments