Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions clang/lib/Headers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,26 @@ set(core_files
varargs.h
)

set(aix_wrapper_files
dbm.h
locale.h
stdio.h
stdlib.h
string.h
time.h
unistd.h
wchar.h
)
set(aix_sys_subdir_wrapper_files
sys/dir.h
sys/param.h
sys/types.h
)
set(aix_files
${aix_wrapper_files}
${aix_sys_subdir_wrapper_files}
)

set(arm_common_files
# Headers shared by Arm and AArch64
arm_acle.h
Expand Down Expand Up @@ -312,6 +332,7 @@ set(utility_files

set(files
${core_files}
${aix_files}
${arm_common_files}
${arm_only_files}
${aarch64_only_files}
Expand Down Expand Up @@ -529,6 +550,7 @@ set_target_properties("clang-resource-headers" PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${output_dir}")
add_dependencies("clang-resource-headers"
"core-resource-headers"
"aix-resource-headers"
"arm-common-resource-headers"
"arm-resource-headers"
"aarch64-resource-headers"
Expand Down Expand Up @@ -557,6 +579,7 @@ add_header_target("core-resource-headers" ${core_files})
add_header_target("arm-common-resource-headers" "${arm_common_files};${arm_common_generated_files}")

# Architecture/platform specific targets
add_header_target("aix-resource-headers" "${aix_files}")
add_header_target("arm-resource-headers" "${arm_only_files};${arm_only_generated_files}")
add_header_target("aarch64-resource-headers" "${aarch64_only_files};${aarch64_only_generated_files}")
add_header_target("cuda-resource-headers" "${cuda_files};${cuda_wrapper_files};${cuda_wrapper_bits_files};${cuda_wrapper_utility_files}")
Expand Down Expand Up @@ -644,6 +667,18 @@ install(
EXCLUDE_FROM_ALL
COMPONENT core-resource-headers)

install(
FILES ${aix_wrapper_files}
DESTINATION ${header_install_dir}
EXCLUDE_FROM_ALL
COMPONENT aix-resource-headers)

install(
FILES ${aix_sys_subdir_wrapper_files}
DESTINATION ${header_install_dir}/sys
EXCLUDE_FROM_ALL
COMPONENT aix-resource-headers)

install(
FILES ${arm_common_files} ${arm_common_generated_files}
DESTINATION ${header_install_dir}
Expand Down Expand Up @@ -837,6 +872,9 @@ if (NOT LLVM_ENABLE_IDE)
add_llvm_install_targets(install-core-resource-headers
DEPENDS core-resource-headers
COMPONENT core-resource-headers)
add_llvm_install_targets(install-aix-resource-headers
DEPENDS aix-resource-headers
COMPONENT aix-resource-headers)
add_llvm_install_targets(install-arm-common-resource-headers
DEPENDS arm-common-resource-headers
COMPONENT arm-common-resource-headers)
Expand Down
24 changes: 24 additions & 0 deletions clang/lib/Headers/dbm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*===---- dbm.h - BSD header for database management ----------------------===*\
*
* 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
*
\*===----------------------------------------------------------------------===*/

#if !defined(_AIX)

#include_next <dbm.h>

#else

#define __need_NULL
#include <stddef.h>

#include_next <dbm.h>

/* Ensure that the definition of NULL is as expected. */
#define __need_NULL
#include <stddef.h>
Comment on lines +15 to +22
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the pattern to define NULL, include_next the header the user asked for, and then define NULL again? Are the include_next headers defining NULL to something different? And if so, what are we potentially breaking by redefining it out from under them?


#endif
24 changes: 24 additions & 0 deletions clang/lib/Headers/locale.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*===---- locale.h - Standard header for localization ---------------------===*\
*
* 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
*
\*===----------------------------------------------------------------------===*/

#if !defined(_AIX)

#include_next <locale.h>

#else

#define __need_NULL
#include <stddef.h>

#include_next <locale.h>

/* Ensure that the definition of NULL is as expected. */
#define __need_NULL
#include <stddef.h>

#endif
24 changes: 24 additions & 0 deletions clang/lib/Headers/stdio.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*===---- stdio.h - Standard header for input and output-------------------===*\
*
* 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
*
\*===----------------------------------------------------------------------===*/

#if !defined(_AIX)

#include_next <stdio.h>

#else

#define __need_NULL
#include <stddef.h>

#include_next <stdio.h>

/* Ensure that the definition of NULL is as expected. */
#define __need_NULL
#include <stddef.h>

#endif
24 changes: 24 additions & 0 deletions clang/lib/Headers/stdlib.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*===---- stdlib.h - Standard header for general utilities ----------------===*\
*
* 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
*
\*===----------------------------------------------------------------------===*/

#if !defined(_AIX)

#include_next <stdlib.h>

#else

#define __need_NULL
#include <stddef.h>

#include_next <stdlib.h>

/* Ensure that the definition of NULL is as expected. */
#define __need_NULL
#include <stddef.h>

#endif
24 changes: 24 additions & 0 deletions clang/lib/Headers/string.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*===---- string.h - Standard header for string handling ------------------===*\
*
* 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
*
\*===----------------------------------------------------------------------===*/

#if !defined(_AIX)

#include_next <string.h>

#else

#define __need_NULL
#include <stddef.h>

#include_next <string.h>

/* Ensure that the definition of NULL is as expected. */
#define __need_NULL
#include <stddef.h>

#endif
24 changes: 24 additions & 0 deletions clang/lib/Headers/sys/dir.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*===---- sys/dir.h - BSD header for directory handling -------------------===*\
*
* 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
*
\*===----------------------------------------------------------------------===*/

#if !defined(_AIX)

#include_next <sys/dir.h>

#else

#define __need_NULL
#include <stddef.h>

#include_next <sys/dir.h>

/* Ensure that the definition of NULL is as expected. */
#define __need_NULL
#include <stddef.h>

#endif
24 changes: 24 additions & 0 deletions clang/lib/Headers/sys/param.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*===---- sys/param.h - BSD header ----------------------------------------===*\
*
* 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
*
\*===----------------------------------------------------------------------===*/

#if !defined(_AIX)

#include_next <sys/param.h>

#else

#define __need_NULL
#include <stddef.h>

#include_next <sys/param.h>

/* Ensure that the definition of NULL is as expected. */
#define __need_NULL
#include <stddef.h>

#endif
24 changes: 24 additions & 0 deletions clang/lib/Headers/sys/types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*===---- sys/types.h - BSD header for types ------------------------------===*\
*
* 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
*
\*===----------------------------------------------------------------------===*/

#if !defined(_AIX)

#include_next <sys/types.h>

#else

#define __need_NULL
#include <stddef.h>

#include_next <sys/types.h>

/* Ensure that the definition of NULL is as expected. */
#define __need_NULL
#include <stddef.h>

#endif
24 changes: 24 additions & 0 deletions clang/lib/Headers/time.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*===---- time.h - Standard header for date and time handling -------------===*\
*
* 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
*
\*===----------------------------------------------------------------------===*/

#if !defined(_AIX)

#include_next <time.h>

#else

#define __need_NULL
#include <stddef.h>

#include_next <time.h>

/* Ensure that the definition of NULL is as expected. */
#define __need_NULL
#include <stddef.h>

#endif
24 changes: 24 additions & 0 deletions clang/lib/Headers/unistd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*===---- unistd.h - Posix Standard header --------------------------------===*\
*
* 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
*
\*===----------------------------------------------------------------------===*/

#if !defined(_AIX)

#include_next <unistd.h>

#else

#define __need_NULL
#include <stddef.h>

#include_next <unistd.h>

/* Ensure that the definition of NULL is as expected. */
#define __need_NULL
#include <stddef.h>

#endif
24 changes: 24 additions & 0 deletions clang/lib/Headers/wchar.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*===---- wchar.h - Standard header for string handling ------------------===*\
*
* 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
*
\*===----------------------------------------------------------------------===*/

#if !defined(_AIX)

#include_next <wchar.h>

#else

#define __need_NULL
#include <stddef.h>

#include_next <wchar.h>

/* Ensure that the definition of NULL is as expected. */
#define __need_NULL
#include <stddef.h>

#endif
22 changes: 22 additions & 0 deletions clang/test/Headers/check-NULL-aix.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// There are at least 2 valid C null-pointer constants as defined
// by the C language standard.
// Test that the macro NULL is defined consistently by those system headers
// on AIX that have a macro definition for NULL.

// REQUIRES: system-aix

// RUN: %clang %s -Dheader="<dbm.h>" -E | tail -1 | FileCheck %s
// RUN: %clang %s -Dheader="<locale.h>" -E | tail -1 | FileCheck %s
// RUN: %clang %s -Dheader="<stdio.h>" -E | tail -1 | FileCheck %s
// RUN: %clang %s -Dheader="<stdlib.h>" -E | tail -1 | FileCheck %s
// RUN: %clang %s -Dheader="<string.h>" -E | tail -1 | FileCheck %s
// RUN: %clang %s -Dheader="<sys/dir.h>" -E | tail -1 | FileCheck %s
// RUN: %clang %s -Dheader="<sys/param.h>" -E | tail -1 | FileCheck %s
// RUN: %clang %s -Dheader="<sys/types.h>" -E | tail -1 | FileCheck %s
// RUN: %clang %s -Dheader="<time.h>" -E | tail -1 | FileCheck %s
// RUN: %clang %s -Dheader="<unistd.h>" -E | tail -1 | FileCheck %s
// RUN: %clang %s -Dheader="<wchar.h>" -E | tail -1 | FileCheck %s

#include header
void *p = NULL;
// CHECK: ({{ *}}({{ *}}void{{ *}}*{{ *}}){{ *}}0{{ *}})
Loading