[libc-commits] [libc] 740db97 - [libc][NFC] Simplify how the definiton of NULL macro is added to string.h.
Siva Chandra Reddy via libc-commits
libc-commits at lists.llvm.org
Tue Dec 20 11:14:35 PST 2022
Author: Siva Chandra Reddy
Date: 2022-12-20T19:14:27Z
New Revision: 740db97ad1613eb337ab64b482a46d34cb7846bd
URL: https://github.com/llvm/llvm-project/commit/740db97ad1613eb337ab64b482a46d34cb7846bd
DIFF: https://github.com/llvm/llvm-project/commit/740db97ad1613eb337ab64b482a46d34cb7846bd.diff
LOG: [libc][NFC] Simplify how the definiton of NULL macro is added to string.h.
We do not list macro definitions in api.td files anymore. Not all macros
definitions have been moved out. This change moves the definition of the
NULL macro out.
Reviewed By: lntue, jhuber6
Differential Revision: https://reviews.llvm.org/D140376
Added:
libc/include/llvm-libc-macros/null-macro.h
Modified:
libc/config/gpu/api.td
libc/config/linux/api.td
libc/include/CMakeLists.txt
libc/include/llvm-libc-macros/CMakeLists.txt
libc/include/string.h.def
Removed:
################################################################################
diff --git a/libc/config/gpu/api.td b/libc/config/gpu/api.td
index 2acae4a4e81b0..9036bbc89238e 100644
--- a/libc/config/gpu/api.td
+++ b/libc/config/gpu/api.td
@@ -2,17 +2,6 @@ include "config/public_api.td"
include "spec/stdc.td"
-def NullMacro : MacroDef<"NULL"> {
- let Defn = [{
- #define __need_NULL
- #include <stddef.h>
- }];
-}
-
def StringAPI : PublicAPI<"string.h"> {
let Types = ["size_t"];
-
- let Macros = [
- NullMacro,
- ];
}
diff --git a/libc/config/linux/api.td b/libc/config/linux/api.td
index 3afb92586f729..95542ef129bcb 100644
--- a/libc/config/linux/api.td
+++ b/libc/config/linux/api.td
@@ -36,13 +36,6 @@ def StaticAssertMacro : MacroDef<"static_assert"> {
}];
}
-def NullMacro : MacroDef<"NULL"> {
- let Defn = [{
- #define __need_NULL
- #include <stddef.h>
- }];
-}
-
def AssertAPI : PublicAPI<"assert.h"> {
let Macros = [
AssertMacro,
@@ -134,10 +127,6 @@ def FenvAPI: PublicAPI<"fenv.h"> {
def StringAPI : PublicAPI<"string.h"> {
let Types = ["size_t"];
-
- let Macros = [
- NullMacro,
- ];
}
def StdIOAPI : PublicAPI<"stdio.h"> {
diff --git a/libc/include/CMakeLists.txt b/libc/include/CMakeLists.txt
index 91ef75739178c..6fa2593f69769 100644
--- a/libc/include/CMakeLists.txt
+++ b/libc/include/CMakeLists.txt
@@ -91,6 +91,7 @@ add_gen_header(
GEN_HDR string.h
DEPENDS
.llvm_libc_common_h
+ .llvm-libc-macros.null_macro
.llvm-libc-types.size_t
)
diff --git a/libc/include/llvm-libc-macros/CMakeLists.txt b/libc/include/llvm-libc-macros/CMakeLists.txt
index 1cab22a8930ed..0f86d8d1df273 100644
--- a/libc/include/llvm-libc-macros/CMakeLists.txt
+++ b/libc/include/llvm-libc-macros/CMakeLists.txt
@@ -6,6 +6,12 @@ add_header(
generic-error-number-macros.h
)
+add_header(
+ null_macro
+ HDR
+ null-macro.h
+)
+
add_header(
fcntl_macros
HDR
diff --git a/libc/include/llvm-libc-macros/null-macro.h b/libc/include/llvm-libc-macros/null-macro.h
new file mode 100644
index 0000000000000..b83fc05c614df
--- /dev/null
+++ b/libc/include/llvm-libc-macros/null-macro.h
@@ -0,0 +1,15 @@
+//===-- Definition of the NULL macro --------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef __LLVM_LIBC_MACROS_NULL_MACRO_H
+#define __LLVM_LIBC_MACROS_NULL_MACRO_H
+
+#define __need_NULL
+#include <stddef.h>
+
+#endif // __LLVM_LIBC_MACROS_NULL_MACRO_H
diff --git a/libc/include/string.h.def b/libc/include/string.h.def
index 001c42915812f..26e6ef93d314d 100644
--- a/libc/include/string.h.def
+++ b/libc/include/string.h.def
@@ -11,6 +11,8 @@
#include <__llvm-libc-common.h>
+#include <llvm-libc-macros/null-macro.h>
+
%%public_api()
#endif // LLVM_LIBC_STRING_H
More information about the libc-commits
mailing list