Skip to content

[libc++] Remove libc++'s own <setjmp.h> header #68806

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion libcxx/include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,6 @@ set(files
scoped_allocator
semaphore
set
setjmp.h
shared_mutex
source_location
span
Expand Down
1 change: 0 additions & 1 deletion libcxx/include/__std_clang_module
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@
# include <semaphore>
#endif
#include <set>
#include <setjmp.h>
#if !defined(_LIBCPP_HAS_NO_THREADS)
# include <shared_mutex>
#endif
Expand Down
8 changes: 0 additions & 8 deletions libcxx/include/csetjmp
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,6 @@ void longjmp(jmp_buf env, int val);

#include <setjmp.h>

#ifndef _LIBCPP_SETJMP_H
# error <csetjmp> tried including <setjmp.h> but didn't find libc++'s <setjmp.h> 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
Expand Down
5 changes: 1 addition & 4 deletions libcxx/include/module.modulemap.in
Original file line number Diff line number Diff line change
Expand Up @@ -456,10 +456,7 @@ module std_math_h [system] {
header "math.h"
export *
}
module std_setjmp_h [system] {
header "setjmp.h"
export *
}
// <setjmp.h> provided by C library.
// <signal.h> provided by C library.
// FIXME: <stdalign.h> is missing.
// <stdarg.h> provided by compiler.
Expand Down
46 changes: 0 additions & 46 deletions libcxx/include/setjmp.h

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
//===----------------------------------------------------------------------===//

// test <setjmp.h>
//
// Even though <setjmp.h> is not provided by libc++, we still test that
// using it with libc++ on the search path will work.

#include <setjmp.h>

#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); }
30 changes: 19 additions & 11 deletions libcxx/test/std/language.support/support.runtime/csetjmp.pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,28 @@
// test <csetjmp>

#include <csetjmp>
#include <cassert>
#include <type_traits>

#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<decltype(std::longjmp(jb, 0)), void>::value),
"std::is_same<decltype(std::longjmp(jb, 0)), void>::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<decltype(std::longjmp(jb, 0)), void>::value, "");

return 1;
}
3 changes: 0 additions & 3 deletions libcxx/utils/data/ignore_format.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down