summaryrefslogtreecommitdiff
path: root/src/unix/pthread.h
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@github.com>2016-11-18 07:19:22 -0500
committerEdward Thomson <ethomson@github.com>2016-11-18 07:34:09 -0500
commit82f15896deb06d396d76d706f6c0146197d14b2c (patch)
tree8e0bc15feb02cb9a197ddc8db62d174515d94bf7 /src/unix/pthread.h
parenta6763ff93aed9a1486c4f84d77151ff57dd4795e (diff)
downloadlibgit2-82f15896deb06d396d76d706f6c0146197d14b2c.tar.gz
threads: introduce `git_thread_exit`
Introduce `git_thread_exit`, which will allow threads to terminate at an arbitrary time, returning a `void *`. On Windows, this means that we need to store the current `git_thread` in TLS, so that we can set its `return` value when terminating. We cannot simply use `ExitThread`, since Win32 returns `DWORD`s from threads; we return `void *`.
Diffstat (limited to 'src/unix/pthread.h')
-rw-r--r--src/unix/pthread.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/unix/pthread.h b/src/unix/pthread.h
index 0f3f17927..3f23d10d5 100644
--- a/src/unix/pthread.h
+++ b/src/unix/pthread.h
@@ -17,6 +17,8 @@ typedef struct {
pthread_create(&(git_thread_ptr)->thread, NULL, start_routine, arg)
#define git_thread_join(git_thread_ptr, status) \
pthread_join((git_thread_ptr)->thread, status)
+#define git_thread_currentid() ((size_t)(pthread_self()))
+#define git_thread_exit(retval) pthread_exit(retval)
/* Git Mutex */
#define git_mutex pthread_mutex_t