Eliminate the atomic porability header's dependence on Windows.h
authorChristopher Dykes <cdykes@fb.com>
Thu, 4 Aug 2016 22:38:29 +0000 (15:38 -0700)
committerFacebook Github Bot 8 <facebook-github-bot-8-bot@fb.com>
Thu, 4 Aug 2016 22:54:22 +0000 (15:54 -0700)
Summary:
This is done by using the intrinsic directly instead.
This also marks the input parameter as `volatile`, to make it more clear that that's how it is handled by `_InterlockedExchangeAdd64`.

Reviewed By: yfeldblum

Differential Revision: D3671320

fbshipit-source-id: 6010085ec3b6952a3eb1e952965ec6ad87566db2

folly/portability/Atomic.h

index 811c24ccb81ab1fc3bd5794ffbc70a346050d146..8aa9f307c464cfbb714d01205e3074e46a7cfda1 100755 (executable)
 
 #ifdef _WIN32
 
+#include <intrin.h>
 #include <stdint.h>
 
 #include <folly/Portability.h>
-// The intrinsics we need are in Windows.h :(
-#include <folly/portability/Windows.h>
 
-FOLLY_ALWAYS_INLINE int64_t __sync_fetch_and_add(int64_t* ptr, int64_t value) {
-  return InterlockedExchangeAdd64(ptr, value);
+FOLLY_ALWAYS_INLINE
+int64_t __sync_fetch_and_add(volatile int64_t* ptr, int64_t value) {
+  return _InterlockedExchangeAdd64(ptr, value);
 }
 
 #endif