Skip to content

Commit 740db97

Browse files
author
Siva Chandra Reddy
committed
[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
1 parent c2a5f15 commit 740db97

File tree

6 files changed

+24
-22
lines changed

6 files changed

+24
-22
lines changed

libc/config/gpu/api.td

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,6 @@ include "config/public_api.td"
22

33
include "spec/stdc.td"
44

5-
def NullMacro : MacroDef<"NULL"> {
6-
let Defn = [{
7-
#define __need_NULL
8-
#include <stddef.h>
9-
}];
10-
}
11-
125
def StringAPI : PublicAPI<"string.h"> {
136
let Types = ["size_t"];
14-
15-
let Macros = [
16-
NullMacro,
17-
];
187
}

libc/config/linux/api.td

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,6 @@ def StaticAssertMacro : MacroDef<"static_assert"> {
3636
}];
3737
}
3838

39-
def NullMacro : MacroDef<"NULL"> {
40-
let Defn = [{
41-
#define __need_NULL
42-
#include <stddef.h>
43-
}];
44-
}
45-
4639
def AssertAPI : PublicAPI<"assert.h"> {
4740
let Macros = [
4841
AssertMacro,
@@ -134,10 +127,6 @@ def FenvAPI: PublicAPI<"fenv.h"> {
134127

135128
def StringAPI : PublicAPI<"string.h"> {
136129
let Types = ["size_t"];
137-
138-
let Macros = [
139-
NullMacro,
140-
];
141130
}
142131

143132
def StdIOAPI : PublicAPI<"stdio.h"> {

libc/include/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ add_gen_header(
9191
GEN_HDR string.h
9292
DEPENDS
9393
.llvm_libc_common_h
94+
.llvm-libc-macros.null_macro
9495
.llvm-libc-types.size_t
9596
)
9697

libc/include/llvm-libc-macros/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ add_header(
66
generic-error-number-macros.h
77
)
88

9+
add_header(
10+
null_macro
11+
HDR
12+
null-macro.h
13+
)
14+
915
add_header(
1016
fcntl_macros
1117
HDR
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//===-- Definition of the NULL macro --------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef __LLVM_LIBC_MACROS_NULL_MACRO_H
10+
#define __LLVM_LIBC_MACROS_NULL_MACRO_H
11+
12+
#define __need_NULL
13+
#include <stddef.h>
14+
15+
#endif // __LLVM_LIBC_MACROS_NULL_MACRO_H

libc/include/string.h.def

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

1212
#include <__llvm-libc-common.h>
1313

14+
#include <llvm-libc-macros/null-macro.h>
15+
1416
%%public_api()
1517

1618
#endif // LLVM_LIBC_STRING_H

0 commit comments

Comments
 (0)