Commit 8b26cdbd authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook GitHub Bot

use extern-access for sanitize wrappers

Summary: Should address various build issues.

Reviewed By: Orvid

Differential Revision: D27699043

fbshipit-source-id: 7bcb827c3372e6243554e8bf04426c041b2c62a4
parent ebb45e07
...@@ -14,9 +14,10 @@ ...@@ -14,9 +14,10 @@
* limitations under the License. * limitations under the License.
*/ */
#include <folly/lang/Extern.h>
#include <folly/memory/SanitizeAddress.h> #include <folly/memory/SanitizeAddress.h>
#include <folly/lang/Extern.h>
// Address Sanitizer interface may be found at: // Address Sanitizer interface may be found at:
// https://github.com/llvm-mirror/compiler-rt/blob/master/include/sanitizer/asan_interface.h // https://github.com/llvm-mirror/compiler-rt/blob/master/include/sanitizer/asan_interface.h
extern "C" void* __asan_region_is_poisoned(void*, std::size_t); extern "C" void* __asan_region_is_poisoned(void*, std::size_t);
......
...@@ -16,72 +16,102 @@ ...@@ -16,72 +16,102 @@
#include <folly/synchronization/SanitizeThread.h> #include <folly/synchronization/SanitizeThread.h>
#include <folly/lang/Extern.h>
// abseil uses size_t for size params while other FB code and libraries use // abseil uses size_t for size params while other FB code and libraries use
// long, so it is helpful to keep these declarations out of widely-included // long, so it is helpful to keep these declarations out of widely-included
// header files. // header files.
extern "C" FOLLY_ATTR_WEAK void AnnotateRWLockCreate( extern "C" void AnnotateRWLockCreate(
const char* f, int l, const volatile void* addr); const char* f, int l, const volatile void* addr);
extern "C" FOLLY_ATTR_WEAK void AnnotateRWLockCreateStatic( extern "C" void AnnotateRWLockCreateStatic(
const char* f, int l, const volatile void* addr); const char* f, int l, const volatile void* addr);
extern "C" FOLLY_ATTR_WEAK void AnnotateRWLockDestroy( extern "C" void AnnotateRWLockDestroy(
const char* f, int l, const volatile void* addr); const char* f, int l, const volatile void* addr);
extern "C" FOLLY_ATTR_WEAK void AnnotateRWLockAcquired( extern "C" void AnnotateRWLockAcquired(
const char* f, int l, const volatile void* addr, long w); const char* f, int l, const volatile void* addr, long w);
extern "C" FOLLY_ATTR_WEAK void AnnotateRWLockReleased( extern "C" void AnnotateRWLockReleased(
const char* f, int l, const volatile void* addr, long w); const char* f, int l, const volatile void* addr, long w);
extern "C" FOLLY_ATTR_WEAK void AnnotateBenignRaceSized( extern "C" void AnnotateBenignRaceSized(
const char* f, const char* f,
int l, int l,
const volatile void* addr, const volatile void* addr,
long size, long size,
const char* desc); const char* desc);
extern "C" FOLLY_ATTR_WEAK void AnnotateIgnoreReadsBegin(const char* f, int l); extern "C" void AnnotateIgnoreReadsBegin(const char* f, int l);
extern "C" FOLLY_ATTR_WEAK void AnnotateIgnoreReadsEnd(const char* f, int l);
extern "C" FOLLY_ATTR_WEAK void AnnotateIgnoreWritesBegin(const char* f, int l); extern "C" void AnnotateIgnoreReadsEnd(const char* f, int l);
extern "C" FOLLY_ATTR_WEAK void AnnotateIgnoreWritesEnd(const char* f, int l); extern "C" void AnnotateIgnoreWritesBegin(const char* f, int l);
extern "C" FOLLY_ATTR_WEAK void AnnotateIgnoreSyncBegin(const char* f, int l); extern "C" void AnnotateIgnoreWritesEnd(const char* f, int l);
extern "C" FOLLY_ATTR_WEAK void AnnotateIgnoreSyncEnd(const char* f, int l); extern "C" void AnnotateIgnoreSyncBegin(const char* f, int l);
#ifdef _MSC_VER extern "C" void AnnotateIgnoreSyncEnd(const char* f, int l);
#define FOLLY_SANITIZE_THREAD_CALL_HOOK(name, ...) [](...) {}(__VA_ARGS__)
#else
#define FOLLY_SANITIZE_THREAD_CALL_HOOK(name, ...) name(__VA_ARGS__)
#endif
namespace folly { namespace folly {
namespace detail { namespace detail {
FOLLY_CREATE_EXTERN_ACCESSOR(
annotate_rwlock_create_access_v, AnnotateRWLockCreate);
FOLLY_CREATE_EXTERN_ACCESSOR(
annotate_rwlock_create_static_access_v, AnnotateRWLockCreateStatic);
FOLLY_CREATE_EXTERN_ACCESSOR(
annotate_rwlock_destroy_access_v, AnnotateRWLockDestroy);
FOLLY_CREATE_EXTERN_ACCESSOR(
annotate_rwlock_acquired_access_v, AnnotateRWLockAcquired);
FOLLY_CREATE_EXTERN_ACCESSOR(
annotate_rwlock_released_access_v, AnnotateRWLockReleased);
FOLLY_CREATE_EXTERN_ACCESSOR(
annotate_benign_race_sized_access_v, AnnotateBenignRaceSized);
FOLLY_CREATE_EXTERN_ACCESSOR(
annotate_ignore_reads_begin_access_v, AnnotateIgnoreReadsBegin);
FOLLY_CREATE_EXTERN_ACCESSOR(
annotate_ignore_reads_end_access_v, AnnotateIgnoreReadsEnd);
FOLLY_CREATE_EXTERN_ACCESSOR(
annotate_ignore_writes_begin_access_v, AnnotateIgnoreWritesBegin);
FOLLY_CREATE_EXTERN_ACCESSOR(
annotate_ignore_writes_end_access_v, AnnotateIgnoreWritesEnd);
FOLLY_CREATE_EXTERN_ACCESSOR(
annotate_ignore_sync_begin_access_v, AnnotateIgnoreSyncBegin);
FOLLY_CREATE_EXTERN_ACCESSOR(
annotate_ignore_sync_end_access_v, AnnotateIgnoreSyncEnd);
void annotate_rwlock_create_impl( void annotate_rwlock_create_impl(
void const volatile* const addr, char const* const f, int const l) { void const volatile* const addr, char const* const f, int const l) {
if (kIsSanitizeThread) { constexpr auto fun = annotate_rwlock_create_access_v<kIsSanitizeThread>;
FOLLY_SANITIZE_THREAD_CALL_HOOK(AnnotateRWLockCreate, f, l, addr); return fun ? fun(f, l, addr) : void();
}
} }
void annotate_rwlock_create_static_impl( void annotate_rwlock_create_static_impl(
void const volatile* const addr, char const* const f, int const l) { void const volatile* const addr, char const* const f, int const l) {
if (kIsSanitizeThread) { constexpr auto fun =
FOLLY_SANITIZE_THREAD_CALL_HOOK(AnnotateRWLockCreateStatic, f, l, addr); annotate_rwlock_create_static_access_v<kIsSanitizeThread>;
} return fun ? fun(f, l, addr) : void();
} }
void annotate_rwlock_destroy_impl( void annotate_rwlock_destroy_impl(
void const volatile* const addr, char const* const f, int const l) { void const volatile* const addr, char const* const f, int const l) {
if (kIsSanitizeThread) { constexpr auto fun = annotate_rwlock_destroy_access_v<kIsSanitizeThread>;
FOLLY_SANITIZE_THREAD_CALL_HOOK(AnnotateRWLockDestroy, f, l, addr); return fun ? fun(f, l, addr) : void();
}
} }
void annotate_rwlock_acquired_impl( void annotate_rwlock_acquired_impl(
...@@ -89,10 +119,8 @@ void annotate_rwlock_acquired_impl( ...@@ -89,10 +119,8 @@ void annotate_rwlock_acquired_impl(
annotate_rwlock_level const w, annotate_rwlock_level const w,
char const* const f, char const* const f,
int const l) { int const l) {
if (kIsSanitizeThread) { constexpr auto fun = annotate_rwlock_acquired_access_v<kIsSanitizeThread>;
FOLLY_SANITIZE_THREAD_CALL_HOOK( return fun ? fun(f, l, addr, static_cast<long>(w)) : void();
AnnotateRWLockAcquired, f, l, addr, static_cast<long>(w));
}
} }
void annotate_rwlock_try_acquired_impl( void annotate_rwlock_try_acquired_impl(
...@@ -111,10 +139,8 @@ void annotate_rwlock_released_impl( ...@@ -111,10 +139,8 @@ void annotate_rwlock_released_impl(
annotate_rwlock_level const w, annotate_rwlock_level const w,
char const* const f, char const* const f,
int const l) { int const l) {
if (kIsSanitizeThread) { constexpr auto fun = annotate_rwlock_released_access_v<kIsSanitizeThread>;
FOLLY_SANITIZE_THREAD_CALL_HOOK( return fun ? fun(f, l, addr, static_cast<long>(w)) : void();
AnnotateRWLockReleased, f, l, addr, static_cast<long>(w));
}
} }
void annotate_benign_race_sized_impl( void annotate_benign_race_sized_impl(
...@@ -123,46 +149,38 @@ void annotate_benign_race_sized_impl( ...@@ -123,46 +149,38 @@ void annotate_benign_race_sized_impl(
const char* desc, const char* desc,
const char* f, const char* f,
int l) { int l) {
if (kIsSanitizeThread) { constexpr auto fun = annotate_benign_race_sized_access_v<kIsSanitizeThread>;
FOLLY_SANITIZE_THREAD_CALL_HOOK( return fun ? fun(f, l, addr, size, desc) : void();
AnnotateBenignRaceSized, f, l, addr, size, desc);
}
} }
void annotate_ignore_reads_begin_impl(const char* f, int l) { void annotate_ignore_reads_begin_impl(const char* f, int l) {
if (kIsSanitizeThread) { constexpr auto fun = annotate_ignore_reads_begin_access_v<kIsSanitizeThread>;
FOLLY_SANITIZE_THREAD_CALL_HOOK(AnnotateIgnoreReadsBegin, f, l); return fun ? fun(f, l) : void();
}
} }
void annotate_ignore_reads_end_impl(const char* f, int l) { void annotate_ignore_reads_end_impl(const char* f, int l) {
if (kIsSanitizeThread) { constexpr auto fun = annotate_ignore_reads_end_access_v<kIsSanitizeThread>;
FOLLY_SANITIZE_THREAD_CALL_HOOK(AnnotateIgnoreReadsEnd, f, l); return fun ? fun(f, l) : void();
}
} }
void annotate_ignore_writes_begin_impl(const char* f, int l) { void annotate_ignore_writes_begin_impl(const char* f, int l) {
if (kIsSanitizeThread) { constexpr auto fun = annotate_ignore_writes_begin_access_v<kIsSanitizeThread>;
FOLLY_SANITIZE_THREAD_CALL_HOOK(AnnotateIgnoreWritesBegin, f, l); return fun ? fun(f, l) : void();
}
} }
void annotate_ignore_writes_end_impl(const char* f, int l) { void annotate_ignore_writes_end_impl(const char* f, int l) {
if (kIsSanitizeThread) { constexpr auto fun = annotate_ignore_writes_end_access_v<kIsSanitizeThread>;
FOLLY_SANITIZE_THREAD_CALL_HOOK(AnnotateIgnoreWritesEnd, f, l); return fun ? fun(f, l) : void();
}
} }
void annotate_ignore_sync_begin_impl(const char* f, int l) { void annotate_ignore_sync_begin_impl(const char* f, int l) {
if (kIsSanitizeThread) { constexpr auto fun = annotate_ignore_sync_begin_access_v<kIsSanitizeThread>;
FOLLY_SANITIZE_THREAD_CALL_HOOK(AnnotateIgnoreSyncBegin, f, l); return fun ? fun(f, l) : void();
}
} }
void annotate_ignore_sync_end_impl(const char* f, int l) { void annotate_ignore_sync_end_impl(const char* f, int l) {
if (kIsSanitizeThread) { constexpr auto fun = annotate_ignore_sync_end_access_v<kIsSanitizeThread>;
FOLLY_SANITIZE_THREAD_CALL_HOOK(AnnotateIgnoreSyncEnd, f, l); return fun ? fun(f, l) : void();
}
} }
} // namespace detail } // namespace detail
} // namespace folly } // namespace folly
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