/* Minimal pthreads shim for MSVC: only the subset the served kstar.c uses. * The served kstar.c (sha 4d3faa05...) is compiled UNMODIFIED with -I shim: * pthread_mutex_t -> SRWLOCK, pthread_t -> HANDLE, create/join -> CreateThread/Wait. */ #ifndef SHIM_PTHREAD_H #define SHIM_PTHREAD_H #define WIN32_LEAN_AND_MEAN #include typedef HANDLE pthread_t; typedef SRWLOCK pthread_mutex_t; #define PTHREAD_MUTEX_INITIALIZER SRWLOCK_INIT static int pthread_mutex_lock(pthread_mutex_t *m) { AcquireSRWLockExclusive(m); return 0; } static int pthread_mutex_unlock(pthread_mutex_t *m) { ReleaseSRWLockExclusive(m); return 0; } static int pthread_create(pthread_t *t, const void *attr, void *(*fn)(void *), void *arg) { (void)attr; *t = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)fn, arg, 0, NULL); return (*t == NULL) ? -1 : 0; } static int pthread_join(pthread_t t, void **ret) { (void)ret; WaitForSingleObject(t, INFINITE); CloseHandle(t); return 0; } #endif