summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2020-05-12 13:08:22 +0100
committerEdward Thomson <ethomson@edwardthomson.com>2020-10-11 14:42:19 +0100
commitfe12423a91015e6116773340a8936fece3251339 (patch)
tree3b22a69b80f5380027b6138b0403f843280e9b43
parent2e5f27c7dc81618c185e68a1c6129dd99c69edab (diff)
downloadlibgit2-fe12423a91015e6116773340a8936fece3251339.tar.gz
init: move thread init to git_global_threads_init
Instead of treating win32 thread initialization specially in the win32 git_libgit2_init function, add a git_global_threads_init function.
-rw-r--r--src/global.c3
-rw-r--r--src/thread-utils.h2
-rw-r--r--src/unix/pthread.h3
-rw-r--r--src/win32/thread.c2
-rw-r--r--src/win32/thread.h2
5 files changed, 7 insertions, 5 deletions
diff --git a/src/global.c b/src/global.c
index 9fe8cd5d3..4abb5e387 100644
--- a/src/global.c
+++ b/src/global.c
@@ -31,6 +31,7 @@ typedef int (*git_global_init_fn)(void);
static git_global_init_fn git__init_callbacks[] = {
git_allocator_global_init,
+ git_threads_global_init,
git_hash_global_init,
git_sysdir_global_init,
git_filter_global_init,
@@ -159,8 +160,6 @@ static int synchronized_threads_init(void)
if ((_fls_index = FlsAlloc(fls_free)) == FLS_OUT_OF_INDEXES)
return -1;
- git_threads_init();
-
if (git_mutex_init(&git__mwindow_mutex))
return -1;
diff --git a/src/thread-utils.h b/src/thread-utils.h
index ecb4909f5..8e1e7c97a 100644
--- a/src/thread-utils.h
+++ b/src/thread-utils.h
@@ -235,6 +235,8 @@ GIT_INLINE(int64_t) git_atomic64_get(git_atomic64 *a)
#else
+GIT_INLINE(int) git_threads_global_init(void) { return 0; }
+
#define git_thread unsigned int
#define git_thread_create(thread, start_routine, arg) 0
#define git_thread_join(id, status) (void)0
diff --git a/src/unix/pthread.h b/src/unix/pthread.h
index 233561b4e..55f4ae227 100644
--- a/src/unix/pthread.h
+++ b/src/unix/pthread.h
@@ -12,7 +12,8 @@ typedef struct {
pthread_t thread;
} git_thread;
-#define git_threads_init() (void)0
+GIT_INLINE(int) git_threads_global_init(void) { return 0; }
+
#define git_thread_create(git_thread_ptr, start_routine, arg) \
pthread_create(&(git_thread_ptr)->thread, NULL, start_routine, arg)
#define git_thread_join(git_thread_ptr, status) \
diff --git a/src/win32/thread.c b/src/win32/thread.c
index 42dba7f97..0936c3168 100644
--- a/src/win32/thread.c
+++ b/src/win32/thread.c
@@ -35,7 +35,7 @@ static DWORD WINAPI git_win32__threadproc(LPVOID lpParameter)
return CLEAN_THREAD_EXIT;
}
-int git_threads_init(void)
+int git_threads_global_init(void)
{
HMODULE hModule = GetModuleHandleW(L"kernel32");
diff --git a/src/win32/thread.h b/src/win32/thread.h
index 41cbf015b..8305036b4 100644
--- a/src/win32/thread.h
+++ b/src/win32/thread.h
@@ -35,7 +35,7 @@ typedef struct {
} native;
} git_rwlock;
-int git_threads_init(void);
+int git_threads_global_init(void);
int git_thread_create(git_thread *GIT_RESTRICT,
void *(*) (void *),