[libcxx-commits] [libcxx] [libc++] Remove obsolete header restrictions (PR #107437)

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Tue Sep 10 07:58:00 PDT 2024


https://github.com/ldionne updated https://github.com/llvm/llvm-project/pull/107437

>From c660cf0402c162d921cdd0446e54609b09b9a126 Mon Sep 17 00:00:00 2001
From: Louis Dionne <ldionne.2 at gmail.com>
Date: Tue, 10 Sep 2024 10:56:40 -0400
Subject: [PATCH] [libc++] Remove obsolete header restrictions for
 _LIBCPP_HAS_NO_THREADS

The _LIBCPP_HAS_NO_THREADS carve-out does not result in hard errors
anymore, but the patch that changed that forgot to update the header
restrictions we use to auto-generate several files.

We can also remove the restrictions for the no-localization build and
no-wide-characters, but doing it is less straightforward so I'm leaving
it out of this patch.
---
 libcxx/include/__std_clang_module         | 36 ++++++-----------------
 libcxx/modules/std.cppm.in                | 32 +++++---------------
 libcxx/utils/libcxx/header_information.py | 13 --------
 3 files changed, 17 insertions(+), 64 deletions(-)

diff --git a/libcxx/include/__std_clang_module b/libcxx/include/__std_clang_module
index 18d6ce6b46c1f6..c57f4a64af3148 100644
--- a/libcxx/include/__std_clang_module
+++ b/libcxx/include/__std_clang_module
@@ -30,12 +30,8 @@
 #include <algorithm>
 #include <any>
 #include <array>
-#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
-#  include <atomic>
-#endif
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-#  include <barrier>
-#endif
+#include <atomic>
+#include <barrier>
 #include <bit>
 #include <bitset>
 #include <cassert>
@@ -101,9 +97,7 @@
 #  include <fstream>
 #endif
 #include <functional>
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-#  include <future>
-#endif
+#include <future>
 #include <initializer_list>
 #include <inttypes.h>
 #if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
@@ -120,9 +114,7 @@
 #  include <istream>
 #endif
 #include <iterator>
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-#  include <latch>
-#endif
+#include <latch>
 #include <limits>
 #include <list>
 #if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
@@ -153,31 +145,23 @@
 #  include <regex>
 #endif
 #include <scoped_allocator>
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-#  include <semaphore>
-#endif
+#include <semaphore>
 #include <set>
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-#  include <shared_mutex>
-#endif
+#include <shared_mutex>
 #include <source_location>
 #include <span>
 #if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
 #  include <sstream>
 #endif
 #include <stack>
-#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
-#  include <stdatomic.h>
-#endif
+#include <stdatomic.h>
 #include <stdbool.h>
 #include <stddef.h>
 #include <stdexcept>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-#  include <stop_token>
-#endif
+#include <stop_token>
 #if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
 #  include <streambuf>
 #endif
@@ -192,9 +176,7 @@
 #endif
 #include <system_error>
 #include <tgmath.h>
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-#  include <thread>
-#endif
+#include <thread>
 #include <tuple>
 #include <type_traits>
 #include <typeindex>
diff --git a/libcxx/modules/std.cppm.in b/libcxx/modules/std.cppm.in
index ad8a639b7f71a1..7cc6f4008ce828 100644
--- a/libcxx/modules/std.cppm.in
+++ b/libcxx/modules/std.cppm.in
@@ -20,12 +20,8 @@ module;
 #include <algorithm>
 #include <any>
 #include <array>
-#if !defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)
-#  include <atomic>
-#endif
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-#  include <barrier>
-#endif
+#include <atomic>
+#include <barrier>
 #include <bit>
 #include <bitset>
 #include <cassert>
@@ -76,9 +72,7 @@ module;
 #  include <fstream>
 #endif
 #include <functional>
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-#  include <future>
-#endif
+#include <future>
 #include <initializer_list>
 #if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
 #  include <iomanip>
@@ -94,9 +88,7 @@ module;
 #  include <istream>
 #endif
 #include <iterator>
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-#  include <latch>
-#endif
+#include <latch>
 #include <limits>
 #include <list>
 #if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
@@ -123,13 +115,9 @@ module;
 #  include <regex>
 #endif
 #include <scoped_allocator>
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-#  include <semaphore>
-#endif
+#include <semaphore>
 #include <set>
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-#  include <shared_mutex>
-#endif
+#include <shared_mutex>
 #include <source_location>
 #include <span>
 #if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
@@ -137,9 +125,7 @@ module;
 #endif
 #include <stack>
 #include <stdexcept>
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-#  include <stop_token>
-#endif
+#include <stop_token>
 #if !defined(_LIBCPP_HAS_NO_LOCALIZATION)
 #  include <streambuf>
 #endif
@@ -152,9 +138,7 @@ module;
 #  include <syncstream>
 #endif
 #include <system_error>
-#if !defined(_LIBCPP_HAS_NO_THREADS)
-#  include <thread>
-#endif
+#include <thread>
 #include <tuple>
 #include <type_traits>
 #include <typeindex>
diff --git a/libcxx/utils/libcxx/header_information.py b/libcxx/utils/libcxx/header_information.py
index 166c9a77c08e70..6bc381bddf57e4 100644
--- a/libcxx/utils/libcxx/header_information.py
+++ b/libcxx/utils/libcxx/header_information.py
@@ -9,10 +9,6 @@
 import os, pathlib
 
 header_restrictions = {
-    # headers with #error directives
-    "atomic": "!defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)",
-    "stdatomic.h": "!defined(_LIBCPP_HAS_NO_ATOMIC_HEADER)",
-
     # headers with #error directives
     "ios": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
     "locale.h": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
@@ -31,15 +27,6 @@
     "strstream": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
     "syncstream": "!defined(_LIBCPP_HAS_NO_LOCALIZATION)",
 
-    # headers with #error directives
-    "barrier": "!defined(_LIBCPP_HAS_NO_THREADS)",
-    "future": "!defined(_LIBCPP_HAS_NO_THREADS)",
-    "latch": "!defined(_LIBCPP_HAS_NO_THREADS)",
-    "semaphore": "!defined(_LIBCPP_HAS_NO_THREADS)",
-    "shared_mutex": "!defined(_LIBCPP_HAS_NO_THREADS)",
-    "stop_token": "!defined(_LIBCPP_HAS_NO_THREADS)",
-    "thread": "!defined(_LIBCPP_HAS_NO_THREADS)",
-
     # headers with #error directives
     "wchar.h": "!defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)",
     "wctype.h": "!defined(_LIBCPP_HAS_NO_WIDE_CHARACTERS)",



More information about the libcxx-commits mailing list