X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=compat%2Fwin32%2Fpthread.h;h=2e205485570bf62a11112c665624203207c724a9;hb=5b5275f6e9ca6284ca123f729d5a78f409e448fb;hp=a45f8d66df8d1e452d9392945bf12a74c32bbca9;hpb=8d676d85f772ce3a100b6f0dddd1c34a7e4313cf;p=git.git diff --git a/compat/win32/pthread.h b/compat/win32/pthread.h index a45f8d66d..2e2054855 100644 --- a/compat/win32/pthread.h +++ b/compat/win32/pthread.h @@ -58,6 +58,7 @@ typedef struct { HANDLE handle; void *(*start_routine)(void*); void *arg; + DWORD tid; } pthread_t; extern int pthread_create(pthread_t *thread, const void *unused, @@ -71,4 +72,28 @@ extern int pthread_create(pthread_t *thread, const void *unused, extern int win32_pthread_join(pthread_t *thread, void **value_ptr); +#define pthread_equal(t1, t2) ((t1).tid == (t2).tid) +extern pthread_t pthread_self(void); + +static inline int pthread_exit(void *ret) +{ + ExitThread((DWORD)ret); +} + +typedef DWORD pthread_key_t; +static inline int pthread_key_create(pthread_key_t *keyp, void (*destructor)(void *value)) +{ + return (*keyp = TlsAlloc()) == TLS_OUT_OF_INDEXES ? EAGAIN : 0; +} + +static inline int pthread_setspecific(pthread_key_t key, const void *value) +{ + return TlsSetValue(key, (void *)value) ? 0 : EINVAL; +} + +static inline void *pthread_getspecific(pthread_key_t key) +{ + return TlsGetValue(key); +} + #endif /* PTHREAD_H */