Skip to content

Commit 2cea1ba

Browse files
authored
[libc++] Remove libc++'s own <setjmp.h> header (#68806)
It doesn't seem to do anything useful beyond what the C library header is doing, so there's no purpose in having one.
1 parent cd0d478 commit 2cea1ba

File tree

8 files changed

+25
-78
lines changed

8 files changed

+25
-78
lines changed

libcxx/include/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,6 @@ set(files
977977
scoped_allocator
978978
semaphore
979979
set
980-
setjmp.h
981980
shared_mutex
982981
source_location
983982
span

libcxx/include/__std_clang_module

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@
169169
# include <semaphore>
170170
#endif
171171
#include <set>
172-
#include <setjmp.h>
173172
#if !defined(_LIBCPP_HAS_NO_THREADS)
174173
# include <shared_mutex>
175174
#endif

libcxx/include/csetjmp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,6 @@ void longjmp(jmp_buf env, int val);
3535

3636
#include <setjmp.h>
3737

38-
#ifndef _LIBCPP_SETJMP_H
39-
# error <csetjmp> tried including <setjmp.h> but didn't find libc++'s <setjmp.h> header. \
40-
This usually means that your header search paths are not configured properly. \
41-
The header search paths should contain the C++ Standard Library headers before \
42-
any C Standard Library, and you are probably using compiler flags that make that \
43-
not be the case.
44-
#endif
45-
4638
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
4739
# pragma GCC system_header
4840
#endif

libcxx/include/module.modulemap.in

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -456,10 +456,7 @@ module std_math_h [system] {
456456
header "math.h"
457457
export *
458458
}
459-
module std_setjmp_h [system] {
460-
header "setjmp.h"
461-
export *
462-
}
459+
// <setjmp.h> provided by C library.
463460
// <signal.h> provided by C library.
464461
// FIXME: <stdalign.h> is missing.
465462
// <stdarg.h> provided by compiler.

libcxx/include/setjmp.h

Lines changed: 0 additions & 46 deletions
This file was deleted.

libcxx/test/std/depr/depr.c.headers/setjmp_h.compile.pass.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
//===----------------------------------------------------------------------===//
88

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

1114
#include <setjmp.h>
1215

1316
#include "test_macros.h"
1417

15-
#ifndef setjmp
16-
#error setjmp not defined
17-
#endif
18-
1918
jmp_buf jb;
2019
ASSERT_SAME_TYPE(void, decltype(longjmp(jb, 0)));
20+
21+
void f() { setjmp(jb); }

libcxx/test/std/language.support/support.runtime/csetjmp.pass.cpp

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,28 @@
99
// test <csetjmp>
1010

1111
#include <csetjmp>
12+
#include <cassert>
1213
#include <type_traits>
1314

14-
#include "test_macros.h"
15+
int main(int, char**) {
16+
std::jmp_buf jb;
1517

16-
#ifndef setjmp
17-
#error setjmp not defined
18-
#endif
18+
switch (setjmp(jb)) {
19+
// First time we set the buffer, the function should return 0
20+
case 0:
21+
break;
1922

20-
int main(int, char**)
21-
{
22-
std::jmp_buf jb;
23-
((void)jb); // Prevent unused warning
24-
static_assert((std::is_same<decltype(std::longjmp(jb, 0)), void>::value),
25-
"std::is_same<decltype(std::longjmp(jb, 0)), void>::value");
23+
// If it returned 42, then we're coming from the std::longjmp call below
24+
case 42:
25+
return 0;
2626

27-
return 0;
27+
// Otherwise, something is wrong
28+
default:
29+
return 1;
30+
}
31+
32+
std::longjmp(jb, 42);
33+
static_assert(std::is_same<decltype(std::longjmp(jb, 0)), void>::value, "");
34+
35+
return 1;
2836
}

libcxx/utils/data/ignore_format.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,6 @@ libcxx/include/regex
418418
libcxx/include/scoped_allocator
419419
libcxx/include/semaphore
420420
libcxx/include/set
421-
libcxx/include/setjmp.h
422421
libcxx/include/span
423422
libcxx/include/__split_buffer
424423
libcxx/include/sstream
@@ -2725,7 +2724,6 @@ libcxx/test/std/depr/depr.c.headers/inttypes_h.compile.pass.cpp
27252724
libcxx/test/std/depr/depr.c.headers/limits_h.compile.pass.cpp
27262725
libcxx/test/std/depr/depr.c.headers/locale_h.compile.pass.cpp
27272726
libcxx/test/std/depr/depr.c.headers/math_h.pass.cpp
2728-
libcxx/test/std/depr/depr.c.headers/setjmp_h.compile.pass.cpp
27292727
libcxx/test/std/depr/depr.c.headers/signal_h.compile.pass.cpp
27302728
libcxx/test/std/depr/depr.c.headers/stdarg_h.compile.pass.cpp
27312729
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
39413939
libcxx/test/std/language.support/support.rtti/type.info/type_info.equal.pass.cpp
39423940
libcxx/test/std/language.support/support.rtti/type.info/type_info_hash.pass.cpp
39433941
libcxx/test/std/language.support/support.rtti/type.info/type_info.pass.cpp
3944-
libcxx/test/std/language.support/support.runtime/csetjmp.pass.cpp
39453942
libcxx/test/std/language.support/support.runtime/csignal.pass.cpp
39463943
libcxx/test/std/language.support/support.runtime/cstdarg.pass.cpp
39473944
libcxx/test/std/language.support/support.runtime/cstdbool.pass.cpp

0 commit comments

Comments
 (0)