diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt index 4d98b8eed1afd..9b03430a87d83 100644 --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -977,7 +977,6 @@ set(files scoped_allocator semaphore set - setjmp.h shared_mutex source_location span diff --git a/libcxx/include/__std_clang_module b/libcxx/include/__std_clang_module index 2644ea98b4907..e2e9e85ffc7d8 100644 --- a/libcxx/include/__std_clang_module +++ b/libcxx/include/__std_clang_module @@ -169,7 +169,6 @@ # include #endif #include -#include #if !defined(_LIBCPP_HAS_NO_THREADS) # include #endif diff --git a/libcxx/include/csetjmp b/libcxx/include/csetjmp index 4c64e8327e3f0..d219c8e6cb225 100644 --- a/libcxx/include/csetjmp +++ b/libcxx/include/csetjmp @@ -35,14 +35,6 @@ void longjmp(jmp_buf env, int val); #include -#ifndef _LIBCPP_SETJMP_H -# error tried including but didn't find libc++'s header. \ - This usually means that your header search paths are not configured properly. \ - The header search paths should contain the C++ Standard Library headers before \ - any C Standard Library, and you are probably using compiler flags that make that \ - not be the case. -#endif - #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header #endif diff --git a/libcxx/include/module.modulemap.in b/libcxx/include/module.modulemap.in index 09184af2732c8..3e5a8a391b6e6 100644 --- a/libcxx/include/module.modulemap.in +++ b/libcxx/include/module.modulemap.in @@ -456,10 +456,7 @@ module std_math_h [system] { header "math.h" export * } -module std_setjmp_h [system] { - header "setjmp.h" - export * -} +// provided by C library. // provided by C library. // FIXME: is missing. // provided by compiler. diff --git a/libcxx/include/setjmp.h b/libcxx/include/setjmp.h deleted file mode 100644 index f4a2bbcb0bd39..0000000000000 --- a/libcxx/include/setjmp.h +++ /dev/null @@ -1,46 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// 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 -// -//===----------------------------------------------------------------------===// - -#ifndef _LIBCPP_SETJMP_H -#define _LIBCPP_SETJMP_H - -/* - setjmp.h synopsis - -Macros: - - setjmp - -Types: - - jmp_buf - -void longjmp(jmp_buf env, int val); - -*/ - -#include <__config> - -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -# pragma GCC system_header -#endif - -#if __has_include_next() -# include_next -#endif - -#ifdef __cplusplus - -#ifndef setjmp -#define setjmp(env) setjmp(env) -#endif - -#endif // __cplusplus - -#endif // _LIBCPP_SETJMP_H diff --git a/libcxx/test/std/depr/depr.c.headers/setjmp_h.compile.pass.cpp b/libcxx/test/std/depr/depr.c.headers/setjmp_h.compile.pass.cpp index 7a49a85510202..eaaeecbeb70ec 100644 --- a/libcxx/test/std/depr/depr.c.headers/setjmp_h.compile.pass.cpp +++ b/libcxx/test/std/depr/depr.c.headers/setjmp_h.compile.pass.cpp @@ -7,14 +7,15 @@ //===----------------------------------------------------------------------===// // test +// +// Even though is not provided by libc++, we still test that +// using it with libc++ on the search path will work. #include #include "test_macros.h" -#ifndef setjmp -#error setjmp not defined -#endif - jmp_buf jb; ASSERT_SAME_TYPE(void, decltype(longjmp(jb, 0))); + +void f() { setjmp(jb); } diff --git a/libcxx/test/std/language.support/support.runtime/csetjmp.pass.cpp b/libcxx/test/std/language.support/support.runtime/csetjmp.pass.cpp index 0e3d8f69e99c2..d6d32c371b9e5 100644 --- a/libcxx/test/std/language.support/support.runtime/csetjmp.pass.cpp +++ b/libcxx/test/std/language.support/support.runtime/csetjmp.pass.cpp @@ -9,20 +9,28 @@ // test #include +#include #include -#include "test_macros.h" +int main(int, char**) { + std::jmp_buf jb; -#ifndef setjmp -#error setjmp not defined -#endif + switch (setjmp(jb)) { + // First time we set the buffer, the function should return 0 + case 0: + break; -int main(int, char**) -{ - std::jmp_buf jb; - ((void)jb); // Prevent unused warning - static_assert((std::is_same::value), - "std::is_same::value"); + // If it returned 42, then we're coming from the std::longjmp call below + case 42: + return 0; - return 0; + // Otherwise, something is wrong + default: + return 1; + } + + std::longjmp(jb, 42); + static_assert(std::is_same::value, ""); + + return 1; } diff --git a/libcxx/utils/data/ignore_format.txt b/libcxx/utils/data/ignore_format.txt index 01038c75f4e13..ad457ab15ee32 100644 --- a/libcxx/utils/data/ignore_format.txt +++ b/libcxx/utils/data/ignore_format.txt @@ -418,7 +418,6 @@ libcxx/include/regex libcxx/include/scoped_allocator libcxx/include/semaphore libcxx/include/set -libcxx/include/setjmp.h libcxx/include/span libcxx/include/__split_buffer libcxx/include/sstream @@ -2725,7 +2724,6 @@ libcxx/test/std/depr/depr.c.headers/inttypes_h.compile.pass.cpp libcxx/test/std/depr/depr.c.headers/limits_h.compile.pass.cpp libcxx/test/std/depr/depr.c.headers/locale_h.compile.pass.cpp libcxx/test/std/depr/depr.c.headers/math_h.pass.cpp -libcxx/test/std/depr/depr.c.headers/setjmp_h.compile.pass.cpp libcxx/test/std/depr/depr.c.headers/signal_h.compile.pass.cpp libcxx/test/std/depr/depr.c.headers/stdarg_h.compile.pass.cpp libcxx/test/std/depr/depr.c.headers/stdbool_h.compile.pass.cpp @@ -3941,7 +3939,6 @@ libcxx/test/std/language.support/support.rtti/bad.typeid/bad_typeid.pass.cpp libcxx/test/std/language.support/support.rtti/type.info/type_info.equal.pass.cpp libcxx/test/std/language.support/support.rtti/type.info/type_info_hash.pass.cpp libcxx/test/std/language.support/support.rtti/type.info/type_info.pass.cpp -libcxx/test/std/language.support/support.runtime/csetjmp.pass.cpp libcxx/test/std/language.support/support.runtime/csignal.pass.cpp libcxx/test/std/language.support/support.runtime/cstdarg.pass.cpp libcxx/test/std/language.support/support.runtime/cstdbool.pass.cpp