Skip to content

Commit 716ed5f

Browse files
authored
[libc++] Undeprecate shared_ptr atomic access APIs (#92920)
This patch reverts 9b832b7 (#87111): - [libc++] Deprecated `shared_ptr` Atomic Access APIs as per P0718R2 - [libc++] Implemented P2869R3: Remove Deprecated `shared_ptr` Atomic Access APIs from C++26 As explained in [1], the suggested replacement in P2869R3 is `__cpp_lib_atomic_shared_ptr`, which libc++ does not yet implement. Let's not deprecate the old way of doing things before the new way of doing things exists. [1]: #87111 (comment)
1 parent 35fa2de commit 716ed5f

30 files changed

+46
-423
lines changed

libcxx/docs/ReleaseNotes/19.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ Implemented Papers
4343
- P2819R2 - Add ``tuple`` protocol to ``complex``
4444
- P2495R3 - Interfacing ``stringstream``\s with ``string_view``
4545
- P2867R2 - Remove Deprecated ``strstream``\s From C++26
46-
- P2869R4 - Remove Deprecated ``shared_ptr`` Atomic Access APIs from C++26
4746
- P2872R3 - Remove ``wstring_convert`` From C++26
4847
- P3142R0 - Printing Blank Lines with ``println`` (as DR against C++23)
4948
- P2944R3 - Comparisons for ``reference_wrapper`` (comparison operators for ``reference_wrapper`` only)
@@ -69,9 +68,6 @@ Improvements and New Features
6968

7069
- The ``_LIBCPP_ENABLE_CXX26_REMOVED_STRSTREAM`` macro has been added to make the declarations in ``<strstream>`` available.
7170

72-
- The ``_LIBCPP_ENABLE_CXX26_REMOVED_SHARED_PTR_ATOMICS`` macro has been added to make the declarations in ``<memory>``
73-
available.
74-
7571
- The ``_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT`` macro has been added to make the declarations in ``<locale>``
7672
available.
7773

libcxx/docs/Status/Cxx20.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ Paper Status
5858
* ``GPS clock`` not done
5959
* ``UTC clock`` not done
6060
61-
.. [#note-P0718] P0718: Implemented deprecation of ``shared_ptr`` atomic access APIs only.
62-
6361
.. _issues-status-cxx20:
6462

6563
Library Working Group Issues Status

libcxx/docs/Status/Cxx20Papers.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"`P0600R1 <https://wg21.link/P0600R1>`__","LWG","nodiscard in the Library","Albuquerque","|Complete|","16.0"
1313
"`P0616R0 <https://wg21.link/P0616R0>`__","LWG","de-pessimize legacy <numeric> algorithms with std::move","Albuquerque","|Complete|","12.0"
1414
"`P0653R2 <https://wg21.link/P0653R2>`__","LWG","Utility to convert a pointer to a raw pointer","Albuquerque","|Complete|","6.0"
15-
"`P0718R2 <https://wg21.link/P0718R2>`__","LWG","Atomic shared_ptr","Albuquerque","|Partial| [#note-P0718]_",""
15+
"`P0718R2 <https://wg21.link/P0718R2>`__","LWG","Atomic shared_ptr","Albuquerque","",""
1616
"`P0767R1 <https://wg21.link/P0767R1>`__","CWG","Deprecate POD","Albuquerque","|Complete|","7.0"
1717
"`P0768R1 <https://wg21.link/P0768R1>`__","CWG","Library Support for the Spaceship (Comparison) Operator","Albuquerque","|Complete|",""
1818
"`P0777R1 <https://wg21.link/P0777R1>`__","LWG","Treating Unnecessary ``decay``\ ","Albuquerque","|Complete|","7.0"

libcxx/docs/Status/Cxx2cPapers.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"","","","","","",""
4949
"`P2875R4 <https://wg21.link/P2875R4>`__","LWG","Undeprecate ``polymorphic_allocator::destroy`` for C++26","Tokyo March 2024","|Complete|","15.0",""
5050
"`P2867R2 <https://wg21.link/P2867R2>`__","LWG","Remove Deprecated ``strstreams`` From C++26","Tokyo March 2024","|Complete|","19.0",""
51-
"`P2869R4 <https://wg21.link/P2869R4>`__","LWG","Remove Deprecated ``shared_ptr`` Atomic Access APIs from C++26","Tokyo March 2024","|Complete|","19.0",""
51+
"`P2869R4 <https://wg21.link/P2869R4>`__","LWG","Remove Deprecated ``shared_ptr`` Atomic Access APIs from C++26","Tokyo March 2024","","",""
5252
"`P2872R3 <https://wg21.link/P2872R3>`__","LWG","Remove ``wstring_convert`` From C++26","Tokyo March 2024","|Complete|","19.0",""
5353
"`P3107R5 <https://wg21.link/P3107R5>`__","LWG","Permit an efficient implementation of ``std::print``","Tokyo March 2024","","","|format| |DR|"
5454
"`P3142R0 <https://wg21.link/P3142R0>`__","LWG","Printing Blank Lines with ``println``","Tokyo March 2024","|Complete| [#note-P3142R0]_","19.0","|format|"

libcxx/docs/UsingLibcxx.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,14 +252,10 @@ C++26 Specific Configuration Macros
252252
**_LIBCPP_ENABLE_CXX26_REMOVED_STRSTREAM**:
253253
This macro is used to re-enable all named declarations in ``<strstream>``.
254254

255-
**_LIBCPP_ENABLE_CXX26_REMOVED_SHARED_PTR_ATOMICS**:
256-
This macro is used to re-enable all ``shared_ptr`` atomic access APIs in ``<memory>``.
257-
258255
**_LIBCPP_ENABLE_CXX26_REMOVED_WSTRING_CONVERT**:
259256
This macro is used to re-enable the ``wstring_convert`` and ``wbuffer_convert``
260257
in ``<locale>``.
261258

262-
263259
Libc++ Extensions
264260
=================
265261

libcxx/include/__memory/shared_ptr.h

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,15 +1583,13 @@ class _LIBCPP_EXPORTED_FROM_ABI __sp_mut {
15831583

15841584
_LIBCPP_EXPORTED_FROM_ABI __sp_mut& __get_sp_mut(const void*);
15851585

1586-
# if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_SHARED_PTR_ATOMICS)
1587-
15881586
template <class _Tp>
1589-
_LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI bool atomic_is_lock_free(const shared_ptr<_Tp>*) {
1587+
inline _LIBCPP_HIDE_FROM_ABI bool atomic_is_lock_free(const shared_ptr<_Tp>*) {
15901588
return false;
15911589
}
15921590

15931591
template <class _Tp>
1594-
_LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> atomic_load(const shared_ptr<_Tp>* __p) {
1592+
_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> atomic_load(const shared_ptr<_Tp>* __p) {
15951593
__sp_mut& __m = std::__get_sp_mut(__p);
15961594
__m.lock();
15971595
shared_ptr<_Tp> __q = *__p;
@@ -1600,28 +1598,25 @@ _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> atomic_load(co
16001598
}
16011599

16021600
template <class _Tp>
1603-
_LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp>
1604-
atomic_load_explicit(const shared_ptr<_Tp>* __p, memory_order) {
1601+
inline _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> atomic_load_explicit(const shared_ptr<_Tp>* __p, memory_order) {
16051602
return std::atomic_load(__p);
16061603
}
16071604

16081605
template <class _Tp>
1609-
_LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI void atomic_store(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r) {
1606+
_LIBCPP_HIDE_FROM_ABI void atomic_store(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r) {
16101607
__sp_mut& __m = std::__get_sp_mut(__p);
16111608
__m.lock();
16121609
__p->swap(__r);
16131610
__m.unlock();
16141611
}
16151612

16161613
template <class _Tp>
1617-
_LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI void
1618-
atomic_store_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r, memory_order) {
1614+
inline _LIBCPP_HIDE_FROM_ABI void atomic_store_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r, memory_order) {
16191615
std::atomic_store(__p, __r);
16201616
}
16211617

16221618
template <class _Tp>
1623-
_LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp>
1624-
atomic_exchange(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r) {
1619+
_LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp> atomic_exchange(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r) {
16251620
__sp_mut& __m = std::__get_sp_mut(__p);
16261621
__m.lock();
16271622
__p->swap(__r);
@@ -1630,13 +1625,13 @@ atomic_exchange(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r) {
16301625
}
16311626

16321627
template <class _Tp>
1633-
_LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp>
1628+
inline _LIBCPP_HIDE_FROM_ABI shared_ptr<_Tp>
16341629
atomic_exchange_explicit(shared_ptr<_Tp>* __p, shared_ptr<_Tp> __r, memory_order) {
16351630
return std::atomic_exchange(__p, __r);
16361631
}
16371632

16381633
template <class _Tp>
1639-
_LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI bool
1634+
_LIBCPP_HIDE_FROM_ABI bool
16401635
atomic_compare_exchange_strong(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, shared_ptr<_Tp> __w) {
16411636
shared_ptr<_Tp> __temp;
16421637
__sp_mut& __m = std::__get_sp_mut(__p);
@@ -1654,25 +1649,23 @@ atomic_compare_exchange_strong(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, share
16541649
}
16551650

16561651
template <class _Tp>
1657-
_LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI bool
1652+
inline _LIBCPP_HIDE_FROM_ABI bool
16581653
atomic_compare_exchange_weak(shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, shared_ptr<_Tp> __w) {
16591654
return std::atomic_compare_exchange_strong(__p, __v, __w);
16601655
}
16611656

16621657
template <class _Tp>
1663-
_LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI bool atomic_compare_exchange_strong_explicit(
1658+
inline _LIBCPP_HIDE_FROM_ABI bool atomic_compare_exchange_strong_explicit(
16641659
shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, shared_ptr<_Tp> __w, memory_order, memory_order) {
16651660
return std::atomic_compare_exchange_strong(__p, __v, __w);
16661661
}
16671662

16681663
template <class _Tp>
1669-
_LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_HIDE_FROM_ABI bool atomic_compare_exchange_weak_explicit(
1664+
inline _LIBCPP_HIDE_FROM_ABI bool atomic_compare_exchange_weak_explicit(
16701665
shared_ptr<_Tp>* __p, shared_ptr<_Tp>* __v, shared_ptr<_Tp> __w, memory_order, memory_order) {
16711666
return std::atomic_compare_exchange_weak(__p, __v, __w);
16721667
}
16731668

1674-
# endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_SHARED_PTR_ATOMICS)
1675-
16761669
#endif // !defined(_LIBCPP_HAS_NO_THREADS)
16771670

16781671
_LIBCPP_END_NAMESPACE_STD

libcxx/include/memory

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -830,34 +830,34 @@ public:
830830
};
831831
832832
template<class T>
833-
bool atomic_is_lock_free(const shared_ptr<T>* p); // Deprecated in C++20, removed in C++26
833+
bool atomic_is_lock_free(const shared_ptr<T>* p);
834834
template<class T>
835-
shared_ptr<T> atomic_load(const shared_ptr<T>* p); // Deprecated in C++20, removed in C++26
835+
shared_ptr<T> atomic_load(const shared_ptr<T>* p);
836836
template<class T>
837-
shared_ptr<T> atomic_load_explicit(const shared_ptr<T>* p, memory_order mo); // Deprecated in C++20, removed in C++26
837+
shared_ptr<T> atomic_load_explicit(const shared_ptr<T>* p, memory_order mo);
838838
template<class T>
839-
void atomic_store(shared_ptr<T>* p, shared_ptr<T> r); // Deprecated in C++20, removed in C++26
839+
void atomic_store(shared_ptr<T>* p, shared_ptr<T> r);
840840
template<class T>
841-
void atomic_store_explicit(shared_ptr<T>* p, shared_ptr<T> r, memory_order mo); // Deprecated in C++20, removed in C++26
841+
void atomic_store_explicit(shared_ptr<T>* p, shared_ptr<T> r, memory_order mo);
842842
template<class T>
843-
shared_ptr<T> atomic_exchange(shared_ptr<T>* p, shared_ptr<T> r); // Deprecated in C++20, removed in C++26
843+
shared_ptr<T> atomic_exchange(shared_ptr<T>* p, shared_ptr<T> r);
844844
template<class T>
845845
shared_ptr<T>
846-
atomic_exchange_explicit(shared_ptr<T>* p, shared_ptr<T> r, memory_order mo); // Deprecated in C++20, removed in C++26
846+
atomic_exchange_explicit(shared_ptr<T>* p, shared_ptr<T> r, memory_order mo);
847847
template<class T>
848848
bool
849-
atomic_compare_exchange_weak(shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w); // Deprecated in C++20, removed in C++26
849+
atomic_compare_exchange_weak(shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w);
850850
template<class T>
851851
bool
852-
atomic_compare_exchange_strong( shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w); // Deprecated in C++20, removed in C++26
852+
atomic_compare_exchange_strong( shared_ptr<T>* p, shared_ptr<T>* v, shared_ptr<T> w);
853853
template<class T>
854854
bool
855-
atomic_compare_exchange_weak_explicit(shared_ptr<T>* p, shared_ptr<T>* v, // Deprecated in C++20, removed in C++26
855+
atomic_compare_exchange_weak_explicit(shared_ptr<T>* p, shared_ptr<T>* v,
856856
shared_ptr<T> w, memory_order success,
857857
memory_order failure);
858858
template<class T>
859859
bool
860-
atomic_compare_exchange_strong_explicit(shared_ptr<T>* p, shared_ptr<T>* v, // Deprecated in C++20, removed in C++26
860+
atomic_compare_exchange_strong_explicit(shared_ptr<T>* p, shared_ptr<T>* v,
861861
shared_ptr<T> w, memory_order success,
862862
memory_order failure);
863863
// Hash support

libcxx/modules/std/memory.inc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,6 @@ export namespace std {
190190
// using std::inout_ptr;
191191

192192
#ifndef _LIBCPP_HAS_NO_THREADS
193-
194-
# if _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_SHARED_PTR_ATOMICS)
195-
196193
// [depr.util.smartptr.shared.atomic]
197194
using std::atomic_is_lock_free;
198195

@@ -209,8 +206,5 @@ export namespace std {
209206
using std::atomic_compare_exchange_strong_explicit;
210207
using std::atomic_compare_exchange_weak;
211208
using std::atomic_compare_exchange_weak_explicit;
212-
213-
# endif // _LIBCPP_STD_VER < 26 || defined(_LIBCPP_ENABLE_CXX26_REMOVED_SHARED_PTR_ATOMICS)
214-
215209
#endif // _LIBCPP_HAS_NO_THREADS
216210
} // namespace std

libcxx/test/libcxx/depr/depr.util.smartptr.shared.atomic/atomic_compare_exchange_strong.depr_in_cxx20..verify.cpp

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

libcxx/test/libcxx/depr/depr.util.smartptr.shared.atomic/atomic_compare_exchange_strong_explicit.depr_in_cxx20.verify.cpp

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

libcxx/test/libcxx/depr/depr.util.smartptr.shared.atomic/atomic_compare_exchange_weak.depr_in_cxx20..verify.cpp

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

libcxx/test/libcxx/depr/depr.util.smartptr.shared.atomic/atomic_compare_exchange_weak_explicit.depr_in_cxx20..verify.cpp

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

libcxx/test/libcxx/depr/depr.util.smartptr.shared.atomic/atomic_exchange.depr_in_cxx20..verify.cpp

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

0 commit comments

Comments
 (0)