summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/atomic.h3
-rw-r--r--src/bfstd.c6
-rw-r--r--src/bfstd.h3
-rw-r--r--src/prelude.h12
-rw-r--r--src/sanity.h18
-rw-r--r--src/xtime.c3
6 files changed, 21 insertions, 24 deletions
diff --git a/src/atomic.h b/src/atomic.h
index ad5303b..a241a03 100644
--- a/src/atomic.h
+++ b/src/atomic.h
@@ -9,7 +9,6 @@
#define BFS_ATOMIC_H
#include "prelude.h"
-#include "sanity.h"
#include <stdatomic.h>
/**
@@ -87,7 +86,7 @@
/**
* Shorthand for atomic_thread_fence().
*/
-#if SANITIZE_THREAD
+#if __SANITIZE_THREAD__
// TSan doesn't support fences: https://github.com/google/sanitizers/issues/1415
# define thread_fence(obj, order) \
fetch_add(obj, 0, order)
diff --git a/src/bfstd.c b/src/bfstd.c
index a179f79..9a3562d 100644
--- a/src/bfstd.c
+++ b/src/bfstd.c
@@ -324,7 +324,7 @@ const char *xstrerror(int errnum) {
// On FreeBSD with MemorySanitizer, duplocale() triggers
// https://github.com/llvm/llvm-project/issues/65532
-#if BFS_HAS_STRERROR_L && !(__FreeBSD__ && SANITIZE_MEMORY)
+#if BFS_HAS_STRERROR_L && !(__FreeBSD__ && __SANITIZE_MEMORY__)
# if BFS_HAS_USELOCALE
locale_t loc = uselocale((locale_t)0);
# else
@@ -715,14 +715,14 @@ int xstrtofflags(const char **str, unsigned long long *set, unsigned long long *
}
long xsysconf(int name) {
-#if __FreeBSD__ && SANITIZE_MEMORY
+#if __FreeBSD__ && __SANITIZE_MEMORY__
// Work around https://github.com/llvm/llvm-project/issues/88163
__msan_scoped_disable_interceptor_checks();
#endif
long ret = sysconf(name);
-#if __FreeBSD__ && SANITIZE_MEMORY
+#if __FreeBSD__ && __SANITIZE_MEMORY__
__msan_scoped_enable_interceptor_checks();
#endif
diff --git a/src/bfstd.h b/src/bfstd.h
index 968c0ac..3a15715 100644
--- a/src/bfstd.h
+++ b/src/bfstd.h
@@ -9,7 +9,6 @@
#define BFS_BFSTD_H
#include "prelude.h"
-#include "sanity.h"
#include <stddef.h>
#include <ctype.h>
@@ -18,7 +17,7 @@
* Work around https://github.com/llvm/llvm-project/issues/65532 by forcing a
* function, not a macro, to be called.
*/
-#if __FreeBSD__ && SANITIZE_MEMORY
+#if __FreeBSD__ && __SANITIZE_MEMORY__
# define BFS_INTERCEPT(fn) (fn)
#else
# define BFS_INTERCEPT(fn) fn
diff --git a/src/prelude.h b/src/prelude.h
index 59fa645..1f5c152 100644
--- a/src/prelude.h
+++ b/src/prelude.h
@@ -156,6 +156,18 @@ extern const char bfs_ldlibs[];
# define __has_builtin(builtin) false
#endif
+// Sanitizer macros (GCC defines these but Clang does not)
+
+#if __has_feature(address_sanitizer) && !defined(__SANITIZE_ADDRESS__)
+# define __SANITIZE_ADDRESS__ true
+#endif
+#if __has_feature(memory_sanitizer) && !defined(__SANITIZE_MEMORY__)
+# define __SANITIZE_MEMORY__ true
+#endif
+#if __has_feature(thread_sanitizer) && !defined(__SANITIZE_THREAD__)
+# define __SANITIZE_THREAD__ true
+#endif
+
// Fundamental utilities
/**
diff --git a/src/sanity.h b/src/sanity.h
index e168b8f..4488be5 100644
--- a/src/sanity.h
+++ b/src/sanity.h
@@ -11,18 +11,6 @@
#include "prelude.h"
#include <stddef.h>
-#if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
-# define SANITIZE_ADDRESS true
-#endif
-
-#if __has_feature(memory_sanitizer) || defined(__SANITIZE_MEMORY__)
-# define SANITIZE_MEMORY true
-#endif
-
-#if __has_feature(thread_sanitizer) || defined(__SANITIZE_THREAD__)
-# define SANITIZE_THREAD true
-#endif
-
// Call macro(ptr, size) or macro(ptr, sizeof(*ptr))
#define SANITIZE_CALL(...) \
SANITIZE_CALL_(__VA_ARGS__, )
@@ -33,7 +21,7 @@
#define SANITIZE_CALL__(macro, ptr, size, ...) \
macro(ptr, size)
-#if SANITIZE_ADDRESS
+#if __SANITIZE_ADDRESS__
# include <sanitizer/asan_interface.h>
/**
@@ -55,7 +43,7 @@
# define sanitize_free sanitize_uninit
#endif
-#if SANITIZE_MEMORY
+#if __SANITIZE_MEMORY__
# include <sanitizer/msan_interface.h>
/**
@@ -85,7 +73,7 @@
/**
* Initialize a variable, unless sanitizers would detect uninitialized uses.
*/
-#if SANITIZE_MEMORY
+#if __SANITIZE_MEMORY__
# define uninit(value)
#else
# define uninit(value) = value
diff --git a/src/xtime.c b/src/xtime.c
index df8fd61..4828119 100644
--- a/src/xtime.c
+++ b/src/xtime.c
@@ -5,7 +5,6 @@
#include "xtime.h"
#include "bfstd.h"
#include "diag.h"
-#include "sanity.h"
#include <errno.h>
#include <limits.h>
#include <sys/time.h>
@@ -36,7 +35,7 @@ int xmktime(struct tm *tm, time_t *timep) {
}
// FreeBSD is missing an interceptor
-#if BFS_HAS_TIMEGM && !(__FreeBSD__ && SANITIZE_MEMORY)
+#if BFS_HAS_TIMEGM && !(__FreeBSD__ && __SANITIZE_MEMORY__)
int xtimegm(struct tm *tm, time_t *timep) {
time_t time = timegm(tm);