diff options
author | Vicent Martà <tanoku@gmail.com> | 2012-01-26 18:03:14 -0800 |
---|---|---|
committer | Vicent Martà <tanoku@gmail.com> | 2012-01-26 18:03:14 -0800 |
commit | 7a6f51de6d4f5543634889e58c30a0a6ceb75a09 (patch) | |
tree | bce97889b53a13977dcd81884fb1fff543115645 /src/thread-utils.h | |
parent | a53420e4b0efc9b1d87d6d13473d7f29ef4c68ee (diff) | |
download | libgit2-7a6f51de6d4f5543634889e58c30a0a6ceb75a09.tar.gz |
win32: Use the Windows Atomic API on MinGW too
Diffstat (limited to 'src/thread-utils.h')
-rw-r--r-- | src/thread-utils.h | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/thread-utils.h b/src/thread-utils.h index c5554799c..913941978 100644 --- a/src/thread-utils.h +++ b/src/thread-utils.h @@ -11,7 +11,7 @@ /* Common operations even if threading has been disabled */ typedef struct { -#if defined(_MSC_VER) +#if defined(GIT_WIN32) volatile long val; #else volatile int val; @@ -48,10 +48,10 @@ GIT_INLINE(void) git_atomic_set(git_atomic *a, int val) GIT_INLINE(int) git_atomic_inc(git_atomic *a) { -#ifdef __GNUC__ - return __sync_add_and_fetch(&a->val, 1); -#elif defined(_MSC_VER) +#if defined(GIT_WIN32) return InterlockedIncrement(&a->val); +#elif defined(__GNUC__) + return __sync_add_and_fetch(&a->val, 1); #else # error "Unsupported architecture for atomic operations" #endif @@ -59,10 +59,10 @@ GIT_INLINE(int) git_atomic_inc(git_atomic *a) GIT_INLINE(int) git_atomic_dec(git_atomic *a) { -#ifdef __GNUC__ - return __sync_sub_and_fetch(&a->val, 1); -#elif defined(_MSC_VER) +#if defined(GIT_WIN32) return InterlockedDecrement(&a->val); +#elif defined(__GNUC__) + return __sync_sub_and_fetch(&a->val, 1); #else # error "Unsupported architecture for atomic operations" #endif |