From 003af621a00289dfb7b946a3bf2d6c57f0401ebf Mon Sep 17 00:00:00 2001 From: Reuben Dunnington Date: Sun, 30 Jul 2023 21:08:29 -0700 Subject: [PATCH] expose platform_thread.h to users of milepost --- src/milepost.h | 1 + src/platform/platform_thread.h | 45 ++++++++++++++++------------------ 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/src/milepost.h b/src/milepost.h index 5cfa699..19b385b 100644 --- a/src/milepost.h +++ b/src/milepost.h @@ -28,6 +28,7 @@ #include"platform/platform_clock.h" #include"platform/platform_path.h" #include"platform/platform_io.h" +#include"platform/platform_thread.h" /* #include"platform_rng.h" #include"platform_socket.h" diff --git a/src/platform/platform_thread.h b/src/platform/platform_thread.h index fcedf18..f54ec0f 100644 --- a/src/platform/platform_thread.h +++ b/src/platform/platform_thread.h @@ -34,17 +34,14 @@ typedef struct mp_thread mp_thread; typedef i32 (*mp_thread_start_function)(void* userPointer); -mp_thread* mp_thread_create(mp_thread_start_function start, void* userPointer); -mp_thread* mp_thread_create_with_name(mp_thread_start_function start, void* userPointer, const char* name); - -const char* mp_thread_get_name(mp_thread* thread); - -u64 mp_thread_unique_id(mp_thread* thread); -u64 mp_thread_self_id(); - -int mp_thread_signal(mp_thread* thread, int sig); -int mp_thread_join(mp_thread* thread, i64* exitCode); -int mp_thread_detach(mp_thread* thread); +MP_API mp_thread* mp_thread_create(mp_thread_start_function start, void* userPointer); +MP_API mp_thread* mp_thread_create_with_name(mp_thread_start_function start, void* userPointer, const char* name); +MP_API const char* mp_thread_get_name(mp_thread* thread); +MP_API u64 mp_thread_unique_id(mp_thread* thread); +MP_API u64 mp_thread_self_id(); +MP_API int mp_thread_signal(mp_thread* thread, int sig); +MP_API int mp_thread_join(mp_thread* thread, i64* exitCode); +MP_API int mp_thread_detach(mp_thread* thread); //--------------------------------------------------------------- // Platform Mutex API @@ -52,10 +49,10 @@ int mp_thread_detach(mp_thread* thread); typedef struct mp_mutex mp_mutex; -mp_mutex* mp_mutex_create(); -int mp_mutex_destroy(mp_mutex* mutex); -int mp_mutex_lock(mp_mutex* mutex); -int mp_mutex_unlock(mp_mutex* mutex); +MP_API mp_mutex* mp_mutex_create(); +MP_API int mp_mutex_destroy(mp_mutex* mutex); +MP_API int mp_mutex_lock(mp_mutex* mutex); +MP_API int mp_mutex_unlock(mp_mutex* mutex); //--------------------------------------------------------------- // Lightweight ticket mutex API @@ -67,9 +64,9 @@ typedef struct mp_ticket_spin_mutex volatile _Atomic(u64) serving; } mp_ticket_spin_mutex; -void mp_ticket_spin_mutex_init(mp_ticket_spin_mutex* mutex); -void mp_ticket_spin_mutex_lock(mp_ticket_spin_mutex* mutex); -void mp_ticket_spin_mutex_unlock(mp_ticket_spin_mutex* mutex); +MP_API void mp_ticket_spin_mutex_init(mp_ticket_spin_mutex* mutex); +MP_API void mp_ticket_spin_mutex_lock(mp_ticket_spin_mutex* mutex); +MP_API void mp_ticket_spin_mutex_unlock(mp_ticket_spin_mutex* mutex); //--------------------------------------------------------------- // Platform condition variable API @@ -77,12 +74,12 @@ void mp_ticket_spin_mutex_unlock(mp_ticket_spin_mutex* mutex); typedef struct mp_condition mp_condition; -mp_condition* mp_condition_create(); -int mp_condition_destroy(mp_condition* cond); -int mp_condition_wait(mp_condition* cond, mp_mutex* mutex); -int mp_condition_timedwait(mp_condition* cond, mp_mutex* mutex, f64 seconds); -int mp_condition_signal(mp_condition* cond); -int mp_condition_broadcast(mp_condition* cond); +MP_API mp_condition* mp_condition_create(); +MP_API int mp_condition_destroy(mp_condition* cond); +MP_API int mp_condition_wait(mp_condition* cond, mp_mutex* mutex); +MP_API int mp_condition_timedwait(mp_condition* cond, mp_mutex* mutex, f64 seconds); +MP_API int mp_condition_signal(mp_condition* cond); +MP_API int mp_condition_broadcast(mp_condition* cond); #ifdef __cplusplus } // extern "C"