Skip to content

Commit 7f3dccd

Browse files
Ensure proper NULL macro definition for system include files.
The C standard allows for at least 2 valid definitions of a null pointer constant and mandates that several standard headers files define the macro NULL to be a null pointer constant. Ensure that definitions of NULL are consistent across the various C header files. respond to review: add in locale.h respond to review: make all changes AIX specific
1 parent 3a6ef8b commit 7f3dccd

File tree

13 files changed

+324
-0
lines changed

13 files changed

+324
-0
lines changed

clang/lib/Headers/CMakeLists.txt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,26 @@ set(core_files
3939
varargs.h
4040
)
4141

42+
set(aix_wrapper_files
43+
dbm.h
44+
locale.h
45+
stdio.h
46+
stdlib.h
47+
string.h
48+
time.h
49+
unistd.h
50+
wchar.h
51+
)
52+
set(aix_sys_subdir_wrapper_files
53+
sys/dir.h
54+
sys/param.h
55+
sys/types.h
56+
)
57+
set(aix_files
58+
${aix_wrapper_files}
59+
${aix_sys_subdir_wrapper_files}
60+
)
61+
4262
set(arm_common_files
4363
# Headers shared by Arm and AArch64
4464
arm_acle.h
@@ -312,6 +332,7 @@ set(utility_files
312332

313333
set(files
314334
${core_files}
335+
${aix_files}
315336
${arm_common_files}
316337
${arm_only_files}
317338
${aarch64_only_files}
@@ -529,6 +550,7 @@ set_target_properties("clang-resource-headers" PROPERTIES
529550
RUNTIME_OUTPUT_DIRECTORY "${output_dir}")
530551
add_dependencies("clang-resource-headers"
531552
"core-resource-headers"
553+
"aix-resource-headers"
532554
"arm-common-resource-headers"
533555
"arm-resource-headers"
534556
"aarch64-resource-headers"
@@ -557,6 +579,7 @@ add_header_target("core-resource-headers" ${core_files})
557579
add_header_target("arm-common-resource-headers" "${arm_common_files};${arm_common_generated_files}")
558580

559581
# Architecture/platform specific targets
582+
add_header_target("aix-resource-headers" "${aix_files}")
560583
add_header_target("arm-resource-headers" "${arm_only_files};${arm_only_generated_files}")
561584
add_header_target("aarch64-resource-headers" "${aarch64_only_files};${aarch64_only_generated_files}")
562585
add_header_target("cuda-resource-headers" "${cuda_files};${cuda_wrapper_files};${cuda_wrapper_bits_files};${cuda_wrapper_utility_files}")
@@ -644,6 +667,18 @@ install(
644667
EXCLUDE_FROM_ALL
645668
COMPONENT core-resource-headers)
646669

670+
install(
671+
FILES ${aix_wrapper_files}
672+
DESTINATION ${header_install_dir}
673+
EXCLUDE_FROM_ALL
674+
COMPONENT aix-resource-headers)
675+
676+
install(
677+
FILES ${aix_sys_subdir_wrapper_files}
678+
DESTINATION ${header_install_dir}/sys
679+
EXCLUDE_FROM_ALL
680+
COMPONENT aix-resource-headers)
681+
647682
install(
648683
FILES ${arm_common_files} ${arm_common_generated_files}
649684
DESTINATION ${header_install_dir}
@@ -837,6 +872,9 @@ if (NOT LLVM_ENABLE_IDE)
837872
add_llvm_install_targets(install-core-resource-headers
838873
DEPENDS core-resource-headers
839874
COMPONENT core-resource-headers)
875+
add_llvm_install_targets(install-aix-resource-headers
876+
DEPENDS aix-resource-headers
877+
COMPONENT aix-resource-headers)
840878
add_llvm_install_targets(install-arm-common-resource-headers
841879
DEPENDS arm-common-resource-headers
842880
COMPONENT arm-common-resource-headers)

clang/lib/Headers/dbm.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*===---- dbm.h - BSD header for database management ----------------------===*\
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+
#if !defined(_AIX)
10+
11+
#include_next <dbm.h>
12+
13+
#else
14+
15+
#define __need_NULL
16+
#include <stddef.h>
17+
18+
#include_next <dbm.h>
19+
20+
/* Ensure that the definition of NULL is as expected. */
21+
#define __need_NULL
22+
#include <stddef.h>
23+
24+
#endif

clang/lib/Headers/locale.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*===---- locale.h - Standard header for localization ---------------------===*\
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+
#if !defined(_AIX)
10+
11+
#include_next <locale.h>
12+
13+
#else
14+
15+
#define __need_NULL
16+
#include <stddef.h>
17+
18+
#include_next <locale.h>
19+
20+
/* Ensure that the definition of NULL is as expected. */
21+
#define __need_NULL
22+
#include <stddef.h>
23+
24+
#endif

clang/lib/Headers/stdio.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*===---- stdio.h - Standard header for input and output-------------------===*\
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+
#if !defined(_AIX)
10+
11+
#include_next <stdio.h>
12+
13+
#else
14+
15+
#define __need_NULL
16+
#include <stddef.h>
17+
18+
#include_next <stdio.h>
19+
20+
/* Ensure that the definition of NULL is as expected. */
21+
#define __need_NULL
22+
#include <stddef.h>
23+
24+
#endif

clang/lib/Headers/stdlib.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*===---- stdlib.h - Standard header for general utilities ----------------===*\
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+
#if !defined(_AIX)
10+
11+
#include_next <stdlib.h>
12+
13+
#else
14+
15+
#define __need_NULL
16+
#include <stddef.h>
17+
18+
#include_next <stdlib.h>
19+
20+
/* Ensure that the definition of NULL is as expected. */
21+
#define __need_NULL
22+
#include <stddef.h>
23+
24+
#endif

clang/lib/Headers/string.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*===---- string.h - Standard header for string handling ------------------===*\
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+
#if !defined(_AIX)
10+
11+
#include_next <string.h>
12+
13+
#else
14+
15+
#define __need_NULL
16+
#include <stddef.h>
17+
18+
#include_next <string.h>
19+
20+
/* Ensure that the definition of NULL is as expected. */
21+
#define __need_NULL
22+
#include <stddef.h>
23+
24+
#endif

clang/lib/Headers/sys/dir.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*===---- sys/dir.h - BSD header for directory handling -------------------===*\
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+
#if !defined(_AIX)
10+
11+
#include_next <sys/dir.h>
12+
13+
#else
14+
15+
#define __need_NULL
16+
#include <stddef.h>
17+
18+
#include_next <sys/dir.h>
19+
20+
/* Ensure that the definition of NULL is as expected. */
21+
#define __need_NULL
22+
#include <stddef.h>
23+
24+
#endif

clang/lib/Headers/sys/param.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*===---- sys/param.h - BSD header ----------------------------------------===*\
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+
#if !defined(_AIX)
10+
11+
#include_next <sys/param.h>
12+
13+
#else
14+
15+
#define __need_NULL
16+
#include <stddef.h>
17+
18+
#include_next <sys/param.h>
19+
20+
/* Ensure that the definition of NULL is as expected. */
21+
#define __need_NULL
22+
#include <stddef.h>
23+
24+
#endif

clang/lib/Headers/sys/types.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*===---- sys/types.h - BSD header for types ------------------------------===*\
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+
#if !defined(_AIX)
10+
11+
#include_next <sys/types.h>
12+
13+
#else
14+
15+
#define __need_NULL
16+
#include <stddef.h>
17+
18+
#include_next <sys/types.h>
19+
20+
/* Ensure that the definition of NULL is as expected. */
21+
#define __need_NULL
22+
#include <stddef.h>
23+
24+
#endif

clang/lib/Headers/time.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*===---- time.h - Standard header for date and time handling -------------===*\
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+
#if !defined(_AIX)
10+
11+
#include_next <time.h>
12+
13+
#else
14+
15+
#define __need_NULL
16+
#include <stddef.h>
17+
18+
#include_next <time.h>
19+
20+
/* Ensure that the definition of NULL is as expected. */
21+
#define __need_NULL
22+
#include <stddef.h>
23+
24+
#endif

0 commit comments

Comments
 (0)