This commit is contained in:
Nishi 2025-11-25 17:57:52 +09:00
commit 667434cadc
Signed by: nishi
GPG key ID: 27EF69B208EB9343
3 changed files with 59 additions and 0 deletions

View file

@ -31,4 +31,36 @@ void MDEThreadJoin(MDEThread thread) {
WaitForSingleObject(thread, INFINITE);
}
#else
#include <pthread.h>
static void* call_wrapper(void* param) {
void** p = param;
void (*call)(void* user_data) = p[0];
void* ud = p[1];
free(p);
call(ud);
return NULL;
}
MDEThread MDEThreadCreate(void (*call)(void* user_data), void* user_data) {
void** p = malloc(sizeof(*p) * 2);
pthread_t* t = malloc(sizeof(*t));
p[0] = call;
p[1] = user_data;
pthread_create(t, NULL, call_wrapper, p);
return t;
}
void MDEThreadDestroy(MDEThread thread) {
free(thread);
}
void MDEThreadJoin(MDEThread thread) {
void* p;
pthread_join(thread, &p);
}
#endif