Skip to content

Commit 34e06dc

Browse files
authored
[libc] newheadergen: added assert.yaml (#98826)
- removed assert macro definitions in api.td - included macro definitions in assert.h.def - added assert.yaml
1 parent d286efe commit 34e06dc

File tree

5 files changed

+36
-100
lines changed

5 files changed

+36
-100
lines changed

libc/config/baremetal/api.td

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,6 @@ include "spec/stdc_ext.td"
55
include "spec/bsd_ext.td"
66
include "spec/llvm_libc_stdfix_ext.td"
77

8-
def AssertMacro : MacroDef<"assert"> {
9-
let Defn = [{
10-
#undef assert
11-
12-
#ifdef NDEBUG
13-
#define assert(e) (void)0
14-
#else
15-
16-
#ifdef __cplusplus
17-
extern "C"
18-
#endif
19-
_Noreturn void __assert_fail(const char *, const char *, unsigned, const char *) __NOEXCEPT;
20-
21-
#define assert(e) \
22-
((e) ? (void)0 : __assert_fail(#e, __FILE__, __LINE__, __PRETTY_FUNCTION__))
23-
24-
#endif
25-
}];
26-
}
27-
28-
def StaticAssertMacro : MacroDef<"static_assert"> {
29-
let Defn = [{
30-
#ifndef __cplusplus
31-
#undef static_assert
32-
#define static_assert _Static_assert
33-
#endif
34-
}];
35-
}
36-
37-
def AssertAPI : PublicAPI<"assert.h"> {
38-
let Macros = [
39-
AssertMacro,
40-
StaticAssertMacro,
41-
];
42-
}
438

449
def CTypeAPI : PublicAPI<"ctype.h"> {
4510
}

libc/config/gpu/api.td

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,6 @@ include "spec/gnu_ext.td"
77
include "spec/stdc_ext.td"
88
include "spec/llvm_libc_ext.td"
99

10-
def AssertMacro : MacroDef<"assert"> {
11-
let Defn = [{
12-
#undef assert
13-
14-
#ifdef NDEBUG
15-
#define assert(e) (void)0
16-
#else
17-
18-
#define assert(e) \
19-
((e) ? (void)0 : __assert_fail(#e, __FILE__, __LINE__, __PRETTY_FUNCTION__))
20-
#endif
21-
}];
22-
}
23-
24-
def StaticAssertMacro : MacroDef<"static_assert"> {
25-
let Defn = [{
26-
#ifndef __cplusplus
27-
#undef static_assert
28-
#define static_assert _Static_assert
29-
#endif
30-
}];
31-
}
32-
33-
def AssertAPI : PublicAPI<"assert.h"> {
34-
let Macros = [
35-
AssertMacro,
36-
StaticAssertMacro,
37-
];
38-
}
3910

4011
def StringAPI : PublicAPI<"string.h"> {
4112
let Types = ["size_t"];

libc/config/linux/api.td

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -9,42 +9,6 @@ include "spec/stdc_ext.td"
99
include "spec/llvm_libc_ext.td"
1010
include "spec/llvm_libc_stdfix_ext.td"
1111

12-
def AssertMacro : MacroDef<"assert"> {
13-
let Defn = [{
14-
#undef assert
15-
16-
#ifdef NDEBUG
17-
#define assert(e) (void)0
18-
#else
19-
20-
#ifdef __cplusplus
21-
extern "C"
22-
#endif
23-
_Noreturn void __assert_fail(const char *, const char *, unsigned, const char *) __NOEXCEPT;
24-
25-
#define assert(e) \
26-
((e) ? (void)0 : __assert_fail(#e, __FILE__, __LINE__, __PRETTY_FUNCTION__))
27-
28-
#endif
29-
}];
30-
}
31-
32-
def StaticAssertMacro : MacroDef<"static_assert"> {
33-
let Defn = [{
34-
#ifndef __cplusplus
35-
#undef static_assert
36-
#define static_assert _Static_assert
37-
#endif
38-
}];
39-
}
40-
41-
def AssertAPI : PublicAPI<"assert.h"> {
42-
let Macros = [
43-
AssertMacro,
44-
StaticAssertMacro,
45-
];
46-
}
47-
4812
def CTypeAPI : PublicAPI<"ctype.h"> {
4913
}
5014

libc/include/assert.h.def

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,24 @@
1212
// This file may be usefully included multiple times to change assert()'s
1313
// definition based on NDEBUG.
1414

15+
16+
#undef assert
17+
#ifdef NDEBUG
18+
#define assert(e) (void)0
19+
#else
20+
21+
#ifndef __cplusplus
22+
#undef static_assert
23+
#define static_assert _Static_assert
24+
#endif
25+
26+
#ifdef __cplusplus
27+
extern "C"
28+
#endif
29+
_Noreturn void __assert_fail(const char *, const char *, unsigned, const char *) __NOEXCEPT;
30+
31+
#define assert(e) \
32+
((e) ? (void)0 : __assert_fail(#e, __FILE__, __LINE__, __PRETTY_FUNCTION__))
33+
#endif
34+
1535
%%public_api()

libc/newhdrgen/yaml/assert.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
header: assert.h
2+
macros: []
3+
types: []
4+
enums: []
5+
objects: []
6+
functions:
7+
- name: __assert_fail
8+
standards:
9+
- llvm_libc_ext
10+
return_type: _Noreturn void
11+
arguments:
12+
- type: const char *
13+
- type: const char *
14+
- type: unsigned
15+
- type: const char *
16+
guard: __cplusplus

0 commit comments

Comments
 (0)