[libc-commits] [libc] 117e78f - [libc] Add NULL macro definitions to header files (#142764)

via libc-commits libc-commits at lists.llvm.org
Wed Jun 11 09:51:38 PDT 2025


Author: William
Date: 2025-06-11T09:51:34-07:00
New Revision: 117e78fe5012087c1ee535b91936bf4d8e3c7785

URL: https://github.com/llvm/llvm-project/commit/117e78fe5012087c1ee535b91936bf4d8e3c7785
DIFF: https://github.com/llvm/llvm-project/commit/117e78fe5012087c1ee535b91936bf4d8e3c7785.diff

LOG: [libc] Add NULL macro definitions to header files (#142764)

By the C standard, <locale.h>, <stddef.h> <stdio.h>, <stdlib.h>,
<string.h>, <time.h>, and <wchar.h> require NULL to be defined.

Added: 
    

Modified: 
    libc/include/CMakeLists.txt
    libc/include/locale.yaml
    libc/include/stdio.yaml
    libc/include/stdlib.yaml
    libc/include/string.h.def
    libc/include/string.yaml
    libc/include/time.yaml
    libc/include/wchar.yaml

Removed: 
    


################################################################################
diff  --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt
index 7209e10c68b8f..55268d19529c7 100644
--- a/libc/include/CMakeLists.txt
+++ b/libc/include/CMakeLists.txt
@@ -255,6 +255,7 @@ add_header_macro(
   time.h
   DEPENDS
     .llvm_libc_common_h
+    .llvm-libc-macros.null_macro
     .llvm-libc-macros.time_macros
     .llvm-libc-types.clock_t
     .llvm-libc-types.time_t
@@ -329,6 +330,7 @@ add_header_macro(
   stdio.h
   DEPENDS
     .llvm-libc-macros.file_seek_macros
+    .llvm-libc-macros.null_macro
     .llvm-libc-macros.stdio_macros
     .llvm-libc-types.FILE
     .llvm-libc-types.cookie_io_functions_t
@@ -343,6 +345,7 @@ add_header_macro(
   ../libc/include/stdlib.yaml
   stdlib.h
   DEPENDS
+    .llvm-libc-macros.null_macro
     .llvm-libc-macros.stdlib_macros
     .llvm-libc-types.__atexithandler_t
     .llvm-libc-types.__qsortcompare_t
@@ -709,6 +712,7 @@ add_header_macro(
   wchar.h
   DEPENDS
     .llvm_libc_common_h
+    .llvm-libc-macros.null_macro
     .llvm-libc-macros.wchar_macros
     .llvm-libc-types.mbstate_t
     .llvm-libc-types.size_t
@@ -723,6 +727,7 @@ add_header_macro(
   DEPENDS
     .llvm_libc_common_h
     .llvm-libc-macros.locale_macros
+    .llvm-libc-macros.null_macro
     .llvm-libc-types.locale_t
     .llvm-libc-types.struct_lconv
 )

diff  --git a/libc/include/locale.yaml b/libc/include/locale.yaml
index 6c71b70e59f0b..4566984ad83af 100644
--- a/libc/include/locale.yaml
+++ b/libc/include/locale.yaml
@@ -1,5 +1,8 @@
 header: locale.h
 header_template: locale.h.def
+macros:
+  - macro_name: NULL
+    macro_header: null-macro.h
 types:
   - type_name: locale_t
   - type_name: struct_lconv

diff  --git a/libc/include/stdio.yaml b/libc/include/stdio.yaml
index 2619984cca264..3d5164fa10ffb 100644
--- a/libc/include/stdio.yaml
+++ b/libc/include/stdio.yaml
@@ -1,6 +1,8 @@
 header: stdio.h
 header_template: stdio.h.def
 macros:
+  - macro_name: NULL
+    macro_header: null-macro.h
   - macro_name: stdout
     macro_value: stdout
   - macro_name: stdin

diff  --git a/libc/include/stdlib.yaml b/libc/include/stdlib.yaml
index f7155ba27a162..3b2ff13c684b1 100644
--- a/libc/include/stdlib.yaml
+++ b/libc/include/stdlib.yaml
@@ -4,7 +4,9 @@ standards:
   - stdc
 merge_yaml_files:
   - stdlib-malloc.yaml
-macros: []
+macros:
+  - macro_name: NULL
+    macro_header: null-macro.h
 types:
   - type_name: __atexithandler_t
   - type_name: __qsortcompare_t

diff  --git a/libc/include/string.h.def b/libc/include/string.h.def
index 1bd2687db2bea..339d005e43a4f 100644
--- a/libc/include/string.h.def
+++ b/libc/include/string.h.def
@@ -11,8 +11,6 @@
 
 #include "__llvm-libc-common.h"
 
-#include "llvm-libc-macros/null-macro.h"
-
 %%public_api()
 
 #endif // LLVM_LIBC_STRING_H

diff  --git a/libc/include/string.yaml b/libc/include/string.yaml
index 9f72b8db6c1eb..736deceb453de 100644
--- a/libc/include/string.yaml
+++ b/libc/include/string.yaml
@@ -1,6 +1,8 @@
 header: string.h
 header_template: string.h.def
-macros: []
+macros:
+  - macro_name: NULL
+    macro_header: null-macro.h
 types:
   - type_name: locale_t
   - type_name: size_t

diff  --git a/libc/include/time.yaml b/libc/include/time.yaml
index 7bb25dbe85ac4..3b9d77c0aaae2 100644
--- a/libc/include/time.yaml
+++ b/libc/include/time.yaml
@@ -1,6 +1,8 @@
 header: time.h
 header_template: time.h.def
-macros: []
+macros:
+  - macro_name: NULL
+    macro_header: null-macro.h
 types:
   - type_name: struct_timeval
   - type_name: clockid_t

diff  --git a/libc/include/wchar.yaml b/libc/include/wchar.yaml
index 877be48b6a10f..57f4f6660827e 100644
--- a/libc/include/wchar.yaml
+++ b/libc/include/wchar.yaml
@@ -1,6 +1,8 @@
 header: wchar.h
 header_template: wchar.h.def
-macros: []
+macros:
+  - macro_name: NULL
+    macro_header: null-macro.h
 types:
   - type_name: size_t
   - type_name: wint_t


        


More information about the libc-commits mailing list