[libc-commits] [libc] [libc] assert.h modifications for newhdrgen (PR #98092)
via libc-commits
libc-commits at lists.llvm.org
Mon Jul 8 15:40:37 PDT 2024
https://github.com/aaryanshukla created https://github.com/llvm/llvm-project/pull/98092
- currently assert.h has a lot of code that does not have a position in
our yaml files. Other files like errno.h and syscall.h have this code
in their respective .h.def files. We want to add that feature to
assert.h by changing assert.h.def.
>From bea73e66cab780c8b449d80b86a3b0fb3975e367 Mon Sep 17 00:00:00 2001
From: Aaryan Shukla <aaryanshukla at google.com>
Date: Mon, 8 Jul 2024 22:37:32 +0000
Subject: [PATCH] [libc] assert.h modifications for newhdrgen
- currently assert.h has a lot of code that does not have a position in
our yaml files. Other files like errno.h and syscall.h have this code
in their respective .h.def files. We want to add that feature to
assert.h by changing assert.h.def.
---
libc/include/assert.h.def | 17 +++++++++++++++++
libc/newhdrgen/yaml/assert.yaml | 15 +++++++++++++++
2 files changed, 32 insertions(+)
create mode 100644 libc/newhdrgen/yaml/assert.yaml
diff --git a/libc/include/assert.h.def b/libc/include/assert.h.def
index 15077e53e2ca48..d5ae14a1cd8101 100644
--- a/libc/include/assert.h.def
+++ b/libc/include/assert.h.def
@@ -12,4 +12,21 @@
// This file may be usefully included multiple times to change assert()'s
// definition based on NDEBUG.
+#ifndef __cplusplus
+#undef static_assert
+#define static_assert _Static_assert
+#endif
+
+#undef assert
+#ifdef NDEBUG
+#define assert(e) (void)0
+#else
+#ifdef __cplusplus
+extern "C"
+#endif
+_Noreturn void __assert_fail(const char *, const char *, unsigned, const char *) __NOEXCEPT;
+#define assert(e) \
+ ((e) ? (void)0 : __assert_fail(#e, __FILE__, __LINE__, __PRETTY_FUNCTION__))
+#endif
+
%%public_api()
diff --git a/libc/newhdrgen/yaml/assert.yaml b/libc/newhdrgen/yaml/assert.yaml
new file mode 100644
index 00000000000000..85de6bc867b224
--- /dev/null
+++ b/libc/newhdrgen/yaml/assert.yaml
@@ -0,0 +1,15 @@
+header: assert.h
+macros: []
+types: []
+enums: []
+objects: []
+functions:
+ - name: __assert_fail
+ - llvm_libc_ext
+ return_type: _Noreturn void
+ arguments:
+ - type: const char *
+ - type: const char *
+ - type: unsigned
+ - type: const char *
+ guard: __cplusplus
\ No newline at end of file
More information about the libc-commits
mailing list