[libcxx-commits] [PATCH] D143797: [libc++] Mark some variables as inline, per the spec
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Feb 10 17:00:34 PST 2023
ldionne created this revision.
Herald added a project: All.
ldionne requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.
This is really what D110243 <https://reviews.llvm.org/D110243> should have done. These variables are
inline in the spec. We unfortunately need to support pre-C++17 since
some of these inline variables are in C++17 parts of the library that
we provide pre-C++17 as an extension.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D143797
Files:
libcxx/include/__config
libcxx/include/__functional/bind.h
libcxx/include/__memory/allocator_arg_t.h
libcxx/include/__mutex_base
libcxx/include/__utility/piecewise_construct.h
Index: libcxx/include/__utility/piecewise_construct.h
===================================================================
--- libcxx/include/__utility/piecewise_construct.h
+++ libcxx/include/__utility/piecewise_construct.h
@@ -21,7 +21,7 @@
#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY)
extern _LIBCPP_EXPORTED_FROM_ABI const piecewise_construct_t piecewise_construct;// = piecewise_construct_t();
#else
-/* inline */ constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
+_LIBCPP_INLINE_VAR constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t();
#endif
_LIBCPP_END_NAMESPACE_STD
Index: libcxx/include/__mutex_base
===================================================================
--- libcxx/include/__mutex_base
+++ libcxx/include/__mutex_base
@@ -72,9 +72,9 @@
#else
-/* inline */ constexpr defer_lock_t defer_lock = defer_lock_t();
-/* inline */ constexpr try_to_lock_t try_to_lock = try_to_lock_t();
-/* inline */ constexpr adopt_lock_t adopt_lock = adopt_lock_t();
+_LIBCPP_INLINE_VAR constexpr defer_lock_t defer_lock = defer_lock_t();
+_LIBCPP_INLINE_VAR constexpr try_to_lock_t try_to_lock = try_to_lock_t();
+_LIBCPP_INLINE_VAR constexpr adopt_lock_t adopt_lock = adopt_lock_t();
#endif
Index: libcxx/include/__memory/allocator_arg_t.h
===================================================================
--- libcxx/include/__memory/allocator_arg_t.h
+++ libcxx/include/__memory/allocator_arg_t.h
@@ -28,7 +28,7 @@
#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY)
extern _LIBCPP_EXPORTED_FROM_ABI const allocator_arg_t allocator_arg;
#else
-/* inline */ constexpr allocator_arg_t allocator_arg = allocator_arg_t();
+_LIBCPP_INLINE_VAR constexpr allocator_arg_t allocator_arg = allocator_arg_t();
#endif
#ifndef _LIBCPP_CXX03_LANG
Index: libcxx/include/__functional/bind.h
===================================================================
--- libcxx/include/__functional/bind.h
+++ libcxx/include/__functional/bind.h
@@ -64,16 +64,16 @@
_LIBCPP_FUNC_VIS extern const __ph<9> _9;
_LIBCPP_FUNC_VIS extern const __ph<10> _10;
#else
-/* inline */ constexpr __ph<1> _1{};
-/* inline */ constexpr __ph<2> _2{};
-/* inline */ constexpr __ph<3> _3{};
-/* inline */ constexpr __ph<4> _4{};
-/* inline */ constexpr __ph<5> _5{};
-/* inline */ constexpr __ph<6> _6{};
-/* inline */ constexpr __ph<7> _7{};
-/* inline */ constexpr __ph<8> _8{};
-/* inline */ constexpr __ph<9> _9{};
-/* inline */ constexpr __ph<10> _10{};
+_LIBCPP_INLINE_VAR constexpr __ph<1> _1{};
+_LIBCPP_INLINE_VAR constexpr __ph<2> _2{};
+_LIBCPP_INLINE_VAR constexpr __ph<3> _3{};
+_LIBCPP_INLINE_VAR constexpr __ph<4> _4{};
+_LIBCPP_INLINE_VAR constexpr __ph<5> _5{};
+_LIBCPP_INLINE_VAR constexpr __ph<6> _6{};
+_LIBCPP_INLINE_VAR constexpr __ph<7> _7{};
+_LIBCPP_INLINE_VAR constexpr __ph<8> _8{};
+_LIBCPP_INLINE_VAR constexpr __ph<9> _9{};
+_LIBCPP_INLINE_VAR constexpr __ph<10> _10{};
#endif // defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY)
} // namespace placeholders
Index: libcxx/include/__config
===================================================================
--- libcxx/include/__config
+++ libcxx/include/__config
@@ -891,6 +891,12 @@
# define _LIBCPP_NODISCARD_AFTER_CXX17
# endif
+# if _LIBCPP_STD_VER >= 17
+# define _LIBCPP_INLINE_VAR inline
+# else
+# define _LIBCPP_INLINE_VAR
+# endif
+
# if __has_attribute(__no_destroy__)
# define _LIBCPP_NO_DESTROY __attribute__((__no_destroy__))
# else
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143797.496638.patch
Type: text/x-patch
Size: 3601 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230211/d85910b8/attachment.bin>
More information about the libcxx-commits
mailing list