[libcxx-commits] [libcxx] [libc++] Only include <setjmp.h> from the C library if it exists (PR #81887)
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Feb 15 09:50:05 PST 2024
https://github.com/ldionne created https://github.com/llvm/llvm-project/pull/81887
In 2cea1babefbb, we removed the <setjmp.h> header provided by libc++. However, we did not conditionally include the underlying <setjmp.h> header only if the C library provides one, which we otherwise do consistently (see e.g. 647ddc08f43c).
rdar://122978778
>From ca8e4b94833c002e3dc47d1dc1c1b0de40d0210e Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Thu, 15 Feb 2024 12:45:31 -0500
Subject: [PATCH] [libc++] Only include <setjmp.h> from the C library if it
exists
In 2cea1babefbb, we removed the <setjmp.h> header provided by libc++.
However, we did not conditionally include the underlying <setjmp.h>
header only if the C library provides one, which we otherwise do
consistently (see e.g. 647ddc08f43c).
rdar://122978778
---
libcxx/include/csetjmp | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/libcxx/include/csetjmp b/libcxx/include/csetjmp
index d219c8e6cb2250..9012cad22ebe74 100644
--- a/libcxx/include/csetjmp
+++ b/libcxx/include/csetjmp
@@ -33,7 +33,13 @@ void longjmp(jmp_buf env, int val);
#include <__assert> // all public C++ headers provide the assertion handler
#include <__config>
-#include <setjmp.h>
+// <setjmp.h> is not provided by libc++
+#if __has_include(<setjmp.h>)
+# include <setjmp.h>
+# ifdef _LIBCPP_SETJMP_H
+# error "If libc++ starts defining <setjmp.h>, the __has_include check should move to libc++'s <setjmp.h>"
+# endif
+#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
More information about the libcxx-commits
mailing list