Commit 30eadf6d authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Simplify ASAN support in folly/MicroLock.h

Summary: [Folly] Simplify ASAN support in `folly/MicroLock.h`.

Reviewed By: mzlee

Differential Revision: D17842549

fbshipit-source-id: c9e89d8c69f8a291427a73fee12651353a5da4e4
parent 87ec63d8
......@@ -23,12 +23,6 @@
#include <folly/Portability.h>
#include <folly/detail/Futex.h>
#if defined(__clang__)
#define NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address))
#else
#define NO_SANITIZE_ADDRESS
#endif
namespace folly {
/**
......@@ -98,12 +92,7 @@ namespace folly {
class MicroLockCore {
protected:
#if defined(__SANITIZE_ADDRESS__) && !defined(__clang__) && \
(defined(__GNUC__) || defined(__GNUG__))
uint32_t lock_;
#else
uint8_t lock_;
#endif
inline detail::Futex<>* word() const; // Well, halfword on 64-bit systems
inline uint32_t baseShift(unsigned slot) const;
inline uint32_t heldBit(unsigned slot) const;
......@@ -116,7 +105,7 @@ class MicroLockCore {
unsigned maxYields);
public:
inline void unlock(unsigned slot) NO_SANITIZE_ADDRESS;
FOLLY_DISABLE_ADDRESS_SANITIZER inline void unlock(unsigned slot);
inline void unlock() {
unlock(0);
}
......@@ -169,11 +158,11 @@ void MicroLockCore::unlock(unsigned slot) {
template <unsigned MaxSpins = 1000, unsigned MaxYields = 0>
class MicroLockBase : public MicroLockCore {
public:
inline void lock(unsigned slot) NO_SANITIZE_ADDRESS;
FOLLY_DISABLE_ADDRESS_SANITIZER inline void lock(unsigned slot);
inline void lock() {
lock(0);
}
inline bool try_lock(unsigned slot) NO_SANITIZE_ADDRESS;
FOLLY_DISABLE_ADDRESS_SANITIZER inline bool try_lock(unsigned slot);
inline bool try_lock() {
return try_lock(0);
}
......
......@@ -218,14 +218,7 @@ TEST(SmallLocks, RegClobber) {
TestClobber().go();
}
FOLLY_PACK_PUSH
#if defined(__SANITIZE_ADDRESS__) && !defined(__clang__) && \
(defined(__GNUC__) || defined(__GNUG__))
static_assert(sizeof(MicroLock) == 4, "Size check failed");
#else
static_assert(sizeof(MicroLock) == 1, "Size check failed");
#endif
FOLLY_PACK_POP
namespace {
......
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