@@ -294,6 +294,7 @@ pub mod guard {
294294 unsafe fn get_stack_start ( ) -> Option < * mut libc:: c_void > {
295295 let mut ret = None ;
296296 let mut attr: libc:: pthread_attr_t = crate :: mem:: zeroed ( ) ;
297+ #[ cfg( target_os = "freebsd" ) ]
297298 assert_eq ! ( libc:: pthread_attr_init( & mut attr) , 0 ) ;
298299 #[ cfg( target_os = "freebsd" ) ]
299300 let e = libc:: pthread_attr_get_np ( libc:: pthread_self ( ) , & mut attr) ;
@@ -305,7 +306,9 @@ pub mod guard {
305306 assert_eq ! ( libc:: pthread_attr_getstack( & attr, & mut stackaddr, & mut stacksize) , 0 ) ;
306307 ret = Some ( stackaddr) ;
307308 }
308- assert_eq ! ( libc:: pthread_attr_destroy( & mut attr) , 0 ) ;
309+ if e == 0 || cfg ! ( target_os = "freebsd" ) {
310+ assert_eq ! ( libc:: pthread_attr_destroy( & mut attr) , 0 ) ;
311+ }
309312 ret
310313 }
311314
@@ -403,6 +406,7 @@ pub mod guard {
403406 pub unsafe fn current ( ) -> Option < Guard > {
404407 let mut ret = None ;
405408 let mut attr: libc:: pthread_attr_t = crate :: mem:: zeroed ( ) ;
409+ #[ cfg( target_os = "freebsd" ) ]
406410 assert_eq ! ( libc:: pthread_attr_init( & mut attr) , 0 ) ;
407411 #[ cfg( target_os = "freebsd" ) ]
408412 let e = libc:: pthread_attr_get_np ( libc:: pthread_self ( ) , & mut attr) ;
@@ -446,7 +450,9 @@ pub mod guard {
446450 Some ( stackaddr..stackaddr + guardsize)
447451 } ;
448452 }
449- assert_eq ! ( libc:: pthread_attr_destroy( & mut attr) , 0 ) ;
453+ if e == 0 || cfg ! ( target_os = "freebsd" ) {
454+ assert_eq ! ( libc:: pthread_attr_destroy( & mut attr) , 0 ) ;
455+ }
450456 ret
451457 }
452458}
0 commit comments