port pthread_mutex_t and pthread_cond_t from sys/unix cause miniaudio wants it

This commit is contained in:
Laytan
2024-10-28 19:42:27 +01:00
parent 0b4a4212bb
commit b7140875cf
2 changed files with 51 additions and 11 deletions

View File

@@ -399,6 +399,16 @@ when ODIN_OS == .Darwin {
pthread_key_t :: distinct c.ulong
pthread_mutex_t :: struct {
__sig: c.long,
__opaque: [56]c.char,
}
pthread_cond_t :: struct {
__sig: c.long,
__opaque: [40]c.char,
}
sched_param :: struct {
sched_priority: c.int, /* [PSX] process or thread execution scheduling priority */
_: [4]c.char,
@@ -432,10 +442,20 @@ when ODIN_OS == .Darwin {
pthread_t :: distinct u64
pthread_attr_t :: distinct rawptr
pthread_attr_t :: struct #align(16) {
_: [8]byte,
}
pthread_key_t :: distinct c.int
pthread_mutex_t :: struct #align(16) {
_: [8]byte,
}
pthread_cond_t :: struct #align(16) {
_: [8]byte,
}
sched_param :: struct {
sched_priority: c.int, /* [PSX] process or thread execution scheduling priority */
}
@@ -476,6 +496,14 @@ when ODIN_OS == .Darwin {
pthread_key_t :: distinct c.int
pthread_cond_t :: struct #align(8) {
_: [40]byte,
}
pthread_mutex_t :: struct #align(8) {
_: [48]byte,
}
sched_param :: struct {
sched_priority: c.int, /* [PSX] process or thread execution scheduling priority */
}
@@ -506,9 +534,11 @@ when ODIN_OS == .Darwin {
PTHREAD_SCOPE_PROCESS :: 0
PTHREAD_SCOPE_SYSTEM :: 0x2
pthread_t :: distinct rawptr
pthread_attr_t :: distinct rawptr
pthread_key_t :: distinct c.int
pthread_t :: distinct rawptr
pthread_attr_t :: distinct rawptr
pthread_key_t :: distinct c.int
pthread_mutex_t :: distinct rawptr
pthread_cond_t :: distinct rawptr
sched_param :: struct {
sched_priority: c.int, /* [PSX] process or thread execution scheduling priority */
@@ -549,6 +579,16 @@ when ODIN_OS == .Darwin {
pthread_key_t :: distinct c.uint
pthread_cond_t :: struct {
__size: [40]c.char, // NOTE: may be smaller depending on libc or arch, but never larger.
__align: c.long,
}
pthread_mutex_t :: struct {
__size: [32]c.char, // NOTE: may be smaller depending on libc or arch, but never larger.
__align: c.long,
}
sched_param :: struct {
sched_priority: c.int, /* [PSX] process or thread execution scheduling priority */

View File

@@ -1,18 +1,18 @@
#+build !windows
package miniaudio
import "core:sys/unix"
import "core:sys/posix"
import "core:c"
thread :: unix.pthread_t
mutex :: unix.pthread_mutex_t
thread :: posix.pthread_t
mutex :: posix.pthread_mutex_t
event :: struct {
value: u32,
lock: unix.pthread_mutex_t,
cond: unix.pthread_cond_t,
lock: posix.pthread_mutex_t,
cond: posix.pthread_cond_t,
}
semaphore :: struct {
value: c.int,
lock: unix.pthread_mutex_t,
cond: unix.pthread_cond_t,
lock: posix.pthread_mutex_t,
cond: posix.pthread_cond_t,
}