summaryrefslogtreecommitdiff
path: root/compat/win32
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2010-06-21 06:02:45 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2010-06-21 06:02:45 -0700
commit762655010d6f051f632a77b8c5b95b9f5cad02c9 (patch)
tree8f9b2d9a72a1e1af33eaa26fd94516391f23ad62 /compat/win32
parentMerge branch 'gv/portable' (diff)
parentfast-import: die_nicely() back to vsnprintf (reverts part of ebaa79f) (diff)
downloadtgif-762655010d6f051f632a77b8c5b95b9f5cad02c9.tar.xz
Merge branch 'js/async-thread'
* js/async-thread: fast-import: die_nicely() back to vsnprintf (reverts part of ebaa79f) Enable threaded async procedures whenever pthreads is available Dying in an async procedure should only exit the thread, not the process. Reimplement async procedures using pthreads Windows: more pthreads functions Fix signature of fcntl() compatibility dummy Make report() from usage.c public as vreportf() and use it. Modernize t5530-upload-pack-error. Conflicts: http-backend.c
Diffstat (limited to 'compat/win32')
-rw-r--r--compat/win32/pthread.c8
-rw-r--r--compat/win32/pthread.h25
2 files changed, 33 insertions, 0 deletions
diff --git a/compat/win32/pthread.c b/compat/win32/pthread.c
index 0f949fc425..010e875ec4 100644
--- a/compat/win32/pthread.c
+++ b/compat/win32/pthread.c
@@ -16,6 +16,7 @@
static unsigned __stdcall win32_start_routine(void *arg)
{
pthread_t *thread = arg;
+ thread->tid = GetCurrentThreadId();
thread->arg = thread->start_routine(thread->arg);
return 0;
}
@@ -49,6 +50,13 @@ int win32_pthread_join(pthread_t *thread, void **value_ptr)
}
}
+pthread_t pthread_self(void)
+{
+ pthread_t t = { 0 };
+ t.tid = GetCurrentThreadId();
+ return t;
+}
+
int pthread_cond_init(pthread_cond_t *cond, const void *unused)
{
cond->waiters = 0;
diff --git a/compat/win32/pthread.h b/compat/win32/pthread.h
index a45f8d66df..2e20548557 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 */