@@ -319,21 +319,27 @@ mod imp {
319319 ) ) ]
320320 unsafe fn get_stack_start ( ) -> Option < * mut libc:: c_void > {
321321 let mut ret = None ;
322- let mut attr: libc:: pthread_attr_t = crate :: mem:: zeroed ( ) ;
322+ let mut attr: mem:: MaybeUninit < libc:: pthread_attr_t > = mem:: MaybeUninit :: uninit ( ) ;
323+ if !cfg ! ( target_os = "freebsd" ) {
324+ attr = mem:: MaybeUninit :: zeroed ( ) ;
325+ }
323326 #[ cfg( target_os = "freebsd" ) ]
324- assert_eq ! ( libc:: pthread_attr_init( & mut attr) , 0 ) ;
327+ assert_eq ! ( libc:: pthread_attr_init( attr. as_mut_ptr ( ) ) , 0 ) ;
325328 #[ cfg( target_os = "freebsd" ) ]
326- let e = libc:: pthread_attr_get_np ( libc:: pthread_self ( ) , & mut attr) ;
329+ let e = libc:: pthread_attr_get_np ( libc:: pthread_self ( ) , attr. as_mut_ptr ( ) ) ;
327330 #[ cfg( not( target_os = "freebsd" ) ) ]
328- let e = libc:: pthread_getattr_np ( libc:: pthread_self ( ) , & mut attr) ;
331+ let e = libc:: pthread_getattr_np ( libc:: pthread_self ( ) , attr. as_mut_ptr ( ) ) ;
329332 if e == 0 {
330333 let mut stackaddr = crate :: ptr:: null_mut ( ) ;
331334 let mut stacksize = 0 ;
332- assert_eq ! ( libc:: pthread_attr_getstack( & attr, & mut stackaddr, & mut stacksize) , 0 ) ;
335+ assert_eq ! (
336+ libc:: pthread_attr_getstack( attr. as_ptr( ) , & mut stackaddr, & mut stacksize) ,
337+ 0
338+ ) ;
333339 ret = Some ( stackaddr) ;
334340 }
335341 if e == 0 || cfg ! ( target_os = "freebsd" ) {
336- assert_eq ! ( libc:: pthread_attr_destroy( & mut attr) , 0 ) ;
342+ assert_eq ! ( libc:: pthread_attr_destroy( attr. as_mut_ptr ( ) ) , 0 ) ;
337343 }
338344 ret
339345 }
@@ -509,16 +515,20 @@ mod imp {
509515 // FIXME: I am probably not unsafe.
510516 unsafe fn current_guard ( ) -> Option < Range < usize > > {
511517 let mut ret = None ;
512- let mut attr: libc:: pthread_attr_t = crate :: mem:: zeroed ( ) ;
518+
519+ let mut attr: mem:: MaybeUninit < libc:: pthread_attr_t > = mem:: MaybeUninit :: uninit ( ) ;
520+ if !cfg ! ( target_os = "freebsd" ) {
521+ attr = mem:: MaybeUninit :: zeroed ( ) ;
522+ }
513523 #[ cfg( target_os = "freebsd" ) ]
514- assert_eq ! ( libc:: pthread_attr_init( & mut attr) , 0 ) ;
524+ assert_eq ! ( libc:: pthread_attr_init( attr. as_mut_ptr ( ) ) , 0 ) ;
515525 #[ cfg( target_os = "freebsd" ) ]
516- let e = libc:: pthread_attr_get_np ( libc:: pthread_self ( ) , & mut attr) ;
526+ let e = libc:: pthread_attr_get_np ( libc:: pthread_self ( ) , attr. as_mut_ptr ( ) ) ;
517527 #[ cfg( not( target_os = "freebsd" ) ) ]
518- let e = libc:: pthread_getattr_np ( libc:: pthread_self ( ) , & mut attr) ;
528+ let e = libc:: pthread_getattr_np ( libc:: pthread_self ( ) , attr. as_mut_ptr ( ) ) ;
519529 if e == 0 {
520530 let mut guardsize = 0 ;
521- assert_eq ! ( libc:: pthread_attr_getguardsize( & attr, & mut guardsize) , 0 ) ;
531+ assert_eq ! ( libc:: pthread_attr_getguardsize( attr. as_ptr ( ) , & mut guardsize) , 0 ) ;
522532 if guardsize == 0 {
523533 if cfg ! ( all( target_os = "linux" , target_env = "musl" ) ) {
524534 // musl versions before 1.1.19 always reported guard
@@ -531,7 +541,7 @@ mod imp {
531541 }
532542 let mut stackptr = crate :: ptr:: null_mut :: < libc:: c_void > ( ) ;
533543 let mut size = 0 ;
534- assert_eq ! ( libc:: pthread_attr_getstack( & attr, & mut stackptr, & mut size) , 0 ) ;
544+ assert_eq ! ( libc:: pthread_attr_getstack( attr. as_ptr ( ) , & mut stackptr, & mut size) , 0 ) ;
535545
536546 let stackaddr = stackptr. addr ( ) ;
537547 ret = if cfg ! ( any( target_os = "freebsd" , target_os = "netbsd" , target_os = "hurd" ) ) {
@@ -552,7 +562,7 @@ mod imp {
552562 } ;
553563 }
554564 if e == 0 || cfg ! ( target_os = "freebsd" ) {
555- assert_eq ! ( libc:: pthread_attr_destroy( & mut attr) , 0 ) ;
565+ assert_eq ! ( libc:: pthread_attr_destroy( attr. as_mut_ptr ( ) ) , 0 ) ;
556566 }
557567 ret
558568 }
0 commit comments