Commit fe12423a by Edward Thomson

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.
parent 2e5f27c7
...@@ -31,6 +31,7 @@ typedef int (*git_global_init_fn)(void); ...@@ -31,6 +31,7 @@ typedef int (*git_global_init_fn)(void);
static git_global_init_fn git__init_callbacks[] = { static git_global_init_fn git__init_callbacks[] = {
git_allocator_global_init, git_allocator_global_init,
git_threads_global_init,
git_hash_global_init, git_hash_global_init,
git_sysdir_global_init, git_sysdir_global_init,
git_filter_global_init, git_filter_global_init,
...@@ -159,8 +160,6 @@ static int synchronized_threads_init(void) ...@@ -159,8 +160,6 @@ static int synchronized_threads_init(void)
if ((_fls_index = FlsAlloc(fls_free)) == FLS_OUT_OF_INDEXES) if ((_fls_index = FlsAlloc(fls_free)) == FLS_OUT_OF_INDEXES)
return -1; return -1;
git_threads_init();
if (git_mutex_init(&git__mwindow_mutex)) if (git_mutex_init(&git__mwindow_mutex))
return -1; return -1;
......
...@@ -235,6 +235,8 @@ GIT_INLINE(int64_t) git_atomic64_get(git_atomic64 *a) ...@@ -235,6 +235,8 @@ GIT_INLINE(int64_t) git_atomic64_get(git_atomic64 *a)
#else #else
GIT_INLINE(int) git_threads_global_init(void) { return 0; }
#define git_thread unsigned int #define git_thread unsigned int
#define git_thread_create(thread, start_routine, arg) 0 #define git_thread_create(thread, start_routine, arg) 0
#define git_thread_join(id, status) (void)0 #define git_thread_join(id, status) (void)0
......
...@@ -12,7 +12,8 @@ typedef struct { ...@@ -12,7 +12,8 @@ typedef struct {
pthread_t thread; pthread_t thread;
} git_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) \ #define git_thread_create(git_thread_ptr, start_routine, arg) \
pthread_create(&(git_thread_ptr)->thread, NULL, start_routine, arg) pthread_create(&(git_thread_ptr)->thread, NULL, start_routine, arg)
#define git_thread_join(git_thread_ptr, status) \ #define git_thread_join(git_thread_ptr, status) \
......
...@@ -35,7 +35,7 @@ static DWORD WINAPI git_win32__threadproc(LPVOID lpParameter) ...@@ -35,7 +35,7 @@ static DWORD WINAPI git_win32__threadproc(LPVOID lpParameter)
return CLEAN_THREAD_EXIT; return CLEAN_THREAD_EXIT;
} }
int git_threads_init(void) int git_threads_global_init(void)
{ {
HMODULE hModule = GetModuleHandleW(L"kernel32"); HMODULE hModule = GetModuleHandleW(L"kernel32");
......
...@@ -35,7 +35,7 @@ typedef struct { ...@@ -35,7 +35,7 @@ typedef struct {
} native; } native;
} git_rwlock; } git_rwlock;
int git_threads_init(void); int git_threads_global_init(void);
int git_thread_create(git_thread *GIT_RESTRICT, int git_thread_create(git_thread *GIT_RESTRICT,
void *(*) (void *), void *(*) (void *),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment