Commit d6a6bb23 authored by Orvid King's avatar Orvid King Committed by facebook-github-bot-4

Added asm_volatile_memory

Summary: This adds `asm_volatile_memory`, which goes along with the same style used by `asm_volatile_pause`.
This also switches the two places in `RWSpinLock.h` that were using inline assembly for this to use the new functions instead.
Closes #260

Reviewed By: @yfeldblum

Differential Revision: D2283541

Pulled By: @sgolemon
parent 65220fef
......@@ -339,6 +339,14 @@ inline size_t malloc_usable_size(void* ptr) {
namespace folly {
inline void asm_volatile_memory() {
#if defined(__clang__) || defined(__GNUC__)
asm volatile("" : : : "memory");
#elif defined(_MSC_VER)
::_ReadWriteBarrier();
#endif
}
inline void asm_volatile_pause() {
#if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))
::_mm_pause();
......
......@@ -525,13 +525,13 @@ class RWTicketSpinLockT : boost::noncopyable {
private: // Some x64-specific utilities for atomic access to ticket.
template<class T> static T load_acquire(T* addr) {
T t = *addr; // acquire barrier
asm volatile("" : : : "memory");
asm_volatile_memory();
return t;
}
template<class T>
static void store_release(T* addr, T v) {
asm volatile("" : : : "memory");
asm_volatile_memory();
*addr = v; // release barrier
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment