From b7140875cfb3b699fc26001936a8974b71b6aafb Mon Sep 17 00:00:00 2001 From: Laytan Date: Mon, 28 Oct 2024 19:42:27 +0100 Subject: [PATCH] port pthread_mutex_t and pthread_cond_t from sys/unix cause miniaudio wants it --- core/sys/posix/pthread.odin | 48 ++++++++++++++++++++++++++++--- vendor/miniaudio/common_unix.odin | 14 ++++----- 2 files changed, 51 insertions(+), 11 deletions(-) diff --git a/core/sys/posix/pthread.odin b/core/sys/posix/pthread.odin index 6e894117a..8bad71f57 100644 --- a/core/sys/posix/pthread.odin +++ b/core/sys/posix/pthread.odin @@ -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 */ diff --git a/vendor/miniaudio/common_unix.odin b/vendor/miniaudio/common_unix.odin index 8afcc0b5a..1c0158404 100644 --- a/vendor/miniaudio/common_unix.odin +++ b/vendor/miniaudio/common_unix.odin @@ -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, }