mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-21 18:03:54 +00:00
win32: Use the Windows Atomic API on MinGW too
This commit is contained in:
parent
a53420e4b0
commit
7a6f51de6d
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
/* Common operations even if threading has been disabled */
|
/* Common operations even if threading has been disabled */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
#if defined(_MSC_VER)
|
#if defined(GIT_WIN32)
|
||||||
volatile long val;
|
volatile long val;
|
||||||
#else
|
#else
|
||||||
volatile int val;
|
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)
|
GIT_INLINE(int) git_atomic_inc(git_atomic *a)
|
||||||
{
|
{
|
||||||
#ifdef __GNUC__
|
#if defined(GIT_WIN32)
|
||||||
return __sync_add_and_fetch(&a->val, 1);
|
|
||||||
#elif defined(_MSC_VER)
|
|
||||||
return InterlockedIncrement(&a->val);
|
return InterlockedIncrement(&a->val);
|
||||||
|
#elif defined(__GNUC__)
|
||||||
|
return __sync_add_and_fetch(&a->val, 1);
|
||||||
#else
|
#else
|
||||||
# error "Unsupported architecture for atomic operations"
|
# error "Unsupported architecture for atomic operations"
|
||||||
#endif
|
#endif
|
||||||
@ -59,10 +59,10 @@ GIT_INLINE(int) git_atomic_inc(git_atomic *a)
|
|||||||
|
|
||||||
GIT_INLINE(int) git_atomic_dec(git_atomic *a)
|
GIT_INLINE(int) git_atomic_dec(git_atomic *a)
|
||||||
{
|
{
|
||||||
#ifdef __GNUC__
|
#if defined(GIT_WIN32)
|
||||||
return __sync_sub_and_fetch(&a->val, 1);
|
|
||||||
#elif defined(_MSC_VER)
|
|
||||||
return InterlockedDecrement(&a->val);
|
return InterlockedDecrement(&a->val);
|
||||||
|
#elif defined(__GNUC__)
|
||||||
|
return __sync_sub_and_fetch(&a->val, 1);
|
||||||
#else
|
#else
|
||||||
# error "Unsupported architecture for atomic operations"
|
# error "Unsupported architecture for atomic operations"
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user