From b9bd2723a9fb6da09402d2099ee1a0d15fe5746f Mon Sep 17 00:00:00 2001 From: Reuben Dunnington Date: Sun, 30 Jul 2023 21:35:08 -0700 Subject: [PATCH] replace pthread with mp_thread --- build.bat | 9 +++------ milepost | 2 +- src/main.c | 15 ++++++--------- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/build.bat b/build.bat index 0bbfe44..ccd88f3 100644 --- a/build.bat +++ b/build.bat @@ -28,12 +28,9 @@ if %target% == milepost ( if %target% == orca ( echo building orca - set pthread_dir=..\vcpkg\packages\pthreads_x64-windows - ::copy libraries copy milepost\bin\milepost.dll bin copy milepost\bin\milepost.dll.lib bin - copy %pthread_dir%\bin\pthreadVC3.dll bin ::generate wasm3 api bindings python3 scripts\bindgen.py core src\core_api.json^ @@ -58,8 +55,8 @@ if %target% == orca ( --wasm3-bindings src\io_api_bind_gen.c ::compile orca - set INCLUDES=/I src /I sdk /I ext\wasm3\source /I milepost\src /I milepost\ext /I %pthread_dir%\include - set LIBS=/LIBPATH:bin /LIBPATH:%pthread_dir%\lib milepost.dll.lib wasm3.lib pthreadVC3.lib + set INCLUDES=/I src /I sdk /I ext\wasm3\source /I milepost\src /I milepost\ext + set LIBS=/LIBPATH:bin milepost.dll.lib wasm3.lib - cl /Zi /Zc:preprocessor /std:c11 %INCLUDES% src\main.c /link %LIBS% /out:bin\orca.exe + cl /Zi /Zc:preprocessor /std:c11 /experimental:c11atomics %INCLUDES% src\main.c /link %LIBS% /out:bin\orca.exe ) diff --git a/milepost b/milepost index 442d863..6ec113b 160000 --- a/milepost +++ b/milepost @@ -1 +1 @@ -Subproject commit 442d86386ebdc6e119ec765648420b6e096d145d +Subproject commit 6ec113b708398bcf82a052a2bfb891b3265ca92e diff --git a/src/main.c b/src/main.c index 700ddf5..afcbce4 100644 --- a/src/main.c +++ b/src/main.c @@ -7,7 +7,6 @@ *****************************************************************/ #include #include -#include #include #define MG_INCLUDE_GL_API @@ -306,7 +305,7 @@ void orca_runtime_init(orca_runtime* runtime) #include"gles_api_bind_gen.c" #include"manual_gles_api.c" -void* orca_runloop(void* user) +i32 orca_runloop(void* user) { orca_app* app = &__orcaApp; @@ -328,7 +327,7 @@ void* orca_runloop(void* user) options); mp_request_quit(); - return((void*)-1); + return(-1); } fseek(file, 0, SEEK_END); @@ -378,7 +377,7 @@ void* orca_runloop(void* user) options); mp_request_quit(); - return((void*)-1); + return(-1); } //NOTE: Find and type check event handlers. @@ -473,7 +472,7 @@ void* orca_runloop(void* user) options); mp_request_quit(); - return((void*)-1); + return(-1); } } @@ -803,8 +802,7 @@ int main(int argc, char** argv) mp_window_focus(app->window); mp_window_center(app->window); - pthread_t runloopThread; - pthread_create(&runloopThread, 0, orca_runloop, 0); + mp_thread* runloopThread = mp_thread_create(orca_runloop, 0); while(!mp_should_quit()) { @@ -812,8 +810,7 @@ int main(int argc, char** argv) //TODO: what to do with mem scratch here? } - void* res; - pthread_join(runloopThread, &res); + mp_thread_join(runloopThread, NULL); mg_canvas_destroy(app->canvas); mg_surface_destroy(app->surface);