[libc-commits] [libc] 4155503 - [libc] Add a note about using assertions in the libc runtime code.
Siva Chandra Reddy via libc-commits
libc-commits at lists.llvm.org
Tue Mar 7 10:18:20 PST 2023
Author: Siva Chandra Reddy
Date: 2023-03-07T10:16:50-08:00
New Revision: 4155503b714bb097ce8cdf3ad03008505210eb08
URL: https://github.com/llvm/llvm-project/commit/4155503b714bb097ce8cdf3ad03008505210eb08
DIFF: https://github.com/llvm/llvm-project/commit/4155503b714bb097ce8cdf3ad03008505210eb08.diff
LOG: [libc] Add a note about using assertions in the libc runtime code.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D145466
Added:
Modified:
libc/docs/dev/code_style.rst
Removed:
################################################################################
diff --git a/libc/docs/dev/code_style.rst b/libc/docs/dev/code_style.rst
index 48197eee2763..c14786fb8874 100644
--- a/libc/docs/dev/code_style.rst
+++ b/libc/docs/dev/code_style.rst
@@ -102,3 +102,15 @@ followed:
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.
More information about the libc-commits
mailing list