@@ -323,9 +323,15 @@ pub(crate) fn current_os_id() -> Option<u64> {
323323 // slightly different spellings.
324324 cfg_if:: cfg_if! {
325325 // Most platforms have a function returning a `pid_t` or int, which is an `i32`.
326- if #[ cfg( any( target_os = "android" , target_os = "linux" , target_os = "nto" ) ) ] {
326+ if #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ] {
327+ use crate :: sys:: weak:: syscall;
328+
329+ // `libc::gettid` is only available on glibc 2.30+, but the syscall is available
330+ // since Linux 2.4.11.
331+ syscall!( fn gettid( ) -> libc:: pid_t; ) ;
332+
327333 // SAFETY: FFI call with no preconditions.
328- let id: libc:: pid_t = unsafe { libc :: gettid( ) } ;
334+ let id: libc:: pid_t = unsafe { gettid( ) } ;
329335 Some ( id as u64 )
330336 } else if #[ cfg( target_os = "openbsd" ) ] {
331337 // SAFETY: FFI call with no preconditions.
@@ -339,6 +345,13 @@ pub(crate) fn current_os_id() -> Option<u64> {
339345 // SAFETY: FFI call with no preconditions.
340346 let id: libc:: lwpid_t = unsafe { libc:: _lwp_self( ) } ;
341347 Some ( id as u64 )
348+ } else if #[ cfg( all( target_os = "nto" , not( target_env = "nto70" ) ) ) ] {
349+ // Neutrino has `gettid` since 7.1. 7.0 is our oldest supported version so exclude it.
350+ // SAFETY: FFI call with no preconditions.
351+ let id: libc:: pid_t = unsafe { libc:: gettid( ) } ;
352+ Some ( id as u64 )
353+ } else if #[ cfg( target_os = "nto" ) ] {
354+ None
342355 } else if #[ cfg( target_vendor = "apple" ) ] {
343356 // Apple allows querying arbitrary thread IDs, `thread=NULL` queries the current thread.
344357 let mut id = 0u64 ;
0 commit comments