File tree 1 file changed +8
-5
lines changed
1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -99,13 +99,16 @@ cfg_if::cfg_if! {
99
99
unsafe fn thread_stack( ) -> ( usize , usize ) {
100
100
let this_thread = libc:: pthread_self( ) ;
101
101
let mut thread_attrs: libc:: pthread_attr_t = mem:: zeroed( ) ;
102
- #[ cfg( not( target_os = "freebsd" ) ) ]
103
- libc:: pthread_getattr_np( this_thread, & mut thread_attrs) ;
104
- #[ cfg( target_os = "freebsd" ) ]
105
- libc:: pthread_attr_get_np( this_thread, & mut thread_attrs) ;
106
102
let mut stackaddr: * mut libc:: c_void = ptr:: null_mut( ) ;
107
103
let mut stacksize: libc:: size_t = 0 ;
108
- libc:: pthread_attr_getstack( & thread_attrs, & mut stackaddr, & mut stacksize) ;
104
+ #[ cfg( not( target_os = "freebsd" ) ) ]
105
+ let ok = libc:: pthread_getattr_np( this_thread, & mut thread_attrs) ;
106
+ #[ cfg( target_os = "freebsd" ) ]
107
+ let ok = libc:: pthread_attr_get_np( this_thread, & mut thread_attrs) ;
108
+ if ok == 0 {
109
+ libc:: pthread_attr_getstack( & thread_attrs, & mut stackaddr, & mut stacksize) ;
110
+ libc:: pthread_attr_destroy( & mut thread_attrs) ;
111
+ }
109
112
( stackaddr as usize , stacksize)
110
113
}
111
114
You can’t perform that action at this time.
0 commit comments