This makes the library consistent in how it handles C library headers. For C headers provided by libc++,
we unconditionally include <foo.h> from <cfoo>, and then <foo.h> conditionally include_next <foo.h>.
For headers not provided by libc++, <cfoo> conditionally includes the system's <foo.h> directly.
Differential Revision: https://reviews.llvm.org/D138512
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
-#include <assert.h>
+
+// <assert.h> is not provided by libc++
+#if __has_include(<assert.h>)
+# include <assert.h>
+# ifdef _LIBCPP_ASSERT_H
+# error "If libc++ starts defining <assert.h>, the __has_include check should move to libc++'s <assert.h>"
+# endif
+#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
+// <signal.h> is not provided by libc++
#if __has_include(<signal.h>)
-# include <signal.h>
+# include <signal.h>
+# ifdef _LIBCPP_SIGNAL_H
+# error "If libc++ starts defining <signal.h>, the __has_include check should move to libc++'s <signal.h>"
+# endif
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
-#include <stdarg.h>
+
+// <stdarg.h> is not provided by libc++
+#if __has_include(<stdarg.h>)
+# include <stdarg.h>
+# ifdef _LIBCPP_STDARG_H
+# error "If libc++ starts defining <stdarg.h>, the __has_include check should move to libc++'s <stdarg.h>"
+# endif
+#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
-#include <time.h>
+
+// <time.h> is not provided by libc++
+#if __has_include(<time.h>)
+# include <time.h>
+# ifdef _LIBCPP_TIME_H
+# error "If libc++ starts defining <time.h>, the __has_include check should move to libc++'s <time.h>"
+# endif
+#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header