[libcxx-commits] [PATCH] D138512: [libc++] Add missing __has_include checks for C headers not provided by libc++
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Nov 22 13:34:08 PST 2022
ldionne updated this revision to Diff 477285.
ldionne added a comment.
Address comment.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D138512/new/
https://reviews.llvm.org/D138512
Files:
libcxx/include/cassert
libcxx/include/csignal
libcxx/include/cstdarg
libcxx/include/ctime
Index: libcxx/include/ctime
===================================================================
--- libcxx/include/ctime
+++ libcxx/include/ctime
@@ -47,7 +47,14 @@
#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
Index: libcxx/include/cstdarg
===================================================================
--- libcxx/include/cstdarg
+++ libcxx/include/cstdarg
@@ -33,7 +33,14 @@
#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
Index: libcxx/include/csignal
===================================================================
--- libcxx/include/csignal
+++ libcxx/include/csignal
@@ -42,8 +42,12 @@
#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)
Index: libcxx/include/cassert
===================================================================
--- libcxx/include/cassert
+++ libcxx/include/cassert
@@ -18,7 +18,14 @@
#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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D138512.477285.patch
Type: text/x-patch
Size: 2458 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20221122/90ee55aa/attachment-0001.bin>
More information about the libcxx-commits
mailing list