Skip to content

Commit fe12423

Browse files
committed
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.
1 parent 2e5f27c commit fe12423

File tree

5 files changed

+7
-5
lines changed

5 files changed

+7
-5
lines changed

src/global.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ typedef int (*git_global_init_fn)(void);
3131

3232
static git_global_init_fn git__init_callbacks[] = {
3333
git_allocator_global_init,
34+
git_threads_global_init,
3435
git_hash_global_init,
3536
git_sysdir_global_init,
3637
git_filter_global_init,
@@ -159,8 +160,6 @@ static int synchronized_threads_init(void)
159160
if ((_fls_index = FlsAlloc(fls_free)) == FLS_OUT_OF_INDEXES)
160161
return -1;
161162

162-
git_threads_init();
163-
164163
if (git_mutex_init(&git__mwindow_mutex))
165164
return -1;
166165

src/thread-utils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@ GIT_INLINE(int64_t) git_atomic64_get(git_atomic64 *a)
235235

236236
#else
237237

238+
GIT_INLINE(int) git_threads_global_init(void) { return 0; }
239+
238240
#define git_thread unsigned int
239241
#define git_thread_create(thread, start_routine, arg) 0
240242
#define git_thread_join(id, status) (void)0

src/unix/pthread.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ typedef struct {
1212
pthread_t thread;
1313
} git_thread;
1414

15-
#define git_threads_init() (void)0
15+
GIT_INLINE(int) git_threads_global_init(void) { return 0; }
16+
1617
#define git_thread_create(git_thread_ptr, start_routine, arg) \
1718
pthread_create(&(git_thread_ptr)->thread, NULL, start_routine, arg)
1819
#define git_thread_join(git_thread_ptr, status) \

src/win32/thread.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static DWORD WINAPI git_win32__threadproc(LPVOID lpParameter)
3535
return CLEAN_THREAD_EXIT;
3636
}
3737

38-
int git_threads_init(void)
38+
int git_threads_global_init(void)
3939
{
4040
HMODULE hModule = GetModuleHandleW(L"kernel32");
4141

src/win32/thread.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ typedef struct {
3535
} native;
3636
} git_rwlock;
3737

38-
int git_threads_init(void);
38+
int git_threads_global_init(void);
3939

4040
int git_thread_create(git_thread *GIT_RESTRICT,
4141
void *(*) (void *),

0 commit comments

Comments
 (0)