primitives_darwin.odin 490 B

123456789101112131415161718
  1. //+build darwin
  2. //+private
  3. package sync
  4. import "core:c"
  5. import "base:intrinsics"
  6. foreign import pthread "system:System.framework"
  7. _current_thread_id :: proc "contextless" () -> int {
  8. tid: u64
  9. // NOTE(Oskar): available from OSX 10.6 and iOS 3.2.
  10. // For older versions there is `syscall(SYS_thread_selfid)`, but not really
  11. // the same thing apparently.
  12. foreign pthread { pthread_threadid_np :: proc "c" (rawptr, ^u64) -> c.int --- }
  13. pthread_threadid_np(nil, &tid)
  14. return int(tid)
  15. }