Skip to content

Commit d7136db

Browse files
committed
Use pthread_threadid_np instead of pthread_self to get TID on macOS
1 parent 27f1ea1 commit d7136db

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

spdlog/src/record.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,9 @@ fn get_current_tid() -> u64 {
272272
#[cfg(target_os = "macos")]
273273
#[must_use]
274274
fn get_current_tid_inner() -> u64 {
275-
let tid = unsafe { libc::pthread_self() };
276-
tid as u64
275+
let mut tid = 0;
276+
unsafe { libc::pthread_threadid_np(0, &mut tid) };
277+
tid
277278
}
278279

279280
#[cfg(target_os = "windows")]

0 commit comments

Comments
 (0)