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

Conversation

ldionne
Copy link
Member

@ldionne ldionne commented Oct 11, 2023

It doesn't seem to do anything useful beyond what the C library header is doing, so there's no purpose in having one.

@ldionne ldionne requested a review from a team as a code owner October 11, 2023 14:36
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Oct 11, 2023
@llvmbot
Copy link
Member

llvmbot commented Oct 11, 2023

@llvm/pr-subscribers-libcxx

Author: Louis Dionne (ldionne)

Changes

It doesn't seem to do anything useful beyond what the C library header is doing, so there's no purpose in having one.


Full diff: https://github.com/llvm/llvm-project/pull/68806.diff

7 Files Affected:

  • (modified) libcxx/include/CMakeLists.txt (-1)
  • (modified) libcxx/include/__std_clang_module (-1)
  • (modified) libcxx/include/csetjmp (-8)
  • (modified) libcxx/include/module.modulemap.in (+1-4)
  • (removed) libcxx/include/setjmp.h (-46)
  • (modified) libcxx/test/std/depr/depr.c.headers/setjmp_h.compile.pass.cpp (+3)
  • (modified) libcxx/utils/data/ignore_format.txt (-1)
diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt
index 4d98b8eed1afd65..9b03430a87d8338 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 2644ea98b4907f7..e2e9e85ffc7d8d6 100644
--- a/libcxx/include/__std_clang_module
+++ b/libcxx/include/__std_clang_module
@@ -169,7 +169,6 @@
 #  include <semaphore>
 #endif
 #include <set>
-#include <setjmp.h>
 #if !defined(_LIBCPP_HAS_NO_THREADS)
 #  include <shared_mutex>
 #endif
diff --git a/libcxx/include/csetjmp b/libcxx/include/csetjmp
index 4c64e8327e3f0ce..d219c8e6cb22506 100644
--- a/libcxx/include/csetjmp
+++ b/libcxx/include/csetjmp
@@ -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
diff --git a/libcxx/include/module.modulemap.in b/libcxx/include/module.modulemap.in
index 09184af2732c83f..3e5a8a391b6e69c 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 *
-}
+// <setjmp.h> provided by C library.
 // <signal.h> provided by C library.
 // FIXME: <stdalign.h> is missing.
 // <stdarg.h> provided by compiler.
diff --git a/libcxx/include/setjmp.h b/libcxx/include/setjmp.h
deleted file mode 100644
index f4a2bbcb0bd392c..000000000000000
--- 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(<setjmp.h>)
-#  include_next <setjmp.h>
-#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 7a49a85510202bf..5b7f9a623cc366b 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,6 +7,9 @@
 //===----------------------------------------------------------------------===//
 
 // 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>
 
diff --git a/libcxx/utils/data/ignore_format.txt b/libcxx/utils/data/ignore_format.txt
index 01038c75f4e1336..7d0244142ed2e6f 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

@ldionne ldionne force-pushed the review/remove-setjmp-header branch from 2fc3f4e to 749c4f4 Compare October 12, 2023 05:12
It doesn't seem to do anything useful beyond what the C library header
is doing, so there's no purpose in having one. As a drive-by, rewrite
the tests of setjmp to be more useful and avoid assuming that setjmp
is a macro.
@ldionne ldionne force-pushed the review/remove-setjmp-header branch from 749c4f4 to e1844f9 Compare October 12, 2023 15:49
@ldionne ldionne merged commit 2cea1ba into llvm:main Oct 12, 2023
@ldionne ldionne deleted the review/remove-setjmp-header branch October 12, 2023 23:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants