1010
1111#define CLEAN_THREAD_EXIT 0x6F012842
1212
13+ typedef void (WINAPI * win32_srwlock_fn )(GIT_SRWLOCK * );
14+
15+ static win32_srwlock_fn win32_srwlock_initialize ;
16+ static win32_srwlock_fn win32_srwlock_acquire_shared ;
17+ static win32_srwlock_fn win32_srwlock_release_shared ;
18+ static win32_srwlock_fn win32_srwlock_acquire_exclusive ;
19+ static win32_srwlock_fn win32_srwlock_release_exclusive ;
20+
1321/* The thread procedure stub used to invoke the caller's procedure
1422 * and capture the return value for later collection. Windows will
1523 * only hold a DWORD, but we need to be able to store an entire
@@ -25,6 +33,26 @@ static DWORD WINAPI git_win32__threadproc(LPVOID lpParameter)
2533 return CLEAN_THREAD_EXIT ;
2634}
2735
36+ int git_threads_init (void )
37+ {
38+ HMODULE hModule = GetModuleHandleW (L"kernel32" );
39+
40+ if (hModule ) {
41+ win32_srwlock_initialize = (win32_srwlock_fn )
42+ GetProcAddress (hModule , "InitializeSRWLock" );
43+ win32_srwlock_acquire_shared = (win32_srwlock_fn )
44+ GetProcAddress (hModule , "AcquireSRWLockShared" );
45+ win32_srwlock_release_shared = (win32_srwlock_fn )
46+ GetProcAddress (hModule , "ReleaseSRWLockShared" );
47+ win32_srwlock_acquire_exclusive = (win32_srwlock_fn )
48+ GetProcAddress (hModule , "AcquireSRWLockExclusive" );
49+ win32_srwlock_release_exclusive = (win32_srwlock_fn )
50+ GetProcAddress (hModule , "ReleaseSRWLockExclusive" );
51+ }
52+
53+ return 0 ;
54+ }
55+
2856int git_thread_create (
2957 git_thread * GIT_RESTRICT thread ,
3058 void * (* start_routine )(void * ),
@@ -152,15 +180,6 @@ int git_cond_signal(git_cond *cond)
152180 return 0 ;
153181}
154182
155-
156- typedef void (WINAPI * win32_srwlock_fn )(GIT_SRWLOCK * );
157-
158- static win32_srwlock_fn win32_srwlock_initialize ;
159- static win32_srwlock_fn win32_srwlock_acquire_shared ;
160- static win32_srwlock_fn win32_srwlock_release_shared ;
161- static win32_srwlock_fn win32_srwlock_acquire_exclusive ;
162- static win32_srwlock_fn win32_srwlock_release_exclusive ;
163-
164183int git_rwlock_init (git_rwlock * GIT_RESTRICT lock )
165184{
166185 if (win32_srwlock_initialize )
@@ -218,23 +237,3 @@ int git_rwlock_free(git_rwlock *lock)
218237 git__memzero (lock , sizeof (* lock ));
219238 return 0 ;
220239}
221-
222- int win32_pthread_initialize (void )
223- {
224- HMODULE hModule = GetModuleHandleW (L"kernel32" );
225-
226- if (hModule ) {
227- win32_srwlock_initialize = (win32_srwlock_fn )
228- GetProcAddress (hModule , "InitializeSRWLock" );
229- win32_srwlock_acquire_shared = (win32_srwlock_fn )
230- GetProcAddress (hModule , "AcquireSRWLockShared" );
231- win32_srwlock_release_shared = (win32_srwlock_fn )
232- GetProcAddress (hModule , "ReleaseSRWLockShared" );
233- win32_srwlock_acquire_exclusive = (win32_srwlock_fn )
234- GetProcAddress (hModule , "AcquireSRWLockExclusive" );
235- win32_srwlock_release_exclusive = (win32_srwlock_fn )
236- GetProcAddress (hModule , "ReleaseSRWLockExclusive" );
237- }
238-
239- return 0 ;
240- }
0 commit comments