mirror of https://github.com/PCSX2/pcsx2.git
common: remove old atomic wrapper
Use cross-platform std::atomic instead
This commit is contained in:
parent
812e41d578
commit
10ea05bc6f
|
@ -159,9 +159,6 @@ namespace Threading
|
||||||
// For use in spin/wait loops.
|
// For use in spin/wait loops.
|
||||||
extern void SpinWait();
|
extern void SpinWait();
|
||||||
|
|
||||||
// Use prior to committing data to another thread
|
|
||||||
extern void StoreFence();
|
|
||||||
|
|
||||||
// Optional implementation to enable hires thread/process scheduler for the operating system.
|
// Optional implementation to enable hires thread/process scheduler for the operating system.
|
||||||
// Needed by Windows, but might not be relevant to other platforms.
|
// Needed by Windows, but might not be relevant to other platforms.
|
||||||
extern void EnableHiresScheduler();
|
extern void EnableHiresScheduler();
|
||||||
|
@ -170,18 +167,6 @@ namespace Threading
|
||||||
// sleeps the current thread for the given number of milliseconds.
|
// sleeps the current thread for the given number of milliseconds.
|
||||||
extern void Sleep( int ms );
|
extern void Sleep( int ms );
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------
|
|
||||||
// AtomicExchange / AtomicIncrement
|
|
||||||
// --------------------------------------------------------------------------------------
|
|
||||||
// Our fundamental interlocking functions. All other useful interlocks can be derived
|
|
||||||
// from these little beasties! (these are all implemented internally using cross-platform
|
|
||||||
// implementations of _InterlockedExchange and such)
|
|
||||||
|
|
||||||
extern u32 AtomicRead( volatile u32& Target );
|
|
||||||
extern s32 AtomicRead( volatile s32& Target );
|
|
||||||
extern u32 AtomicExchange( volatile u32& Target, u32 value );
|
|
||||||
extern s32 AtomicExchange( volatile s32& Target, s32 value );
|
|
||||||
|
|
||||||
// pthread Cond is an evil api that is not suited for Pcsx2 needs.
|
// pthread Cond is an evil api that is not suited for Pcsx2 needs.
|
||||||
// Let's not use it. Use mutexes and semaphores instead to create waits. (Air)
|
// Let's not use it. Use mutexes and semaphores instead to create waits. (Air)
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -309,7 +294,7 @@ namespace Threading
|
||||||
// will be automatically released on any return or exit from the function.
|
// will be automatically released on any return or exit from the function.
|
||||||
//
|
//
|
||||||
// Const qualification note:
|
// Const qualification note:
|
||||||
// ScopedLock takes const instances of the mutex, even though the mutex is modified
|
// ScopedLock takes const instances of the mutex, even though the mutex is modified
|
||||||
// by locking and unlocking. Two rationales:
|
// by locking and unlocking. Two rationales:
|
||||||
//
|
//
|
||||||
// 1) when designing classes with accessors (GetString, GetValue, etc) that need mutexes,
|
// 1) when designing classes with accessors (GetString, GetValue, etc) that need mutexes,
|
||||||
|
|
|
@ -327,7 +327,7 @@ void Threading::ScopedLock::AssignAndLock( const Mutex* locker )
|
||||||
if( !m_lock ) return;
|
if( !m_lock ) return;
|
||||||
|
|
||||||
m_IsLocked = true;
|
m_IsLocked = true;
|
||||||
m_lock->Acquire();
|
m_lock->Acquire();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Threading::ScopedLock::Assign( const Mutex& locker )
|
void Threading::ScopedLock::Assign( const Mutex& locker )
|
||||||
|
|
|
@ -782,27 +782,6 @@ void Threading::WaitEvent::Wait()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------
|
|
||||||
// InterlockedExchanges / AtomicExchanges (PCSX2's Helper versions)
|
|
||||||
// --------------------------------------------------------------------------------------
|
|
||||||
// define some overloads for InterlockedExchanges for commonly used types, like u32 and s32.
|
|
||||||
// Note: For all of these atomic operations below to be atomic, the variables need to be 4-byte
|
|
||||||
// aligned. Read: http://msdn.microsoft.com/en-us/library/ms684122%28v=vs.85%29.aspx
|
|
||||||
|
|
||||||
__fi u32 Threading::AtomicRead(volatile u32& Target) {
|
|
||||||
return Target; // Properly-aligned 32-bit reads are atomic
|
|
||||||
}
|
|
||||||
__fi s32 Threading::AtomicRead(volatile s32& Target) {
|
|
||||||
return Target; // Properly-aligned 32-bit reads are atomic
|
|
||||||
}
|
|
||||||
|
|
||||||
__fi u32 Threading::AtomicExchange(volatile u32& Target, u32 value ) {
|
|
||||||
return _InterlockedExchange( (volatile vol_t*)&Target, value );
|
|
||||||
}
|
|
||||||
__fi s32 Threading::AtomicExchange( volatile s32& Target, s32 value ) {
|
|
||||||
return _InterlockedExchange( (volatile vol_t*)&Target, value );
|
|
||||||
}
|
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------
|
||||||
// BaseThreadError
|
// BaseThreadError
|
||||||
// --------------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -36,11 +36,6 @@ __fi void Threading::SpinWait()
|
||||||
__asm pause;
|
__asm pause;
|
||||||
}
|
}
|
||||||
|
|
||||||
__fi void Threading::StoreFence()
|
|
||||||
{
|
|
||||||
__asm sfence;
|
|
||||||
}
|
|
||||||
|
|
||||||
__fi void Threading::EnableHiresScheduler()
|
__fi void Threading::EnableHiresScheduler()
|
||||||
{
|
{
|
||||||
// This improves accuracy of Sleep() by some amount, and only adds a negligible amount of
|
// This improves accuracy of Sleep() by some amount, and only adds a negligible amount of
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
|
|
||||||
__aligned16 VU_Thread vu1Thread(CpuVU1, VU1);
|
__aligned16 VU_Thread vu1Thread(CpuVU1, VU1);
|
||||||
|
|
||||||
#define volatize(x) (*reinterpret_cast<volatile uint*>(&(x)))
|
|
||||||
#define size_u32(x) (((u32)x+3u)>>2) // Rounds up a size in bytes for size in u32's
|
#define size_u32(x) (((u32)x+3u)>>2) // Rounds up a size in bytes for size in u32's
|
||||||
#define MTVU_ALWAYS_KICK 0
|
#define MTVU_ALWAYS_KICK 0
|
||||||
#define MTVU_SYNC_MODE 0
|
#define MTVU_SYNC_MODE 0
|
||||||
|
|
Loading…
Reference in New Issue