forked from OSchip/llvm-project
tsan: fix freebsd build
freebsd does not have /proc/self/environ llvm-svn: 211417
This commit is contained in:
parent
c3510c74f7
commit
f9c22916d5
|
@ -48,6 +48,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#if SANITIZER_FREEBSD
|
#if SANITIZER_FREEBSD
|
||||||
|
#include <stdlib.h> // for getenv
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#include <machine/atomic.h>
|
#include <machine/atomic.h>
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -314,6 +315,7 @@ u64 NanoTime() {
|
||||||
return (u64)tv.tv_sec * 1000*1000*1000 + tv.tv_usec * 1000;
|
return (u64)tv.tv_sec * 1000*1000*1000 + tv.tv_usec * 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if SANITIZER_LINUX
|
||||||
// Like getenv, but reads env directly from /proc and does not use libc.
|
// Like getenv, but reads env directly from /proc and does not use libc.
|
||||||
// This function should be called first inside __asan_init.
|
// This function should be called first inside __asan_init.
|
||||||
const char *GetEnv(const char *name) {
|
const char *GetEnv(const char *name) {
|
||||||
|
@ -341,6 +343,11 @@ const char *GetEnv(const char *name) {
|
||||||
}
|
}
|
||||||
return 0; // Not found.
|
return 0; // Not found.
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
const char *GetEnv(const char *name) {
|
||||||
|
return getenv(name);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
SANITIZER_WEAK_ATTRIBUTE extern void *__libc_stack_end;
|
SANITIZER_WEAK_ATTRIBUTE extern void *__libc_stack_end;
|
||||||
|
|
Loading…
Reference in New Issue