windows support

This commit is contained in:
Nishi 2025-11-25 11:08:13 +09:00
commit b9004acd79
Signed by: nishi
GPG key ID: 27EF69B208EB9343
16 changed files with 208 additions and 32 deletions

34
core/thread.c Normal file
View file

@ -0,0 +1,34 @@
#include <MDE/Core/Thread.h>
#ifdef _WIN32
#include <windows.h>
static DWORD WINAPI call_wrapper(LPVOID param) {
void** p = param;
void (*call)(void* user_data) = p[0];
void* ud = p[1];
free(p);
call(ud);
return 0;
}
MDEThread MDEThreadCreate(void (*call)(void* user_data), void* user_data) {
void** p = malloc(sizeof(*p) * 2);
p[0] = call;
p[1] = user_data;
return CreateThread(NULL, 0, call_wrapper, (void*)p, 0, NULL);
}
void MDEThreadDestroy(MDEThread thread) {
CloseHandle(thread);
}
void MDEThreadJoin(MDEThread thread) {
WaitForSingleObject(thread, INFINITE);
}
#else
#endif