@@ -322,8 +322,7 @@ pub(crate) fn current_os_id() -> Option<u64> {
322322 // Most Unix platforms have a way to query an integer ID of the current thread, all with
323323 // slightly different spellings.
324324 cfg_if:: cfg_if! {
325- // Linux-like and some BSDs have methods to get the current `pid_t`, which is an `i32` on
326- // these platforms.
325+ // Most platforms have a function returning a `pid_t` or int, which is an `i32`.
327326 if #[ cfg( any( target_os = "android" , target_os = "linux" , target_os = "nto" ) ) ] {
328327 // SAFETY: FFI call with no preconditions.
329328 let id: libc:: pid_t = unsafe { libc:: gettid( ) } ;
@@ -336,20 +335,12 @@ pub(crate) fn current_os_id() -> Option<u64> {
336335 // SAFETY: FFI call with no preconditions.
337336 let id: libc:: c_int = unsafe { libc:: pthread_getthreadid_np( ) } ;
338337 Some ( id as u64 )
339- }
340-
341- // Solaris, Illumos, and NetBSD are similar but their functions return a `u32`.
342- else if #[ cfg( any( target_os = "illumos" , target_os = "solaris" ) ) ] {
343- // SAFETY: FFI call with no preconditions.
344- let id: libc:: thread_t = unsafe { libc:: thr_self( ) } ;
345- Some ( id. into( ) )
346338 } else if #[ cfg( target_os = "netbsd" ) ] {
339+ // SAFETY: FFI call with no preconditions.
347340 let id: libc:: lwpid_t = unsafe { libc:: _lwp_self( ) } ;
348- Some ( id. into( ) )
349- }
350-
351- // Apple allows querying arbitrary thread IDs, `thread=NULL` queries the current thread.
352- else if #[ cfg( target_vendor = "apple" ) ] {
341+ Some ( id as u64 )
342+ } else if #[ cfg( target_vendor = "apple" ) ] {
343+ // Apple allows querying arbitrary thread IDs, `thread=NULL` queries the current thread.
353344 let mut id = 0u64 ;
354345 // SAFETY: `thread_id` is a valid pointer, no other preconditions.
355346 let status: libc:: c_int = unsafe { libc:: pthread_threadid_np( 0 , & mut id) } ;
@@ -358,10 +349,8 @@ pub(crate) fn current_os_id() -> Option<u64> {
358349 } else {
359350 None
360351 }
361- }
362-
363- // As a fallback, return the pid which can be used to help identify a crashing process.
364- else {
352+ } else {
353+ // As a fallback, return the pid which can be used to help identify a crashing process.
365354 Some ( super :: os:: getpid( ) . into( ) )
366355 }
367356 }
0 commit comments