@@ -323,9 +323,15 @@ pub(crate) fn current_os_id() -> Option<u64> {
323
323
// slightly different spellings.
324
324
cfg_if:: cfg_if! {
325
325
// 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
+
327
333
// SAFETY: FFI call with no preconditions.
328
- let id: libc:: pid_t = unsafe { libc :: gettid( ) } ;
334
+ let id: libc:: pid_t = unsafe { gettid( ) } ;
329
335
Some ( id as u64 )
330
336
} else if #[ cfg( target_os = "openbsd" ) ] {
331
337
// SAFETY: FFI call with no preconditions.
@@ -339,6 +345,13 @@ pub(crate) fn current_os_id() -> Option<u64> {
339
345
// SAFETY: FFI call with no preconditions.
340
346
let id: libc:: lwpid_t = unsafe { libc:: _lwp_self( ) } ;
341
347
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
342
355
} else if #[ cfg( target_vendor = "apple" ) ] {
343
356
// Apple allows querying arbitrary thread IDs, `thread=NULL` queries the current thread.
344
357
let mut id = 0u64 ;
0 commit comments