#[cfg(target_os = "linux")]
pub fn get_current_thread_id() -> i64 {
unsafe { libc::syscall(libc::SYS_gettid) as i64 }
}
#[cfg(target_os = "macos")]
pub fn get_current_thread_id() -> i64 {
let mut tid: u64 = 0;
let rc = unsafe { libc::pthread_threadid_np(0, &mut tid) };
debug_assert_eq!(
rc,
0,
"pthread_threadid_np failed: {rc} ({})",
std::io::Error::from_raw_os_error(rc)
);
tid as i64
}
#[cfg(target_os = "windows")]
pub fn get_current_thread_id() -> i64 {
unsafe { windows_sys::Win32::System::Threading::GetCurrentThreadId() as i64 }
}
#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows")))]
compile_error!("libdd_common::threading::get_current_thread_id is unsupported on this platform");