From bea30f8a2cb5e29749ae4965775094e4c93f73d1 Mon Sep 17 00:00:00 2001 From: Joe Bryan Date: Tue, 17 Dec 2019 23:57:23 -0800 Subject: [PATCH] u3: specially defines c3_assert for ASan compatiblity --- pkg/urbit/include/c/defs.h | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/pkg/urbit/include/c/defs.h b/pkg/urbit/include/c/defs.h index e6cb107e99..636ee861bb 100644 --- a/pkg/urbit/include/c/defs.h +++ b/pkg/urbit/include/c/defs.h @@ -17,16 +17,27 @@ **/ /* Assert. Good to capture. */ -# define c3_assert(x) \ - do { \ - if (!(x)) { \ - fprintf(stderr, "\rAssertion '%s' " \ - "failed in %s:%d\n", \ - #x, __FILE__, __LINE__); \ - c3_cooked(); \ - assert(x); \ - } \ - } while(0) + +# if defined(ASAN_ENABLED) && defined(__clang__) +# define c3_assert(x) \ + do { \ + if (!(x)) { \ + c3_cooked(); \ + assert(x); \ + } \ + } while(0) +# else +# define c3_assert(x) \ + do { \ + if (!(x)) { \ + fprintf(stderr, "\rAssertion '%s' " \ + "failed in %s:%d\n", \ + #x, __FILE__, __LINE__); \ + c3_cooked(); \ + assert(x); \ + } \ + } while(0) +#endif /* Stub. */