diff options
| author | Patrick Steinhardt <ps@pks.im> | 2016-06-20 20:07:33 +0200 |
|---|---|---|
| committer | Patrick Steinhardt <ps@pks.im> | 2016-06-20 20:07:33 +0200 |
| commit | aab266c93256fbf89a000778b454c5d60bae43a9 (patch) | |
| tree | 2fb24ca1fdc06eda35056b1b23fa78ee91009a64 /src/win32/thread.c | |
| parent | 8aaa9fb6238336b313766d7bd9c20cff07cb840b (diff) | |
| download | libgit2-aab266c93256fbf89a000778b454c5d60bae43a9.tar.gz | |
threads: add platform-independent thread initialization function
Diffstat (limited to 'src/win32/thread.c')
| -rw-r--r-- | src/win32/thread.c | 57 |
1 files changed, 28 insertions, 29 deletions
diff --git a/src/win32/thread.c b/src/win32/thread.c index 8222c65fe..80d56ce5d 100644 --- a/src/win32/thread.c +++ b/src/win32/thread.c @@ -10,6 +10,14 @@ #define CLEAN_THREAD_EXIT 0x6F012842 +typedef void (WINAPI *win32_srwlock_fn)(GIT_SRWLOCK *); + +static win32_srwlock_fn win32_srwlock_initialize; +static win32_srwlock_fn win32_srwlock_acquire_shared; +static win32_srwlock_fn win32_srwlock_release_shared; +static win32_srwlock_fn win32_srwlock_acquire_exclusive; +static win32_srwlock_fn win32_srwlock_release_exclusive; + /* The thread procedure stub used to invoke the caller's procedure * and capture the return value for later collection. Windows will * 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) return CLEAN_THREAD_EXIT; } +int git_threads_init(void) +{ + HMODULE hModule = GetModuleHandleW(L"kernel32"); + + if (hModule) { + win32_srwlock_initialize = (win32_srwlock_fn) + GetProcAddress(hModule, "InitializeSRWLock"); + win32_srwlock_acquire_shared = (win32_srwlock_fn) + GetProcAddress(hModule, "AcquireSRWLockShared"); + win32_srwlock_release_shared = (win32_srwlock_fn) + GetProcAddress(hModule, "ReleaseSRWLockShared"); + win32_srwlock_acquire_exclusive = (win32_srwlock_fn) + GetProcAddress(hModule, "AcquireSRWLockExclusive"); + win32_srwlock_release_exclusive = (win32_srwlock_fn) + GetProcAddress(hModule, "ReleaseSRWLockExclusive"); + } + + return 0; +} + int git_thread_create( git_thread *GIT_RESTRICT thread, void *(*start_routine)(void*), @@ -152,15 +180,6 @@ int git_cond_signal(git_cond *cond) return 0; } - -typedef void (WINAPI *win32_srwlock_fn)(GIT_SRWLOCK *); - -static win32_srwlock_fn win32_srwlock_initialize; -static win32_srwlock_fn win32_srwlock_acquire_shared; -static win32_srwlock_fn win32_srwlock_release_shared; -static win32_srwlock_fn win32_srwlock_acquire_exclusive; -static win32_srwlock_fn win32_srwlock_release_exclusive; - int git_rwlock_init(git_rwlock *GIT_RESTRICT lock) { if (win32_srwlock_initialize) @@ -218,23 +237,3 @@ int git_rwlock_free(git_rwlock *lock) git__memzero(lock, sizeof(*lock)); return 0; } - -int win32_pthread_initialize(void) -{ - HMODULE hModule = GetModuleHandleW(L"kernel32"); - - if (hModule) { - win32_srwlock_initialize = (win32_srwlock_fn) - GetProcAddress(hModule, "InitializeSRWLock"); - win32_srwlock_acquire_shared = (win32_srwlock_fn) - GetProcAddress(hModule, "AcquireSRWLockShared"); - win32_srwlock_release_shared = (win32_srwlock_fn) - GetProcAddress(hModule, "ReleaseSRWLockShared"); - win32_srwlock_acquire_exclusive = (win32_srwlock_fn) - GetProcAddress(hModule, "AcquireSRWLockExclusive"); - win32_srwlock_release_exclusive = (win32_srwlock_fn) - GetProcAddress(hModule, "ReleaseSRWLockExclusive"); - } - - return 0; -} |
