summaryrefslogtreecommitdiff
path: root/src/thread-utils.h
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-04-15 16:31:04 -0700
committerVicent Marti <tanoku@gmail.com>2013-04-22 16:52:07 +0200
commitc628918625c7f779d2050a56998fb2b675f097fb (patch)
tree90ae07f0127035f5ad15633d914290e507ef0ed3 /src/thread-utils.h
parente976b56dda6ae3d7d81bd114b61750e97cc918d3 (diff)
downloadlibgit2-c628918625c7f779d2050a56998fb2b675f097fb.tar.gz
Fixes for Windows cas/threading stuff
Diffstat (limited to 'src/thread-utils.h')
-rw-r--r--src/thread-utils.h9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/thread-utils.h b/src/thread-utils.h
index 7b663182d..e53a60c05 100644
--- a/src/thread-utils.h
+++ b/src/thread-utils.h
@@ -71,16 +71,15 @@ GIT_INLINE(int) git_atomic_dec(git_atomic *a)
GIT_INLINE(void *) git___compare_and_swap(
volatile void **ptr, void *oldval, void *newval)
{
- bool swapped;
+ void *foundval;
#if defined(GIT_WIN32)
- swapped = ((LONGLONG)oldval == InterlockedCompareExchange64(
- (LONGLONG volatile *)ptr, (LONGLONG)newval, (LONGLONG)oldval));
+ foundval = InterlockedCompareExchangePointer(ptr, newval, oldval);
#elif defined(__GNUC__)
- swapped = (__sync_val_compare_and_swap(ptr, oldval, newval) == oldval);
+ foundval = __sync_val_compare_and_swap(ptr, oldval, newval);
#else
# error "Unsupported architecture for atomic operations"
#endif
- return swapped ? oldval : newval;
+ return (foundval == oldval) ? oldval : newval;
}
#else