mirror of
https://github.com/odin-lang/Odin.git
synced 2026-08-05 13:48:33 +00:00
20 lines
350 B
Odin
20 lines
350 B
Odin
#+private
|
|
package runtime
|
|
|
|
import "base:intrinsics"
|
|
|
|
SYS_thr_self :: uintptr(432)
|
|
|
|
_get_current_thread_id :: proc "contextless" () -> int {
|
|
when size_of(rawptr) == 4 {
|
|
id: i32
|
|
} else {
|
|
id: i64
|
|
}
|
|
_, ok := intrinsics.syscall_bsd(SYS_thr_self, uintptr(&id))
|
|
if !ok {
|
|
panic_contextless("Failed to get current thread ID.")
|
|
}
|
|
return int(id)
|
|
}
|