summaryrefslogtreecommitdiff
path: root/compat/win32/pthread.h
diff options
context:
space:
mode:
authorJohannes Sixt <j6t@kdbg.org>2010-03-06 15:40:41 (GMT)
committerJunio C Hamano <gitster@pobox.com>2010-03-07 08:37:36 (GMT)
commit912b26324dbc1eb9500e49c90d271a330cbcb30b (patch)
treea48d3afc58d4f7c015096f4018f1764996b324c2 /compat/win32/pthread.h
parent5f8763a81b96b94f24af6aa728107997adcf60bd (diff)
downloadgit-912b26324dbc1eb9500e49c90d271a330cbcb30b.zip
git-912b26324dbc1eb9500e49c90d271a330cbcb30b.tar.gz
git-912b26324dbc1eb9500e49c90d271a330cbcb30b.tar.bz2
Windows: more pthreads functions
This adds: pthread_self pthread_equal pthread_exit pthread_key_create pthread_setspecific pthread_getspecific Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'compat/win32/pthread.h')
-rw-r--r--compat/win32/pthread.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/compat/win32/pthread.h b/compat/win32/pthread.h
index c72f100..c7b8241 100644
--- a/compat/win32/pthread.h
+++ b/compat/win32/pthread.h
@@ -52,6 +52,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,
@@ -65,4 +66,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 */