Update OpenAL Soft to 1.18.2

This commit is contained in:
Alex Szpakowski
2017-12-10 22:34:10 -04:00
parent 75e0077566
commit b160006eb1
152 changed files with 33572 additions and 15363 deletions
+11 -9
View File
@@ -11,26 +11,27 @@
/* A simple spinlock. Yield the thread while the given integer is set by
* another. Could probably be improved... */
#define LOCK(l) do { \
while(ATOMIC_EXCHANGE(int, &(l), true) == true) \
while(ATOMIC_FLAG_TEST_AND_SET(&(l), almemory_order_acq_rel) == true) \
althrd_yield(); \
} while(0)
#define UNLOCK(l) ATOMIC_STORE(&(l), false)
#define UNLOCK(l) ATOMIC_FLAG_CLEAR(&(l), almemory_order_release)
void RWLockInit(RWLock *lock)
{
InitRef(&lock->read_count, 0);
InitRef(&lock->write_count, 0);
ATOMIC_INIT(&lock->read_lock, false);
ATOMIC_INIT(&lock->read_entry_lock, false);
ATOMIC_INIT(&lock->write_lock, false);
ATOMIC_FLAG_CLEAR(&lock->read_lock, almemory_order_relaxed);
ATOMIC_FLAG_CLEAR(&lock->read_entry_lock, almemory_order_relaxed);
ATOMIC_FLAG_CLEAR(&lock->write_lock, almemory_order_relaxed);
}
void ReadLock(RWLock *lock)
{
LOCK(lock->read_entry_lock);
LOCK(lock->read_lock);
if(IncrementRef(&lock->read_count) == 1)
/* NOTE: ATOMIC_ADD returns the *old* value! */
if(ATOMIC_ADD(&lock->read_count, 1, almemory_order_acq_rel) == 0)
LOCK(lock->write_lock);
UNLOCK(lock->read_lock);
UNLOCK(lock->read_entry_lock);
@@ -38,13 +39,14 @@ void ReadLock(RWLock *lock)
void ReadUnlock(RWLock *lock)
{
if(DecrementRef(&lock->read_count) == 0)
/* NOTE: ATOMIC_SUB returns the *old* value! */
if(ATOMIC_SUB(&lock->read_count, 1, almemory_order_acq_rel) == 1)
UNLOCK(lock->write_lock);
}
void WriteLock(RWLock *lock)
{
if(IncrementRef(&lock->write_count) == 1)
if(ATOMIC_ADD(&lock->write_count, 1, almemory_order_acq_rel) == 0)
LOCK(lock->read_lock);
LOCK(lock->write_lock);
}
@@ -52,6 +54,6 @@ void WriteLock(RWLock *lock)
void WriteUnlock(RWLock *lock)
{
UNLOCK(lock->write_lock);
if(DecrementRef(&lock->write_count) == 0)
if(ATOMIC_SUB(&lock->write_count, 1, almemory_order_acq_rel) == 1)
UNLOCK(lock->read_lock);
}