diff --git a/libcxx/include/ext/__hash b/libcxx/include/ext/__hash --- a/libcxx/include/ext/__hash +++ b/libcxx/include/ext/__hash @@ -14,6 +14,7 @@ #include <__config> #include +#include #include namespace __gnu_cxx { diff --git a/libcxx/include/module.modulemap.in b/libcxx/include/module.modulemap.in --- a/libcxx/include/module.modulemap.in +++ b/libcxx/include/module.modulemap.in @@ -64,8 +64,7 @@ textual header "stdbool.h" } module stddef_h { - // 's __need_* macros require textual inclusion. - textual header "stddef.h" + header "stddef.h" } module stdint_h { header "stdint.h" @@ -75,14 +74,12 @@ export Darwin.C.stdint } module stdio_h { - // 's __need_* macros require textual inclusion. - textual header "stdio.h" + header "stdio.h" export * export Darwin.C.stdio } module stdlib_h { - // 's __need_* macros require textual inclusion. - textual header "stdlib.h" + header "stdlib.h" export * } module string_h { @@ -96,8 +93,7 @@ // provided by C library. module wchar_h { @requires_LIBCXX_ENABLE_WIDE_CHARACTERS@ - // 's __need_* macros require textual inclusion. - textual header "wchar.h" + header "wchar.h" export * } module wctype_h { diff --git a/libcxx/include/stdbool.h b/libcxx/include/stdbool.h --- a/libcxx/include/stdbool.h +++ b/libcxx/include/stdbool.h @@ -6,6 +6,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// + #ifndef _LIBCPP_STDBOOL_H #define _LIBCPP_STDBOOL_H diff --git a/libcxx/include/stddef.h b/libcxx/include/stddef.h --- a/libcxx/include/stddef.h +++ b/libcxx/include/stddef.h @@ -7,16 +7,7 @@ // //===----------------------------------------------------------------------===// -#if defined(__need_ptrdiff_t) || defined(__need_size_t) || \ - defined(__need_wchar_t) || defined(__need_NULL) || defined(__need_wint_t) - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -#include_next - -#elif !defined(_LIBCPP_STDDEF_H) +#ifndef _LIBCPP_STDDEF_H #define _LIBCPP_STDDEF_H /* @@ -42,6 +33,24 @@ # pragma GCC system_header #endif +// The Clang builtin headers only define the types we need when we request it explicitly. +// TODO: We should fix that in Clang and drop these defines. +#ifndef __need_ptrdiff_t +# define __need_ptrdiff_t +#endif +#ifndef __need_size_t +# define __need_size_t +#endif +#ifndef __need_wchar_t +# define __need_wchar_t +#endif +#ifndef __need_NULL +# define __need_NULL +#endif +#ifndef __need_STDDEF_H_misc +# define __need_STDDEF_H_misc +#endif + #include_next #ifdef __cplusplus diff --git a/libcxx/include/stdio.h b/libcxx/include/stdio.h --- a/libcxx/include/stdio.h +++ b/libcxx/include/stdio.h @@ -7,15 +7,7 @@ // //===----------------------------------------------------------------------===// -#if defined(__need_FILE) || defined(__need___FILE) - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -#include_next - -#elif !defined(_LIBCPP_STDIO_H) +#ifndef _LIBCPP_STDIO_H #define _LIBCPP_STDIO_H /* diff --git a/libcxx/include/stdlib.h b/libcxx/include/stdlib.h --- a/libcxx/include/stdlib.h +++ b/libcxx/include/stdlib.h @@ -7,15 +7,7 @@ // //===----------------------------------------------------------------------===// -#if defined(__need_malloc_and_calloc) - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -#include_next - -#elif !defined(_LIBCPP_STDLIB_H) +#ifndef _LIBCPP_STDLIB_H #define _LIBCPP_STDLIB_H /* diff --git a/libcxx/include/wchar.h b/libcxx/include/wchar.h --- a/libcxx/include/wchar.h +++ b/libcxx/include/wchar.h @@ -7,15 +7,7 @@ // //===----------------------------------------------------------------------===// -#if defined(__need_wint_t) || defined(__need_mbstate_t) - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -#include_next - -#elif !defined(_LIBCPP_WCHAR_H) +#ifndef _LIBCPP_WCHAR_H #define _LIBCPP_WCHAR_H /*