[libc-commits] [libc] 65c7893 - [libc] Support LIBC_COPT_USE_C_ASSERT build flag
Roland McGrath via libc-commits
libc-commits at lists.llvm.org
Thu May 25 14:10:50 PDT 2023
Author: Roland McGrath
Date: 2023-05-25T14:10:33-07:00
New Revision: 65c78933ae22a9a26b56ed763f5827765ce7eadf
URL: https://github.com/llvm/llvm-project/commit/65c78933ae22a9a26b56ed763f5827765ce7eadf
DIFF: https://github.com/llvm/llvm-project/commit/65c78933ae22a9a26b56ed763f5827765ce7eadf.diff
LOG: [libc] Support LIBC_COPT_USE_C_ASSERT build flag
In this mode, LIBC_ASSERT is just standard C assert.
Reviewed By: abrachet
Differential Revision: https://reviews.llvm.org/D151498
Added:
Modified:
libc/src/__support/libc_assert.h
Removed:
################################################################################
diff --git a/libc/src/__support/libc_assert.h b/libc/src/__support/libc_assert.h
index d8a1d5fe7678..3aa74ec748fc 100644
--- a/libc/src/__support/libc_assert.h
+++ b/libc/src/__support/libc_assert.h
@@ -9,6 +9,17 @@
#ifndef LLVM_LIBC_SRC_SUPPORT_LIBC_ASSERT_H
#define LLVM_LIBC_SRC_SUPPORT_LIBC_ASSERT_H
+#ifdef LIBC_COPT_USE_C_ASSERT
+
+// The build is configured to just use the public <assert.h> API
+// for libc's internal assertions.
+
+#include <assert.h>
+
+#define LIBC_ASSERT(COND) assert(COND)
+
+#else // Not LIBC_COPT_USE_C_ASSERT
+
#include "src/__support/OSUtil/io.h"
#include "src/__support/OSUtil/quick_exit.h"
#include "src/__support/integer_to_string.h"
@@ -58,4 +69,6 @@ LIBC_INLINE void report_assertion_failure(const char *assertion,
} while (false)
#endif // NDEBUG
+#endif // LIBC_COPT_USE_C_ASSERT
+
#endif // LLVM_LIBC_SRC_SUPPORT_LIBC_ASSERT_H
More information about the libc-commits
mailing list