summary refs log tree commit diff stats
path: root/lib/system/threads.nim
diff options
context:
space:
mode:
Diffstat (limited to 'lib/system/threads.nim')
-rw-r--r--lib/system/threads.nim9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/system/threads.nim b/lib/system/threads.nim
index 7886fdcdf..ab86baeee 100644
--- a/lib/system/threads.nim
+++ b/lib/system/threads.nim
@@ -195,12 +195,15 @@ else:
     importc: "pthread_setaffinity_np", header: pthreadh.}
 
   when defined(linux):
-    type Pid {.importc: "pid_t", header: "<sys/types.h>".} = distinct int
-    proc gettid(): Pid {.importc, header: "<sys/types.h>".}
+    proc syscall(arg: int): int {.varargs, importc: "syscall", header: "<sys/syscall.h>".}
+    var SYS_gettid {.importc, header: "<sys/syscall.h>".}: int
+
+    #type Pid {.importc: "pid_t", header: "<sys/types.h>".} = distinct int
+    #proc gettid(): Pid {.importc, header: "<sys/types.h>".}
 
     proc getThreadId*(): int =
       ## get the ID of the currently running thread.
-      result = int(gettid())
+      result = int(syscall(SYS_gettid))
   elif defined(macosx) or defined(bsd):
     proc pthread_main_np(): cint {.importc, header: "pthread.h".}