diff options
| author | Ben Straub <bs@github.com> | 2013-10-04 19:35:32 -0700 |
|---|---|---|
| committer | Ben Straub <bs@github.com> | 2013-10-04 19:35:32 -0700 |
| commit | 22661448973e3c46f2a71a75364630a5111f7c14 (patch) | |
| tree | 3bec12fb3966e5733e739ceb638cfef4008b97ed /src/global.c | |
| parent | cdc95a0d93aa3b515f9c4fe30f47d52e8e7f3dde (diff) | |
| download | libgit2-22661448973e3c46f2a71a75364630a5111f7c14.tar.gz | |
Don't use git_atomic as an integer
Diffstat (limited to 'src/global.c')
| -rw-r--r-- | src/global.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/global.c b/src/global.c index 33a760c54..7d39c6fa8 100644 --- a/src/global.c +++ b/src/global.c @@ -18,7 +18,6 @@ git_mutex git__mwindow_mutex; git_global_shutdown_fn git__shutdown_callbacks[MAX_SHUTDOWN_CB]; git_atomic git__n_shutdown_callbacks; -git_atomic git__n_inits; void git__on_shutdown(git_global_shutdown_fn callback) { @@ -75,6 +74,7 @@ static void git__shutdown(void) static DWORD _tls_index; static DWORD _mutex = 0; +static DWORD _n_inits = 0; static int synchronized_threads_init() { @@ -101,7 +101,7 @@ int git_threads_init(void) while (InterlockedCompareExchange(&_mutex, 1, 0)) { Sleep(0); } /* Only do work on a 0 -> 1 transition of the refcount */ - if (1 == ++git__n_inits.val) + if (1 == ++_n_inits) error = synchronized_threads_init(); /* Exit the lock */ @@ -124,7 +124,7 @@ void git_threads_shutdown(void) while (InterlockedCompareExchange(&_mutex, 1, 0)) { Sleep(0); } /* Only do work on a 1 -> 0 transition of the refcount */ - if (0 == --git__n_inits.val) + if (0 == --_n_inits) synchronized_threads_shutdown(); /* Exit the lock */ @@ -135,7 +135,7 @@ git_global_st *git__global_state(void) { void *ptr; - assert(git__n_inits.val); + assert(_n_inits); if ((ptr = TlsGetValue(_tls_index)) != NULL) return ptr; @@ -153,6 +153,7 @@ git_global_st *git__global_state(void) static pthread_key_t _tls_key; static pthread_once_t _once_init = PTHREAD_ONCE_INIT; +static git_atomic git__n_inits; int init_error = 0; static void cb__free_status(void *st) |
