@@ -5,6 +5,8 @@ use std::ffi::CString;
5
5
use std:: thread;
6
6
7
7
fn main ( ) {
8
+ test_named_thread_truncation ( ) ;
9
+
8
10
#[ cfg( not( target_os = "freebsd" ) ) ]
9
11
test_mutex_libc_init_recursive ( ) ;
10
12
#[ cfg( not( target_os = "freebsd" ) ) ]
@@ -14,8 +16,6 @@ fn main() {
14
16
#[ cfg( not( target_os = "freebsd" ) ) ]
15
17
test_rwlock_libc_static_initializer ( ) ;
16
18
17
- test_named_thread_truncation ( ) ;
18
-
19
19
#[ cfg( target_os = "linux" ) ]
20
20
test_mutex_libc_static_initializer_recursive ( ) ;
21
21
}
@@ -150,12 +150,10 @@ fn test_named_thread_truncation() {
150
150
return unsafe { libc:: pthread_setname_np ( libc:: pthread_self ( ) , name. as_ptr ( ) . cast ( ) ) } ;
151
151
#[ cfg( target_os = "freebsd" ) ]
152
152
unsafe {
153
- // pthread_set_name_np does not return anything only it can fail if the
154
- // thread id is invalid
155
- libc :: pthread_set_name_np ( libc :: pthread_self ( ) , name . as_ptr ( ) . cast ( ) )
153
+ // pthread_set_name_np does not return anything
154
+ libc :: pthread_set_name_np ( libc :: pthread_self ( ) , name . as_ptr ( ) . cast ( ) ) ;
155
+ return 0 ;
156
156
} ;
157
- #[ cfg( target_os = "freebsd" ) ]
158
- return 0 ;
159
157
#[ cfg( target_os = "macos" ) ]
160
158
return unsafe { libc:: pthread_setname_np ( name. as_ptr ( ) . cast ( ) ) } ;
161
159
}
@@ -172,8 +170,6 @@ fn test_named_thread_truncation() {
172
170
} ;
173
171
#[ cfg( target_os = "freebsd" ) ]
174
172
unsafe {
175
- // pthread_get_name_np does not return anything only it can fail if the
176
- // thread id is invalid
177
173
libc:: pthread_get_name_np ( libc:: pthread_self ( ) , buf. as_mut_ptr ( ) . cast ( ) , buf. len ( ) )
178
174
} ;
179
175
let cstr = CStr :: from_bytes_until_nul ( & buf) . unwrap ( ) ;
0 commit comments