aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas T Jonsson <mail@andreasjonsson.se>2024-06-05 11:06:14 +0200
committerAndreas T Jonsson <mail@andreasjonsson.se>2024-06-05 11:06:14 +0200
commited6667ebf2fd5d85bcafc789c8e5e5adbd7524cc (patch)
treebae2c1560cf198274a0af5e8fae9b7ff67a4255a
parent2c580aa6fbcc58b5d95afd475a6c7418570f1369 (diff)
Propper thread identification on NetBSD
-rw-r--r--core/os/os_netbsd.odin7
-rw-r--r--core/sync/primitives_netbsd.odin8
2 files changed, 12 insertions, 3 deletions
diff --git a/core/os/os_netbsd.odin b/core/os/os_netbsd.odin
index e8e551340..ab4f877bb 100644
--- a/core/os/os_netbsd.odin
+++ b/core/os/os_netbsd.odin
@@ -328,6 +328,11 @@ foreign dl {
@(link_name="dlerror") _unix_dlerror :: proc() -> cstring ---
}
+@(private)
+foreign libc {
+ _lwp_self :: proc() -> i32 ---
+}
+
// NOTE(phix): Perhaps share the following functions with FreeBSD if they turn out to be the same in the end.
is_path_separator :: proc(r: rune) -> bool {
@@ -721,7 +726,7 @@ exit :: proc "contextless" (code: int) -> ! {
}
current_thread_id :: proc "contextless" () -> int {
- return cast(int) unix.pthread_self()
+ return int(_lwp_self())
}
dlopen :: proc(filename: string, flags: int) -> rawptr {
diff --git a/core/sync/primitives_netbsd.odin b/core/sync/primitives_netbsd.odin
index 042e744e8..594f2ff5c 100644
--- a/core/sync/primitives_netbsd.odin
+++ b/core/sync/primitives_netbsd.odin
@@ -1,8 +1,12 @@
//+private
package sync
-import "core:sys/unix"
+foreign import libc "system:c"
+
+foreign libc {
+ _lwp_self :: proc "c" () -> i32 ---
+}
_current_thread_id :: proc "contextless" () -> int {
- return cast(int) unix.pthread_self()
+ return int(_lwp_self())
}