summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2017-01-31 16:06:37 +0100
committerAndreas Rumpf <rumpf_a@web.de>2017-01-31 16:06:37 +0100
commitd12a5a6525c95e825a3094e8069cc54938eb8045 (patch)
tree7e5777875d2cb96b29ee559c7cb2e90bb5f4ebd2
parentbd580e9d6ed2dc72139b2bef1d16e6596ffe26ac (diff)
downloadNim-d12a5a6525c95e825a3094e8069cc54938eb8045.tar.gz
make getThreadId() work on OSX
-rw-r--r--lib/system/threads.nim6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/system/threads.nim b/lib/system/threads.nim
index be0b91c66..3dadfc683 100644
--- a/lib/system/threads.nim
+++ b/lib/system/threads.nim
@@ -205,11 +205,13 @@ else:
       ## get the ID of the currently running thread.
       result = int(syscall(SYS_gettid))
   elif defined(macosx) or defined(bsd):
-    proc pthread_main_np(): cint {.importc, header: "pthread.h".}
+    proc pthread_threadid_np(y: pointer; x: var uint64): cint {.importc, header: "pthread.h".}
 
     proc getThreadId*(): int =
       ## get the ID of the currently running thread.
-      result = int(pthread_main_np())
+      var x: uint64
+      result = pthread_threadid_np(nil, x)
+      result = int(x)
   elif defined(solaris):
     # just a guess really:
     type thread_t {.importc: "thread_t", header: "<thread.h>".} = distinct int