mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-15 19:28:43 +12:00
Make buildable with GCC in Linux
* replace GetThreadID with std::this_thread.getId() * name all anonymous structs and unions that contain non-trivially constructable objects * made default constructor for big endian type noexcept to make it work with std::atomic * move instantiated specialized template function members ouside of the class definition to comply with the standard * added default instantiation for template parameter "=nullptr" * used the C++11 standardized thread_local instead of the __declspec(thread) * added transitional definitions to bridge the microsoft specific calls (compare and exchange and aligned alloc) * removed cyclic dependency between Emulator->CPUThreadManager->CPUThread->SMutex->Emulator->... * fixed some instances of indentation by space instead of tabs * surrounded some unused code with an #if 0 block to make sure it doesn't compile
This commit is contained in:
parent
07135570f4
commit
9a30ce5f18
48 changed files with 190 additions and 154 deletions
|
@ -52,9 +52,7 @@ class be_t
|
|||
T m_data;
|
||||
|
||||
public:
|
||||
be_t()
|
||||
{
|
||||
}
|
||||
be_t() noexcept = default;
|
||||
|
||||
be_t(const T& value)
|
||||
{
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#if defined(__GNUG__)
|
||||
#include <math.h>
|
||||
#define _fpclass(x) fpclassify(x)
|
||||
#include <cmath>
|
||||
#define _fpclass(x) std::fpclassify(x)
|
||||
#define __forceinline __attribute__((always_inline))
|
||||
#define _byteswap_ushort(x) __builtin_bswap16(x)
|
||||
#define _byteswap_ulong(x) __builtin_bswap32(x)
|
||||
|
@ -11,4 +11,9 @@
|
|||
#define mkdir(x) mkdir(x, 0777)
|
||||
#define INFINITE 0xFFFFFFFF
|
||||
#define _CRT_ALIGN(x) __attribute__((aligned(x)))
|
||||
#define InterlockedCompareExchange(ptr,new_val,old_val) __sync_val_compare_and_swap(ptr,old_val,new_val)
|
||||
#define InterlockedCompareExchange64(ptr,new_val,old_val) __sync_val_compare_and_swap(ptr,old_val,new_val)
|
||||
#define _aligned_malloc(size,alignment) aligned_alloc(alignment,size)
|
||||
#define _aligned_free(pointer) free(pointer)
|
||||
#define DWORD int64_t
|
||||
#endif
|
||||
|
|
|
@ -96,7 +96,7 @@ public:
|
|||
m_cur_id = s_first_id;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
template<typename T = char>
|
||||
ID_TYPE GetNewID(const std::string& name = "", T* data = nullptr, const u8 attr = 0)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m_mtx_main);
|
||||
|
@ -155,4 +155,4 @@ public:
|
|||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
@ -95,4 +95,4 @@ public:
|
|||
|
||||
wxDialog::Close(force);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
|
@ -6,9 +6,9 @@ __forceinline void SM_Sleep()
|
|||
Sleep(1);
|
||||
}
|
||||
|
||||
__forceinline DWORD SM_GetCurrentThreadId()
|
||||
__forceinline std::thread::id SM_GetCurrentThreadId()
|
||||
{
|
||||
return GetCurrentThreadId();
|
||||
return std::this_thread::get_id();
|
||||
}
|
||||
|
||||
__forceinline u32 SM_GetCurrentCPUThreadId()
|
||||
|
@ -23,4 +23,4 @@ __forceinline u32 SM_GetCurrentCPUThreadId()
|
|||
__forceinline be_t<u32> SM_GetCurrentCPUThreadIdBE()
|
||||
{
|
||||
return SM_GetCurrentCPUThreadId();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
extern void SM_Sleep();
|
||||
extern DWORD SM_GetCurrentThreadId();
|
||||
extern std::thread::id SM_GetCurrentThreadId();
|
||||
extern u32 SM_GetCurrentCPUThreadId();
|
||||
extern be_t<u32> SM_GetCurrentCPUThreadIdBE();
|
||||
|
||||
|
@ -22,7 +22,7 @@ template
|
|||
typename T,
|
||||
u32 free_value = 0,
|
||||
u32 dead_value = ~0,
|
||||
void (wait)() = SM_Sleep
|
||||
void (*wait)() = SM_Sleep
|
||||
>
|
||||
class SMutexBase
|
||||
{
|
||||
|
@ -149,9 +149,9 @@ typedef SMutexBase<u32>
|
|||
typedef SMutexBase<be_t<u32>>
|
||||
SMutexBE;
|
||||
|
||||
typedef SMutexLockerBase<DWORD, SM_GetCurrentThreadId>
|
||||
typedef SMutexLockerBase<std::thread::id, SM_GetCurrentThreadId>
|
||||
SMutexGeneralLocker;
|
||||
typedef SMutexLockerBase<u32, SM_GetCurrentCPUThreadId>
|
||||
SMutexLocker;
|
||||
typedef SMutexLockerBase<be_t<u32>, SM_GetCurrentCPUThreadIdBE>
|
||||
SMutexBELocker;
|
||||
SMutexBELocker;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "stdafx.h"
|
||||
#include "Thread.h"
|
||||
|
||||
__declspec(thread) NamedThreadBase* g_tls_this_thread = nullptr;
|
||||
/*__declspec(thread)*/ thread_local NamedThreadBase* g_tls_this_thread = nullptr;
|
||||
|
||||
NamedThreadBase* GetCurrentNamedThread()
|
||||
{
|
||||
|
@ -124,7 +124,7 @@ void thread::start(std::function<void()> func)
|
|||
catch(...)
|
||||
{
|
||||
ConLog.Error("Crash :(");
|
||||
terminate();
|
||||
std::terminate();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -142,4 +142,4 @@ void thread::join()
|
|||
bool thread::joinable() const
|
||||
{
|
||||
return m_thr.joinable();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,7 +141,7 @@ class StepThread : public ThreadBase
|
|||
volatile bool m_exit;
|
||||
|
||||
protected:
|
||||
StepThread(const wxString& name = "Unknown StepThread")
|
||||
StepThread(const std::string& name = "Unknown StepThread")
|
||||
: ThreadBase(true, name)
|
||||
, m_exit(false)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue