Message ID | 20240921132253.934099-1-jason@redhat.com |
---|---|
State | New |
Headers | show |
Series | libstdc++: operator new/delete are transaction_safe | expand |
On Sat, 21 Sept 2024, 14:24 Jason Merrill, <jason@redhat.com> wrote: > Tested x86_64-pc-linux-gnu, OK for trunk? > All those macros already make them cluttered so this doesn't make them any more unreadable! OK, thanks > -- 8< -- > > With the changes to #pragma system_header, g++.dg/tm/pr46270.C was > failing because <new> didn't implement the N4514 change to [new.delete] > that > says "The library versions of the global allocation and deallocation > functions are declared transaction_safe (8.3.5 dcl.fct)." We already have > the _GLIBCXX_TXN_SAFE macro, just need to add it. > > libstdc++-v3/ChangeLog: > > * libsupc++/new: Add _GLIBCXX_TXN_SAFE. > --- > libstdc++-v3/libsupc++/new | 56 ++++++++++++++++++++++++++------------ > 1 file changed, 38 insertions(+), 18 deletions(-) > > diff --git a/libstdc++-v3/libsupc++/new b/libstdc++-v3/libsupc++/new > index 7e1eee8f9d6..e9a3d9b49a3 100644 > --- a/libstdc++-v3/libsupc++/new > +++ b/libstdc++-v3/libsupc++/new > @@ -134,49 +134,63 @@ namespace std > * Placement new and delete signatures (take a memory address argument, > * does nothing) may not be replaced by a user's program. > */ > -_GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW > (std::bad_alloc) > +_GLIBCXX_NODISCARD void* operator new(std::size_t) > + _GLIBCXX_TXN_SAFE _GLIBCXX_THROW (std::bad_alloc) > __attribute__((__externally_visible__)); > -_GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW > (std::bad_alloc) > +_GLIBCXX_NODISCARD void* operator new[](std::size_t) > + _GLIBCXX_TXN_SAFE _GLIBCXX_THROW (std::bad_alloc) > __attribute__((__externally_visible__)); > -void operator delete(void*) _GLIBCXX_USE_NOEXCEPT > +void operator delete(void*) _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT > __attribute__((__externally_visible__)); > -void operator delete[](void*) _GLIBCXX_USE_NOEXCEPT > +void operator delete[](void*) _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT > __attribute__((__externally_visible__)); > #if __cpp_sized_deallocation > -void operator delete(void*, std::size_t) _GLIBCXX_USE_NOEXCEPT > +void operator delete(void*, std::size_t) > + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT > __attribute__((__externally_visible__)); > -void operator delete[](void*, std::size_t) _GLIBCXX_USE_NOEXCEPT > +void operator delete[](void*, std::size_t) > + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT > __attribute__((__externally_visible__)); > #endif > -_GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) > _GLIBCXX_USE_NOEXCEPT > +_GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) > + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT > __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__)); > -_GLIBCXX_NODISCARD void* operator new[](std::size_t, const > std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT > +_GLIBCXX_NODISCARD void* operator new[](std::size_t, const > std::nothrow_t&) > + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT > __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__)); > -void operator delete(void*, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT > +void operator delete(void*, const std::nothrow_t&) > + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT > __attribute__((__externally_visible__)); > -void operator delete[](void*, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT > +void operator delete[](void*, const std::nothrow_t&) > + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT > __attribute__((__externally_visible__)); > #if __cpp_aligned_new > _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t) > + _GLIBCXX_TXN_SAFE > __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__)); > _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, > const std::nothrow_t&) > + _GLIBCXX_TXN_SAFE > _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__, > __alloc_size__ (1), __malloc__)); > -void operator delete(void*, std::align_val_t) > +void operator delete(void*, std::align_val_t) _GLIBCXX_TXN_SAFE > _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); > void operator delete(void*, std::align_val_t, const std::nothrow_t&) > + _GLIBCXX_TXN_SAFE > _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); > _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t) > + _GLIBCXX_TXN_SAFE > __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__)); > _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, > const std::nothrow_t&) > + _GLIBCXX_TXN_SAFE > _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__, > __alloc_size__ (1), __malloc__)); > -void operator delete[](void*, std::align_val_t) > +void operator delete[](void*, std::align_val_t) _GLIBCXX_TXN_SAFE > _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); > void operator delete[](void*, std::align_val_t, const std::nothrow_t&) > + _GLIBCXX_TXN_SAFE > _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); > #if __cpp_sized_deallocation > -void operator delete(void*, std::size_t, std::align_val_t) > +void operator delete(void*, std::size_t, std::align_val_t) > _GLIBCXX_TXN_SAFE > _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); > -void operator delete[](void*, std::size_t, std::align_val_t) > +void operator delete[](void*, std::size_t, std::align_val_t) > _GLIBCXX_TXN_SAFE > _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); > #endif // __cpp_sized_deallocation > #endif // __cpp_aligned_new > @@ -189,17 +203,23 @@ void operator delete[](void*, std::size_t, > std::align_val_t) > > // Default placement versions of operator new. > _GLIBCXX_NODISCARD _GLIBCXX_PLACEMENT_CONSTEXPR > -void* operator new(std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT > +void* operator new(std::size_t, void* __p) > + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT > { return __p; } > _GLIBCXX_NODISCARD _GLIBCXX_PLACEMENT_CONSTEXPR > -void* operator new[](std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT > +void* operator new[](std::size_t, void* __p) > + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT > { return __p; } > > #undef _GLIBCXX_PLACEMENT_CONSTEXPR > > // Default placement versions of operator delete. > -inline void operator delete (void*, void*) _GLIBCXX_USE_NOEXCEPT { } > -inline void operator delete[](void*, void*) _GLIBCXX_USE_NOEXCEPT { } > +inline void operator delete (void*, void*) > + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT > +{ } > +inline void operator delete[](void*, void*) > + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT > +{ } > //@} > } // extern "C++" > > > base-commit: 2484ba167e1c4a52d4989b71e1f5d4d27755500f > -- > 2.46.0 > >
diff --git a/libstdc++-v3/libsupc++/new b/libstdc++-v3/libsupc++/new index 7e1eee8f9d6..e9a3d9b49a3 100644 --- a/libstdc++-v3/libsupc++/new +++ b/libstdc++-v3/libsupc++/new @@ -134,49 +134,63 @@ namespace std * Placement new and delete signatures (take a memory address argument, * does nothing) may not be replaced by a user's program. */ -_GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc) +_GLIBCXX_NODISCARD void* operator new(std::size_t) + _GLIBCXX_TXN_SAFE _GLIBCXX_THROW (std::bad_alloc) __attribute__((__externally_visible__)); -_GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc) +_GLIBCXX_NODISCARD void* operator new[](std::size_t) + _GLIBCXX_TXN_SAFE _GLIBCXX_THROW (std::bad_alloc) __attribute__((__externally_visible__)); -void operator delete(void*) _GLIBCXX_USE_NOEXCEPT +void operator delete(void*) _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); -void operator delete[](void*) _GLIBCXX_USE_NOEXCEPT +void operator delete[](void*) _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); #if __cpp_sized_deallocation -void operator delete(void*, std::size_t) _GLIBCXX_USE_NOEXCEPT +void operator delete(void*, std::size_t) + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); -void operator delete[](void*, std::size_t) _GLIBCXX_USE_NOEXCEPT +void operator delete[](void*, std::size_t) + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); #endif -_GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT +_GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__)); -_GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT +_GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__)); -void operator delete(void*, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT +void operator delete(void*, const std::nothrow_t&) + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); -void operator delete[](void*, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT +void operator delete[](void*, const std::nothrow_t&) + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); #if __cpp_aligned_new _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t) + _GLIBCXX_TXN_SAFE __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__)); _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&) + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__)); -void operator delete(void*, std::align_val_t) +void operator delete(void*, std::align_val_t) _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); void operator delete(void*, std::align_val_t, const std::nothrow_t&) + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t) + _GLIBCXX_TXN_SAFE __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__)); _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&) + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__)); -void operator delete[](void*, std::align_val_t) +void operator delete[](void*, std::align_val_t) _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); void operator delete[](void*, std::align_val_t, const std::nothrow_t&) + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); #if __cpp_sized_deallocation -void operator delete(void*, std::size_t, std::align_val_t) +void operator delete(void*, std::size_t, std::align_val_t) _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); -void operator delete[](void*, std::size_t, std::align_val_t) +void operator delete[](void*, std::size_t, std::align_val_t) _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT __attribute__((__externally_visible__)); #endif // __cpp_sized_deallocation #endif // __cpp_aligned_new @@ -189,17 +203,23 @@ void operator delete[](void*, std::size_t, std::align_val_t) // Default placement versions of operator new. _GLIBCXX_NODISCARD _GLIBCXX_PLACEMENT_CONSTEXPR -void* operator new(std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT +void* operator new(std::size_t, void* __p) + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT { return __p; } _GLIBCXX_NODISCARD _GLIBCXX_PLACEMENT_CONSTEXPR -void* operator new[](std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT +void* operator new[](std::size_t, void* __p) + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT { return __p; } #undef _GLIBCXX_PLACEMENT_CONSTEXPR // Default placement versions of operator delete. -inline void operator delete (void*, void*) _GLIBCXX_USE_NOEXCEPT { } -inline void operator delete[](void*, void*) _GLIBCXX_USE_NOEXCEPT { } +inline void operator delete (void*, void*) + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT +{ } +inline void operator delete[](void*, void*) + _GLIBCXX_TXN_SAFE _GLIBCXX_USE_NOEXCEPT +{ } //@} } // extern "C++"