[libc-commits] [PATCH] D145466: [libc] Add a note about using assertions in the libc runtime code.
Siva Chandra via Phabricator via libc-commits
libc-commits at lists.llvm.org
Mon Mar 6 21:09:46 PST 2023
sivachandra created this revision.
sivachandra added reviewers: lntue, michaelrj.
Herald added subscribers: libc-commits, ecnelises, tschuett.
Herald added projects: libc-project, All.
sivachandra requested review of this revision.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D145466
Files:
libc/docs/dev/code_style.rst
Index: libc/docs/dev/code_style.rst
===================================================================
--- libc/docs/dev/code_style.rst
+++ libc/docs/dev/code_style.rst
@@ -102,3 +102,15 @@
entrypoint is the only exceptional entrypoint on which other entrypoints
should explicitly depend on if they set ``errno`` to indicate error
conditions.
+
+Assertions in libc runtime code
+===============================
+
+The libc developers should, and are encouraged to, use assertions freely in
+the libc runtime code. However, the assertion should be listed via the macro
+``LIBC_ASSERT`` defined in ``src/__support/libc_assert.h``. This macro can be
+used from anywhere in the libc runtime code. Internally, all it does is to
+print the assertion expression and exit. It does not implement the semantics
+of the standard ``assert`` macro. Hence, it can be used from any where in the
+libc runtime code without causing any recursive calls or chicken-and-egg
+situations.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145466.502913.patch
Type: text/x-patch
Size: 980 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230307/0fec2318/attachment.bin>
More information about the libc-commits
mailing list