* Use native `getthrid` on OpenBSD.
* Use NetBSD specific primitive to get thread id
This commit is contained in:
Eugene Kabanov
2017-05-31 22:00:16 +03:00
committed by Andreas Rumpf
parent 7b3785554f
commit 199f061ddc

View File

@@ -264,7 +264,17 @@ else:
proc getThreadId*(): int =
result = int(lwp_gettid())
elif defined(macosx) or defined(freebsd) or defined(openbsd) or defined(netbsd):
elif defined(openbsd):
proc getthrid(): int32 {.importc: "getthrid", header: "<unistd.h>".}
proc getThreadId*(): int =
result = int(getthrid())
elif defined(netbsd):
proc lwp_self(): int32 {.importc: "_lwp_self", header: "<lwp.h>".}
proc getThreadId*(): int =
result = int(lwp_self())
elif defined(macosx) or defined(freebsd):
proc pthread_threadid_np(y: pointer; x: var uint64): cint {.importc, header: "pthread.h".}
proc getThreadId*(): int =