Skip to content

Commit 90ca27d

Browse files
committed
[libc] Add NULL macro definitions to header files
By the C standard, <locale.h>, <stddef.h> <stdio.h>, <stdlib.h>, <string.h>, <time.h>, and <wchar.h> require NULL to be defined.
1 parent 4b2cb11 commit 90ca27d

File tree

8 files changed

+22
-6
lines changed

8 files changed

+22
-6
lines changed

libc/include/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ add_header_macro(
255255
time.h
256256
DEPENDS
257257
.llvm_libc_common_h
258+
.llvm-libc-macros.null_macro
258259
.llvm-libc-macros.time_macros
259260
.llvm-libc-types.clock_t
260261
.llvm-libc-types.time_t
@@ -329,6 +330,7 @@ add_header_macro(
329330
stdio.h
330331
DEPENDS
331332
.llvm-libc-macros.file_seek_macros
333+
.llvm-libc-macros.null_macro
332334
.llvm-libc-macros.stdio_macros
333335
.llvm-libc-types.FILE
334336
.llvm-libc-types.cookie_io_functions_t
@@ -343,6 +345,7 @@ add_header_macro(
343345
../libc/include/stdlib.yaml
344346
stdlib.h
345347
DEPENDS
348+
.llvm-libc-macros.null_macro
346349
.llvm-libc-macros.stdlib_macros
347350
.llvm-libc-types.__atexithandler_t
348351
.llvm-libc-types.__qsortcompare_t
@@ -709,6 +712,7 @@ add_header_macro(
709712
wchar.h
710713
DEPENDS
711714
.llvm_libc_common_h
715+
.llvm-libc-macros.null_macro
712716
.llvm-libc-macros.wchar_macros
713717
.llvm-libc-types.mbstate_t
714718
.llvm-libc-types.size_t
@@ -723,6 +727,7 @@ add_header_macro(
723727
DEPENDS
724728
.llvm_libc_common_h
725729
.llvm-libc-macros.locale_macros
730+
.llvm-libc-macros.null_macro
726731
.llvm-libc-types.locale_t
727732
.llvm-libc-types.struct_lconv
728733
)

libc/include/locale.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
header: locale.h
22
header_template: locale.h.def
3+
macros:
4+
- macro_name: NULL
5+
macro_header: null-macro.h
36
types:
47
- type_name: locale_t
58
- type_name: struct_lconv

libc/include/stdio.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
header: stdio.h
22
header_template: stdio.h.def
33
macros:
4+
- macro_name: NULL
5+
macro_header: null-macro.h
46
- macro_name: stdout
57
macro_value: stdout
68
- macro_name: stdin

libc/include/stdlib.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ standards:
44
- stdc
55
merge_yaml_files:
66
- stdlib-malloc.yaml
7-
macros: []
7+
macros:
8+
- macro_name: NULL
9+
macro_header: null-macro.h
810
types:
911
- type_name: __atexithandler_t
1012
- type_name: __qsortcompare_t

libc/include/string.h.def

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
#include "__llvm-libc-common.h"
1313

14-
#include "llvm-libc-macros/null-macro.h"
15-
1614
%%public_api()
1715

1816
#endif // LLVM_LIBC_STRING_H

libc/include/string.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
header: string.h
22
header_template: string.h.def
3-
macros: []
3+
macros:
4+
- macro_name: NULL
5+
macro_header: null-macro.h
46
types:
57
- type_name: locale_t
68
- type_name: size_t

libc/include/time.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
header: time.h
22
header_template: time.h.def
3-
macros: []
3+
macros:
4+
- macro_name: NULL
5+
macro_header: null-macro.h
46
types:
57
- type_name: struct_timeval
68
- type_name: clockid_t

libc/include/wchar.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
header: wchar.h
22
header_template: wchar.h.def
3-
macros: []
3+
macros:
4+
- macro_name: NULL
5+
macro_header: null-macro.h
46
types:
57
- type_name: size_t
68
- type_name: wint_t

0 commit comments

Comments
 (0)