@@ -294,6 +294,7 @@ pub mod guard {
294
294
unsafe fn get_stack_start ( ) -> Option < * mut libc:: c_void > {
295
295
let mut ret = None ;
296
296
let mut attr: libc:: pthread_attr_t = crate :: mem:: zeroed ( ) ;
297
+ #[ cfg( target_os = "freebsd" ) ]
297
298
assert_eq ! ( libc:: pthread_attr_init( & mut attr) , 0 ) ;
298
299
#[ cfg( target_os = "freebsd" ) ]
299
300
let e = libc:: pthread_attr_get_np ( libc:: pthread_self ( ) , & mut attr) ;
@@ -305,7 +306,9 @@ pub mod guard {
305
306
assert_eq ! ( libc:: pthread_attr_getstack( & attr, & mut stackaddr, & mut stacksize) , 0 ) ;
306
307
ret = Some ( stackaddr) ;
307
308
}
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
+ }
309
312
ret
310
313
}
311
314
@@ -403,6 +406,7 @@ pub mod guard {
403
406
pub unsafe fn current ( ) -> Option < Guard > {
404
407
let mut ret = None ;
405
408
let mut attr: libc:: pthread_attr_t = crate :: mem:: zeroed ( ) ;
409
+ #[ cfg( target_os = "freebsd" ) ]
406
410
assert_eq ! ( libc:: pthread_attr_init( & mut attr) , 0 ) ;
407
411
#[ cfg( target_os = "freebsd" ) ]
408
412
let e = libc:: pthread_attr_get_np ( libc:: pthread_self ( ) , & mut attr) ;
@@ -446,7 +450,9 @@ pub mod guard {
446
450
Some ( stackaddr..stackaddr + guardsize)
447
451
} ;
448
452
}
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
+ }
450
456
ret
451
457
}
452
458
}
0 commit comments