#include "sanitizer_common/sanitizer_platform.h"
#if SANITIZER_POSIX
# include <pthread.h>
# include <signal.h>
# include <stdlib.h>
# include <sys/resource.h>
# include <sys/time.h>
# include <unistd.h>
# include "asan_interceptors.h"
# include "asan_internal.h"
# include "asan_mapping.h"
# include "asan_poisoning.h"
# include "asan_report.h"
# include "asan_stack.h"
# include "lsan/lsan_common.h"
# include "sanitizer_common/sanitizer_libc.h"
# include "sanitizer_common/sanitizer_posix.h"
# include "sanitizer_common/sanitizer_procmaps.h"
namespace __asan {
void AsanOnDeadlySignal(int signo, void *siginfo, void *context) { … }
bool PlatformUnpoisonStacks() { … }
#if SANITIZER_NETBSD && !ASAN_DYNAMIC
static void (*tsd_destructor)(void *tsd) = nullptr;
struct tsd_key {
tsd_key() : key(nullptr) {}
~tsd_key() {
CHECK(tsd_destructor);
if (key)
(*tsd_destructor)(key);
}
void *key;
};
static thread_local struct tsd_key key;
void AsanTSDInit(void (*destructor)(void *tsd)) {
CHECK(!tsd_destructor);
tsd_destructor = destructor;
}
void *AsanTSDGet() {
CHECK(tsd_destructor);
return key.key;
}
void AsanTSDSet(void *tsd) {
CHECK(tsd_destructor);
CHECK(tsd);
CHECK(!key.key);
key.key = tsd;
}
void PlatformTSDDtor(void *tsd) {
CHECK(tsd_destructor);
CHECK_EQ(key.key, tsd);
key.key = nullptr;
atomic_signal_fence(memory_order_seq_cst);
AsanThread::TSDDtor(tsd);
}
#else
static pthread_key_t tsd_key;
static bool tsd_key_inited = …;
void AsanTSDInit(void (*destructor)(void *tsd)) { … }
void *AsanTSDGet() { … }
void AsanTSDSet(void *tsd) { … }
void PlatformTSDDtor(void *tsd) { … }
# endif
static void BeforeFork() { … }
static void AfterFork(bool fork_child) { … }
void InstallAtForkHandler() { … }
void InstallAtExitCheckLeaks() { … }
}
#endif