Merge pull request #3439 from andreas-jonsson/netbsd

NetBSD support
This commit is contained in:
gingerBill
2024-05-15 10:33:52 +01:00
committed by GitHub
40 changed files with 1192 additions and 79 deletions
+5 -5
View File
@@ -1,4 +1,4 @@
// +build linux, darwin, freebsd, openbsd, haiku
// +build linux, darwin, freebsd, openbsd, netbsd, haiku
// +private
package thread
@@ -20,7 +20,7 @@ Thread_Os_Specific :: struct #align(16) {
// It then waits for `start` to be called.
//
_create :: proc(procedure: Thread_Proc, priority: Thread_Priority) -> ^Thread {
__linux_thread_entry_proc :: proc "c" (t: rawptr) -> rawptr {
__unix_thread_entry_proc :: proc "c" (t: rawptr) -> rawptr {
t := (^Thread)(t)
when ODIN_OS != .Darwin {
@@ -82,7 +82,7 @@ _create :: proc(procedure: Thread_Proc, priority: Thread_Priority) -> ^Thread {
// NOTE(tetra, 2019-11-01): These only fail if their argument is invalid.
assert(unix.pthread_attr_setdetachstate(&attrs, unix.PTHREAD_CREATE_JOINABLE) == 0)
when ODIN_OS != .Haiku {
when ODIN_OS != .Haiku && ODIN_OS != .NetBSD {
assert(unix.pthread_attr_setinheritsched(&attrs, unix.PTHREAD_EXPLICIT_SCHED) == 0)
}
@@ -95,7 +95,7 @@ _create :: proc(procedure: Thread_Proc, priority: Thread_Priority) -> ^Thread {
// Set thread priority.
policy: i32
res: i32
when ODIN_OS != .Haiku {
when ODIN_OS != .Haiku && ODIN_OS != .NetBSD {
res = unix.pthread_attr_getschedpolicy(&attrs, &policy)
assert(res == 0)
}
@@ -113,7 +113,7 @@ _create :: proc(procedure: Thread_Proc, priority: Thread_Priority) -> ^Thread {
assert(res == 0)
thread.procedure = procedure
if unix.pthread_create(&thread.unix_thread, &attrs, __linux_thread_entry_proc, thread) != 0 {
if unix.pthread_create(&thread.unix_thread, &attrs, __unix_thread_entry_proc, thread) != 0 {
free(thread, thread.creation_allocator)
return nil
}