-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[libc] Allow user-defined LIBC_ASSERT macro. #168087
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…BC_ASSERT macro is not defined.
|
@llvm/pr-subscribers-libc Author: None (lntue) ChangesBy only defining it if LIBC_ASSERT macro is not defined. Fixes #162392 Full diff: https://github.com/llvm/llvm-project/pull/168087.diff 1 Files Affected:
diff --git a/libc/src/__support/libc_assert.h b/libc/src/__support/libc_assert.h
index ada1795ccb80a..6e0b5bd3d68b4 100644
--- a/libc/src/__support/libc_assert.h
+++ b/libc/src/__support/libc_assert.h
@@ -14,9 +14,11 @@
// The build is configured to just use the public <assert.h> API
// for libc's internal assertions.
+#ifndef LIBC_ASSERT
#include <assert.h>
#define LIBC_ASSERT(COND) assert(COND)
+#endif // LIBC_ASSERT
#else // Not LIBC_COPT_USE_C_ASSERT
|
ldionne
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
ldionne
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious, what is LIBC_COPT_USE_C_ASSERT?
michaelrj-google
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
It selects if we want to use the public C assert API or our own internal API for assertions. |
It is to skip the internal implementation of assertion in full build mode, mostly to be used in GPU offload or embedded systems. |
By only defining it if LIBC_ASSERT macro is not defined.
Fixes #162392