Skip to content

Commit 04f01a2

Browse files
authored
[libc++] Make the __availability header a sub-header of __config (#93083)
In essence, this header has always been related to configuration of the library but we didn't want to put it inside <__config> due to complexity reasons. Now that we have sub-headers in <__config>, we can move <__availability> to it and stop including it everywhere since we already obtain the required macros via <__config>.
1 parent 6abc387 commit 04f01a2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+60
-94
lines changed

libcxx/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ option(LIBCXX_ENABLE_VENDOR_AVAILABILITY_ANNOTATIONS
122122
on definitions in a shared library. By default, we assume that we're not building
123123
libc++ for any specific vendor, and we disable those annotations. Vendors wishing
124124
to provide compile-time errors when using features unavailable on some version of
125-
the shared library they shipped should turn this on and see `include/__availability`
125+
the shared library they shipped should turn this on and see `include/__configuration/availability.h`
126126
for more details." OFF)
127127

128128
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")

libcxx/include/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ set(files
219219
__atomic/kill_dependency.h
220220
__atomic/memory_order.h
221221
__atomic/to_gcc_order.h
222-
__availability
223222
__bit/bit_cast.h
224223
__bit/bit_ceil.h
225224
__bit/bit_floor.h
@@ -315,7 +314,9 @@ set(files
315314
__condition_variable/condition_variable.h
316315
__config
317316
__configuration/abi.h
317+
__configuration/availability.h
318318
__configuration/compiler.h
319+
__configuration/language.h
319320
__configuration/platform.h
320321
__coroutine/coroutine_handle.h
321322
__coroutine/coroutine_traits.h

libcxx/include/__atomic/atomic_base.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include <__atomic/cxx_atomic_impl.h>
1515
#include <__atomic/is_always_lock_free.h>
1616
#include <__atomic/memory_order.h>
17-
#include <__availability>
1817
#include <__config>
1918
#include <__memory/addressof.h>
2019
#include <__type_traits/is_integral.h>

libcxx/include/__atomic/atomic_flag.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include <__atomic/contention_t.h>
1414
#include <__atomic/cxx_atomic_impl.h>
1515
#include <__atomic/memory_order.h>
16-
#include <__availability>
1716
#include <__chrono/duration.h>
1817
#include <__config>
1918
#include <__memory/addressof.h>

libcxx/include/__atomic/atomic_sync.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
#include <__atomic/cxx_atomic_impl.h>
1414
#include <__atomic/memory_order.h>
1515
#include <__atomic/to_gcc_order.h>
16-
#include <__availability>
1716
#include <__chrono/duration.h>
1817
#include <__config>
1918
#include <__memory/addressof.h>

libcxx/include/__charconv/to_chars_floating_point.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#ifndef _LIBCPP___CHARCONV_TO_CHARS_FLOATING_POINT_H
1111
#define _LIBCPP___CHARCONV_TO_CHARS_FLOATING_POINT_H
1212

13-
#include <__availability>
1413
#include <__charconv/chars_format.h>
1514
#include <__charconv/to_chars_result.h>
1615
#include <__config>

libcxx/include/__chrono/file_clock.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#ifndef _LIBCPP___CHRONO_FILE_CLOCK_H
1111
#define _LIBCPP___CHRONO_FILE_CLOCK_H
1212

13-
#include <__availability>
1413
#include <__chrono/duration.h>
1514
#include <__chrono/system_clock.h>
1615
#include <__chrono/time_point.h>

libcxx/include/__chrono/tzdb_list.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
// Enable the contents of the header only when libc++ was built with experimental features enabled.
1717
#if !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_TZDB)
1818

19-
# include <__availability>
2019
# include <__chrono/time_zone.h>
2120
# include <__chrono/tzdb.h>
2221
# include <__config>

libcxx/include/__config

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include <__config_site>
1414
#include <__configuration/abi.h>
15+
#include <__configuration/availability.h>
1516
#include <__configuration/compiler.h>
1617
#include <__configuration/platform.h>
1718

@@ -35,25 +36,6 @@
3536
# define _LIBCPP_FREESTANDING
3637
# endif
3738

38-
// NOLINTBEGIN(libcpp-cpp-version-check)
39-
# ifndef _LIBCPP_STD_VER
40-
# if __cplusplus <= 201103L
41-
# define _LIBCPP_STD_VER 11
42-
# elif __cplusplus <= 201402L
43-
# define _LIBCPP_STD_VER 14
44-
# elif __cplusplus <= 201703L
45-
# define _LIBCPP_STD_VER 17
46-
# elif __cplusplus <= 202002L
47-
# define _LIBCPP_STD_VER 20
48-
# elif __cplusplus <= 202302L
49-
# define _LIBCPP_STD_VER 23
50-
# else
51-
// Expected release year of the next C++ standard
52-
# define _LIBCPP_STD_VER 26
53-
# endif
54-
# endif // _LIBCPP_STD_VER
55-
// NOLINTEND(libcpp-cpp-version-check)
56-
5739
// HARDENING {
5840

5941
// TODO(hardening): deprecate this in LLVM 19.
@@ -364,10 +346,6 @@ typedef __char32_t char32_t;
364346

365347
# endif
366348

367-
# if !defined(__cpp_exceptions) || __cpp_exceptions < 199711L
368-
# define _LIBCPP_HAS_NO_EXCEPTIONS
369-
# endif
370-
371349
# define _LIBCPP_PREFERRED_ALIGNOF(_Tp) __alignof(_Tp)
372350

373351
# if defined(_LIBCPP_COMPILER_CLANG_BASED)
@@ -840,11 +818,6 @@ typedef __char32_t char32_t;
840818
# define _LIBCPP_CONSTEXPR_SINCE_CXX23
841819
# endif
842820

843-
// Try to find out if RTTI is disabled.
844-
# if !defined(__cpp_rtti) || __cpp_rtti < 199711L
845-
# define _LIBCPP_HAS_NO_RTTI
846-
# endif
847-
848821
# ifndef _LIBCPP_WEAK
849822
# define _LIBCPP_WEAK __attribute__((__weak__))
850823
# endif

libcxx/include/__availability renamed to libcxx/include/__configuration/availability.h

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

10-
#ifndef _LIBCPP___AVAILABILITY
11-
#define _LIBCPP___AVAILABILITY
10+
#ifndef _LIBCPP___CONFIGURATION_AVAILABILITY_H
11+
#define _LIBCPP___CONFIGURATION_AVAILABILITY_H
1212

13-
#include <__config>
13+
#include <__configuration/compiler.h>
14+
#include <__configuration/language.h>
1415

1516
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
1617
# pragma GCC system_header
@@ -374,4 +375,4 @@
374375
# define _LIBCPP_AVAILABILITY_INIT_PRIMARY_EXCEPTION
375376
#endif
376377

377-
#endif // _LIBCPP___AVAILABILITY
378+
#endif // _LIBCPP___CONFIGURATION_AVAILABILITY_H
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// -*- C++ -*-
2+
//===----------------------------------------------------------------------===//
3+
//
4+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5+
// See https://llvm.org/LICENSE.txt for license information.
6+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7+
//
8+
//===----------------------------------------------------------------------===//
9+
10+
#ifndef _LIBCPP___CONFIGURATION_LANGUAGE_H
11+
#define _LIBCPP___CONFIGURATION_LANGUAGE_H
12+
13+
#include <__config_site>
14+
15+
#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
16+
# pragma GCC system_header
17+
#endif
18+
19+
// NOLINTBEGIN(libcpp-cpp-version-check)
20+
#ifdef __cplusplus
21+
# if __cplusplus <= 201103L
22+
# define _LIBCPP_STD_VER 11
23+
# elif __cplusplus <= 201402L
24+
# define _LIBCPP_STD_VER 14
25+
# elif __cplusplus <= 201703L
26+
# define _LIBCPP_STD_VER 17
27+
# elif __cplusplus <= 202002L
28+
# define _LIBCPP_STD_VER 20
29+
# elif __cplusplus <= 202302L
30+
# define _LIBCPP_STD_VER 23
31+
# else
32+
// Expected release year of the next C++ standard
33+
# define _LIBCPP_STD_VER 26
34+
# endif
35+
#endif // __cplusplus
36+
// NOLINTEND(libcpp-cpp-version-check)
37+
38+
#if !defined(__cpp_rtti) || __cpp_rtti < 199711L
39+
# define _LIBCPP_HAS_NO_RTTI
40+
#endif
41+
42+
#if !defined(__cpp_exceptions) || __cpp_exceptions < 199711L
43+
# define _LIBCPP_HAS_NO_EXCEPTIONS
44+
#endif
45+
46+
#endif // _LIBCPP___CONFIGURATION_LANGUAGE_H

libcxx/include/__exception/exception_ptr.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#ifndef _LIBCPP___EXCEPTION_EXCEPTION_PTR_H
1010
#define _LIBCPP___EXCEPTION_EXCEPTION_PTR_H
1111

12-
#include <__availability>
1312
#include <__config>
1413
#include <__exception/operations.h>
1514
#include <__memory/addressof.h>

libcxx/include/__expected/bad_expected_access.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#ifndef _LIBCPP___EXPECTED_BAD_EXPECTED_ACCESS_H
1010
#define _LIBCPP___EXPECTED_BAD_EXPECTED_ACCESS_H
1111

12-
#include <__availability>
1312
#include <__config>
1413
#include <__exception/exception.h>
1514
#include <__utility/move.h>

libcxx/include/__filesystem/directory_entry.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#ifndef _LIBCPP___FILESYSTEM_DIRECTORY_ENTRY_H
1111
#define _LIBCPP___FILESYSTEM_DIRECTORY_ENTRY_H
1212

13-
#include <__availability>
1413
#include <__chrono/time_point.h>
1514
#include <__compare/ordering.h>
1615
#include <__config>

libcxx/include/__filesystem/directory_iterator.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#define _LIBCPP___FILESYSTEM_DIRECTORY_ITERATOR_H
1212

1313
#include <__assert>
14-
#include <__availability>
1514
#include <__config>
1615
#include <__filesystem/directory_entry.h>
1716
#include <__filesystem/directory_options.h>

libcxx/include/__filesystem/filesystem_error.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#ifndef _LIBCPP___FILESYSTEM_FILESYSTEM_ERROR_H
1111
#define _LIBCPP___FILESYSTEM_FILESYSTEM_ERROR_H
1212

13-
#include <__availability>
1413
#include <__config>
1514
#include <__filesystem/path.h>
1615
#include <__memory/shared_ptr.h>

libcxx/include/__filesystem/operations.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#ifndef _LIBCPP___FILESYSTEM_OPERATIONS_H
1111
#define _LIBCPP___FILESYSTEM_OPERATIONS_H
1212

13-
#include <__availability>
1413
#include <__chrono/time_point.h>
1514
#include <__config>
1615
#include <__filesystem/copy_options.h>

libcxx/include/__filesystem/path.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
#include <__algorithm/replace.h>
1414
#include <__algorithm/replace_copy.h>
15-
#include <__availability>
1615
#include <__config>
1716
#include <__functional/unary_function.h>
1817
#include <__fwd/functional.h>

libcxx/include/__filesystem/path_iterator.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#define _LIBCPP___FILESYSTEM_PATH_ITERATOR_H
1212

1313
#include <__assert>
14-
#include <__availability>
1514
#include <__config>
1615
#include <__filesystem/path.h>
1716
#include <__iterator/iterator_traits.h>

libcxx/include/__filesystem/recursive_directory_iterator.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#ifndef _LIBCPP___FILESYSTEM_RECURSIVE_DIRECTORY_ITERATOR_H
1111
#define _LIBCPP___FILESYSTEM_RECURSIVE_DIRECTORY_ITERATOR_H
1212

13-
#include <__availability>
1413
#include <__config>
1514
#include <__filesystem/directory_entry.h>
1615
#include <__filesystem/directory_options.h>

libcxx/include/__filesystem/u8path.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#define _LIBCPP___FILESYSTEM_U8PATH_H
1212

1313
#include <__algorithm/unwrap_iter.h>
14-
#include <__availability>
1514
#include <__config>
1615
#include <__filesystem/path.h>
1716
#include <string>

libcxx/include/__functional/function.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#define _LIBCPP___FUNCTIONAL_FUNCTION_H
1212

1313
#include <__assert>
14-
#include <__availability>
1514
#include <__config>
1615
#include <__exception/exception.h>
1716
#include <__functional/binary_function.h>

libcxx/include/__fwd/memory_resource.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#ifndef _LIBCPP___FWD_MEMORY_RESOURCE_H
1010
#define _LIBCPP___FWD_MEMORY_RESOURCE_H
1111

12-
#include <__availability>
1312
#include <__config>
1413

1514
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)

libcxx/include/__fwd/string.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#ifndef _LIBCPP___FWD_STRING_H
1010
#define _LIBCPP___FWD_STRING_H
1111

12-
#include <__availability>
1312
#include <__config>
1413
#include <__fwd/memory.h>
1514
#include <__fwd/memory_resource.h>

libcxx/include/__memory_resource/memory_resource.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#ifndef _LIBCPP___MEMORY_RESOURCE_MEMORY_RESOURCE_H
1010
#define _LIBCPP___MEMORY_RESOURCE_MEMORY_RESOURCE_H
1111

12-
#include <__availability>
1312
#include <__config>
1413
#include <__fwd/memory_resource.h>
1514
#include <cstddef>

libcxx/include/__memory_resource/monotonic_buffer_resource.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#ifndef _LIBCPP___MEMORY_RESOURCE_MONOTONIC_BUFFER_RESOURCE_H
1010
#define _LIBCPP___MEMORY_RESOURCE_MONOTONIC_BUFFER_RESOURCE_H
1111

12-
#include <__availability>
1312
#include <__config>
1413
#include <__memory/addressof.h>
1514
#include <__memory_resource/memory_resource.h>

libcxx/include/__memory_resource/polymorphic_allocator.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#define _LIBCPP___MEMORY_RESOURCE_POLYMORPHIC_ALLOCATOR_H
1111

1212
#include <__assert>
13-
#include <__availability>
1413
#include <__config>
1514
#include <__fwd/pair.h>
1615
#include <__memory_resource/memory_resource.h>

libcxx/include/__memory_resource/synchronized_pool_resource.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#ifndef _LIBCPP___MEMORY_RESOURCE_SYNCHRONIZED_POOL_RESOURCE_H
1010
#define _LIBCPP___MEMORY_RESOURCE_SYNCHRONIZED_POOL_RESOURCE_H
1111

12-
#include <__availability>
1312
#include <__config>
1413
#include <__memory_resource/memory_resource.h>
1514
#include <__memory_resource/pool_options.h>

libcxx/include/__memory_resource/unsynchronized_pool_resource.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#ifndef _LIBCPP___MEMORY_RESOURCE_UNSYNCHRONIZED_POOL_RESOURCE_H
1010
#define _LIBCPP___MEMORY_RESOURCE_UNSYNCHRONIZED_POOL_RESOURCE_H
1111

12-
#include <__availability>
1312
#include <__config>
1413
#include <__memory_resource/memory_resource.h>
1514
#include <__memory_resource/pool_options.h>

libcxx/include/__ostream/print.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#ifndef _LIBCPP___OSTREAM_PRINT_H
1010
#define _LIBCPP___OSTREAM_PRINT_H
1111

12-
#include <__availability>
1312
#include <__config>
1413
#include <__fwd/ostream.h>
1514
#include <__iterator/ostreambuf_iterator.h>

libcxx/include/__stop_token/stop_callback.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#ifndef _LIBCPP___STOP_TOKEN_STOP_CALLBACK_H
1111
#define _LIBCPP___STOP_TOKEN_STOP_CALLBACK_H
1212

13-
#include <__availability>
1413
#include <__concepts/constructible.h>
1514
#include <__concepts/destructible.h>
1615
#include <__concepts/invocable.h>

libcxx/include/__stop_token/stop_source.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#ifndef _LIBCPP___STOP_TOKEN_STOP_SOURCE_H
1111
#define _LIBCPP___STOP_TOKEN_STOP_SOURCE_H
1212

13-
#include <__availability>
1413
#include <__config>
1514
#include <__stop_token/intrusive_shared_ptr.h>
1615
#include <__stop_token/stop_state.h>

libcxx/include/__stop_token/stop_state.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#define _LIBCPP___STOP_TOKEN_STOP_STATE_H
1212

1313
#include <__assert>
14-
#include <__availability>
1514
#include <__config>
1615
#include <__stop_token/atomic_unique_lock.h>
1716
#include <__stop_token/intrusive_list_view.h>

libcxx/include/__stop_token/stop_token.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#ifndef _LIBCPP___STOP_TOKEN_STOP_TOKEN_H
1111
#define _LIBCPP___STOP_TOKEN_STOP_TOKEN_H
1212

13-
#include <__availability>
1413
#include <__config>
1514
#include <__stop_token/intrusive_shared_ptr.h>
1615
#include <__stop_token/stop_state.h>

libcxx/include/__thread/jthread.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#ifndef _LIBCPP___THREAD_JTHREAD_H
1111
#define _LIBCPP___THREAD_JTHREAD_H
1212

13-
#include <__availability>
1413
#include <__config>
1514
#include <__functional/invoke.h>
1615
#include <__stop_token/stop_source.h>

libcxx/include/__thread/poll_with_backoff.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#ifndef _LIBCPP___THREAD_POLL_WITH_BACKOFF_H
1111
#define _LIBCPP___THREAD_POLL_WITH_BACKOFF_H
1212

13-
#include <__availability>
1413
#include <__chrono/duration.h>
1514
#include <__chrono/high_resolution_clock.h>
1615
#include <__config>

0 commit comments

Comments
 (0)