[libc-commits] [PATCH] D151498: [libc] Support LIBC_COPT_USE_C_ASSERT build flag

Roland McGrath via Phabricator via libc-commits libc-commits at lists.llvm.org
Thu May 25 14:08:07 PDT 2023


mcgrathr created this revision.
mcgrathr added reviewers: abrachet, sivachandra.
Herald added subscribers: libc-commits, tschuett.
Herald added projects: libc-project, All.
mcgrathr requested review of this revision.

In this mode, LIBC_ASSERT is just standard C assert.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151498

Files:
  libc/src/__support/libc_assert.h


Index: libc/src/__support/libc_assert.h
===================================================================
--- libc/src/__support/libc_assert.h
+++ 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 @@
   } while (false)
 #endif // NDEBUG
 
+#endif // LIBC_COPT_USE_C_ASSERT
+
 #endif // LLVM_LIBC_SRC_SUPPORT_LIBC_ASSERT_H


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151498.525793.patch
Type: text/x-patch
Size: 802 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230525/b7f9222b/attachment.bin>


More information about the libc-commits mailing list