Update OpenAL-soft to 1.23.1-bc7cb17.

This commit is contained in:
Miku AuahDark
2024-03-20 11:06:03 +08:00
parent 4a512be715
commit 73a6fc9196
294 changed files with 44342 additions and 40077 deletions
+18 -29
View File
@@ -1,6 +1,8 @@
#ifndef INTRUSIVE_PTR_H
#define INTRUSIVE_PTR_H
#include <atomic>
#include <cstddef>
#include <utility>
#include "atomic.h"
@@ -11,14 +13,14 @@ namespace al {
template<typename T>
class intrusive_ref {
RefCount mRef{1u};
std::atomic<unsigned int> mRef{1u};
public:
unsigned int add_ref() noexcept { return IncrementRef(mRef); }
unsigned int release() noexcept
unsigned int dec_ref() noexcept
{
auto ref = DecrementRef(mRef);
if UNLIKELY(ref == 0)
if(ref == 0) UNLIKELY
delete static_cast<T*>(this);
return ref;
}
@@ -58,22 +60,26 @@ public:
{ rhs.mPtr = nullptr; }
intrusive_ptr(std::nullptr_t) noexcept { }
explicit intrusive_ptr(T *ptr) noexcept : mPtr{ptr} { }
~intrusive_ptr() { if(mPtr) mPtr->release(); }
~intrusive_ptr() { if(mPtr) mPtr->dec_ref(); }
/* NOLINTBEGIN(bugprone-unhandled-self-assignment)
* Self-assignment is handled properly here.
*/
intrusive_ptr& operator=(const intrusive_ptr &rhs) noexcept
{
static_assert(noexcept(std::declval<T*>()->release()), "release must be noexcept");
static_assert(noexcept(std::declval<T*>()->dec_ref()), "dec_ref must be noexcept");
if(rhs.mPtr) rhs.mPtr->add_ref();
if(mPtr) mPtr->release();
if(mPtr) mPtr->dec_ref();
mPtr = rhs.mPtr;
return *this;
}
/* NOLINTEND(bugprone-unhandled-self-assignment) */
intrusive_ptr& operator=(intrusive_ptr&& rhs) noexcept
{
if(likely(&rhs != this))
if(&rhs != this) LIKELY
{
if(mPtr) mPtr->release();
if(mPtr) mPtr->dec_ref();
mPtr = std::exchange(rhs.mPtr, nullptr);
}
return *this;
@@ -81,14 +87,14 @@ public:
explicit operator bool() const noexcept { return mPtr != nullptr; }
T& operator*() const noexcept { return *mPtr; }
T* operator->() const noexcept { return mPtr; }
T* get() const noexcept { return mPtr; }
[[nodiscard]] auto operator*() const noexcept -> T& { return *mPtr; }
[[nodiscard]] auto operator->() const noexcept -> T* { return mPtr; }
[[nodiscard]] auto get() const noexcept -> T* { return mPtr; }
void reset(T *ptr=nullptr) noexcept
{
if(mPtr)
mPtr->release();
mPtr->dec_ref();
mPtr = ptr;
}
@@ -98,23 +104,6 @@ public:
void swap(intrusive_ptr&& rhs) noexcept { std::swap(mPtr, rhs.mPtr); }
};
#define AL_DECL_OP(op) \
template<typename T> \
inline bool operator op(const intrusive_ptr<T> &lhs, const T *rhs) noexcept \
{ return lhs.get() op rhs; } \
template<typename T> \
inline bool operator op(const T *lhs, const intrusive_ptr<T> &rhs) noexcept \
{ return lhs op rhs.get(); }
AL_DECL_OP(==)
AL_DECL_OP(!=)
AL_DECL_OP(<=)
AL_DECL_OP(>=)
AL_DECL_OP(<)
AL_DECL_OP(>)
#undef AL_DECL_OP
} // namespace al
#endif /* INTRUSIVE_PTR_H */