mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-04 05:51:27 +12:00
make things compile under windows again, there's still some ugly ifdefs
I'd like to get rid of
This commit is contained in:
parent
92fb77d50e
commit
1908286e7c
11 changed files with 97 additions and 95 deletions
|
@ -50,7 +50,10 @@ class be_t
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef T type;
|
typedef T type;
|
||||||
be_t() noexcept = default;
|
#ifdef __GNUG__
|
||||||
|
be_t() noexcept = default
|
||||||
|
#endif
|
||||||
|
be_t(){}
|
||||||
|
|
||||||
be_t(const T& value)
|
be_t(const T& value)
|
||||||
{
|
{
|
||||||
|
|
|
@ -96,7 +96,11 @@ public:
|
||||||
m_cur_id = s_first_id;
|
m_cur_id = s_first_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T = char>
|
template<typename T
|
||||||
|
#ifdef __GNUG__
|
||||||
|
= char
|
||||||
|
#endif
|
||||||
|
>
|
||||||
ID_TYPE GetNewID(const std::string& name = "", T* data = nullptr, const u32 attr = 0)
|
ID_TYPE GetNewID(const std::string& name = "", T* data = nullptr, const u32 attr = 0)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(m_mtx_main);
|
std::lock_guard<std::mutex> lock(m_mtx_main);
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "Thread.h"
|
#include "Thread.h"
|
||||||
|
|
||||||
/*__declspec(thread)*/ thread_local NamedThreadBase* g_tls_this_thread = nullptr;
|
#ifdef _WIN32
|
||||||
|
__declspec(thread)
|
||||||
|
#else
|
||||||
|
thread_local
|
||||||
|
#endif
|
||||||
|
NamedThreadBase* g_tls_this_thread = nullptr;
|
||||||
|
|
||||||
NamedThreadBase* GetCurrentNamedThread()
|
NamedThreadBase* GetCurrentNamedThread()
|
||||||
{
|
{
|
||||||
|
|
|
@ -524,16 +524,16 @@ struct CellAdecParamM4Aac
|
||||||
be_t<MPEG4AAC_ConfigType> configNumber;
|
be_t<MPEG4AAC_ConfigType> configNumber;
|
||||||
|
|
||||||
union {
|
union {
|
||||||
struct
|
struct { struct
|
||||||
{
|
{
|
||||||
be_t<u32> adifProgramNumber; // 0
|
be_t<u32> adifProgramNumber; // 0
|
||||||
} adifConfig;
|
} adifConfig; };
|
||||||
|
|
||||||
struct
|
struct { struct
|
||||||
{
|
{
|
||||||
be_t<MPEG4AAC_SamplingFreq> samplingFreqIndex;
|
be_t<MPEG4AAC_SamplingFreq> samplingFreqIndex;
|
||||||
be_t<u32> profile; // LC profile (1)
|
be_t<u32> profile; // LC profile (1)
|
||||||
} rawDataBlockConfig;
|
} rawDataBlockConfig; };
|
||||||
} configInfo;
|
} configInfo;
|
||||||
|
|
||||||
be_t<u32> enableDownmix; // enable downmix to 2.0 (if (enableDownmix))
|
be_t<u32> enableDownmix; // enable downmix to 2.0 (if (enableDownmix))
|
||||||
|
@ -557,6 +557,7 @@ struct CellAdecM4AacInfo
|
||||||
be_t<u32> pad1; // TODO: check alignment
|
be_t<u32> pad1; // TODO: check alignment
|
||||||
|
|
||||||
union {
|
union {
|
||||||
|
struct {
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
be_t<u32> copyrightIdPresent;
|
be_t<u32> copyrightIdPresent;
|
||||||
|
@ -568,7 +569,9 @@ struct CellAdecM4AacInfo
|
||||||
be_t<u32> numberOfProgramConfigElements;
|
be_t<u32> numberOfProgramConfigElements;
|
||||||
be_t<u32> bufferFullness;
|
be_t<u32> bufferFullness;
|
||||||
} adif;
|
} adif;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct {
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
be_t<u32> id;
|
be_t<u32> id;
|
||||||
|
@ -587,6 +590,7 @@ struct CellAdecM4AacInfo
|
||||||
be_t<u32> numberOfRawDataBlocks;
|
be_t<u32> numberOfRawDataBlocks;
|
||||||
be_t<u32> crcCheck;
|
be_t<u32> crcCheck;
|
||||||
} adts;
|
} adts;
|
||||||
|
};
|
||||||
} bsi;
|
} bsi;
|
||||||
|
|
||||||
be_t<u32> pad2; // TODO: check alignment
|
be_t<u32> pad2; // TODO: check alignment
|
||||||
|
|
|
@ -96,20 +96,7 @@ struct CellDmuxResource2
|
||||||
be_t<u32> memSize;
|
be_t<u32> memSize;
|
||||||
be_t<u32> ppuThreadPriority;
|
be_t<u32> ppuThreadPriority;
|
||||||
be_t<u32> ppuThreadStackSize;
|
be_t<u32> ppuThreadStackSize;
|
||||||
union cell_info
|
be_t<u32> shit[4];
|
||||||
{
|
|
||||||
struct spu_info
|
|
||||||
{
|
|
||||||
be_t<u32> noex_spuThreadPriority;
|
|
||||||
be_t<u32> noex_numOfSpus;
|
|
||||||
}spu_inf;
|
|
||||||
struct spurs_info
|
|
||||||
{
|
|
||||||
be_t<u32> ex_spurs_addr;
|
|
||||||
u8 ex_priority[8];
|
|
||||||
be_t<u32> ex_maxContention;
|
|
||||||
}spurs_inf;
|
|
||||||
}cell_inf;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct CellDmuxCb
|
struct CellDmuxCb
|
||||||
|
|
|
@ -24,12 +24,12 @@ enum
|
||||||
};
|
};
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
union CellSyncMutex {
|
struct CellSyncMutex {
|
||||||
struct cell_sync_mutex_info{
|
|
||||||
be_t<u16> m_freed;
|
be_t<u16> m_freed;
|
||||||
be_t<u16> m_order;
|
be_t<u16> m_order;
|
||||||
}parts;
|
volatile u32& m_data(){
|
||||||
volatile u32 m_data;
|
return *reinterpret_cast<u32*>(this);
|
||||||
|
};
|
||||||
/*
|
/*
|
||||||
(???) Initialize: set zeros
|
(???) Initialize: set zeros
|
||||||
(???) Lock: increase m_order and wait until m_freed == old m_order
|
(???) Lock: increase m_order and wait until m_freed == old m_order
|
||||||
|
@ -59,7 +59,7 @@ int cellSyncMutexInitialize(mem_ptr_t<CellSyncMutex> mutex)
|
||||||
{
|
{
|
||||||
reservation.clear();
|
reservation.clear();
|
||||||
}
|
}
|
||||||
mutex->m_data = 0;
|
mutex->m_data() = 0;
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,9 +85,9 @@ int cellSyncMutexLock(mem_ptr_t<CellSyncMutex> mutex)
|
||||||
{
|
{
|
||||||
reservation.clear();
|
reservation.clear();
|
||||||
}
|
}
|
||||||
old_order = mutex->parts.m_order;
|
old_order = mutex->m_order;
|
||||||
mutex->parts.m_order = mutex->parts.m_order + 1;
|
mutex->m_order = mutex->m_order + 1;
|
||||||
if (old_order == mutex->parts.m_freed)
|
if (old_order == mutex->m_freed)
|
||||||
{
|
{
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
@ -125,11 +125,11 @@ int cellSyncMutexTryLock(mem_ptr_t<CellSyncMutex> mutex)
|
||||||
{
|
{
|
||||||
reservation.clear();
|
reservation.clear();
|
||||||
}
|
}
|
||||||
if (mutex->parts.m_order != mutex->parts.m_freed)
|
if (mutex->m_order != mutex->m_freed)
|
||||||
{
|
{
|
||||||
return CELL_SYNC_ERROR_BUSY;
|
return CELL_SYNC_ERROR_BUSY;
|
||||||
}
|
}
|
||||||
mutex->parts.m_order = mutex->parts.m_order + 1;
|
mutex->m_order = mutex->m_order + 1;
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,7 @@ int cellSyncMutexUnlock(mem_ptr_t<CellSyncMutex> mutex)
|
||||||
{
|
{
|
||||||
reservation.clear();
|
reservation.clear();
|
||||||
}
|
}
|
||||||
mutex->parts.m_freed = mutex->parts.m_freed + 1;
|
mutex->m_freed = mutex->m_freed + 1;
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,11 +86,11 @@ int sys_lwcond_signal(mem_ptr_t<sys_lwcond_t> lwcond)
|
||||||
|
|
||||||
if (be_t<u32> target = (mutex->attribute.ToBE() == se32(SYS_SYNC_PRIORITY) ? sq->pop_prio() : sq->pop()))
|
if (be_t<u32> target = (mutex->attribute.ToBE() == se32(SYS_SYNC_PRIORITY) ? sq->pop_prio() : sq->pop()))
|
||||||
{
|
{
|
||||||
if (mutex->vars.parts.owner.trylock(target) != SMR_OK)
|
if (mutex->mutex.owner.trylock(target) != SMR_OK)
|
||||||
{
|
{
|
||||||
mutex->vars.parts.owner.lock(tid);
|
mutex->mutex.owner.lock(tid);
|
||||||
mutex->recursive_count = 1;
|
mutex->recursive_count = 1;
|
||||||
mutex->vars.parts.owner.unlock(tid, target);
|
mutex->mutex.owner.unlock(tid, target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,11 +122,11 @@ int sys_lwcond_signal_all(mem_ptr_t<sys_lwcond_t> lwcond)
|
||||||
|
|
||||||
while (be_t<u32> target = (mutex->attribute.ToBE() == se32(SYS_SYNC_PRIORITY) ? sq->pop_prio() : sq->pop()))
|
while (be_t<u32> target = (mutex->attribute.ToBE() == se32(SYS_SYNC_PRIORITY) ? sq->pop_prio() : sq->pop()))
|
||||||
{
|
{
|
||||||
if (mutex->vars.parts.owner.trylock(target) != SMR_OK)
|
if (mutex->mutex.owner.trylock(target) != SMR_OK)
|
||||||
{
|
{
|
||||||
mutex->vars.parts.owner.lock(tid);
|
mutex->mutex.owner.lock(tid);
|
||||||
mutex->recursive_count = 1;
|
mutex->recursive_count = 1;
|
||||||
mutex->vars.parts.owner.unlock(tid, target);
|
mutex->mutex.owner.unlock(tid, target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,11 +163,11 @@ int sys_lwcond_signal_to(mem_ptr_t<sys_lwcond_t> lwcond, u32 ppu_thread_id)
|
||||||
|
|
||||||
be_t<u32> target = ppu_thread_id;
|
be_t<u32> target = ppu_thread_id;
|
||||||
|
|
||||||
if (mutex->vars.parts.owner.trylock(target) != SMR_OK)
|
if (mutex->mutex.owner.trylock(target) != SMR_OK)
|
||||||
{
|
{
|
||||||
mutex->vars.parts.owner.lock(tid);
|
mutex->mutex.owner.lock(tid);
|
||||||
mutex->recursive_count = 1;
|
mutex->recursive_count = 1;
|
||||||
mutex->vars.parts.owner.unlock(tid, target);
|
mutex->mutex.owner.unlock(tid, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Emu.IsStopped())
|
if (Emu.IsStopped())
|
||||||
|
@ -197,7 +197,7 @@ int sys_lwcond_wait(mem_ptr_t<sys_lwcond_t> lwcond, u64 timeout)
|
||||||
u32 tid_le = GetCurrentPPUThread().GetId();
|
u32 tid_le = GetCurrentPPUThread().GetId();
|
||||||
be_t<u32> tid = tid_le;
|
be_t<u32> tid = tid_le;
|
||||||
|
|
||||||
if (mutex->vars.parts.owner.GetOwner() != tid)
|
if (mutex->mutex.owner.GetOwner() != tid)
|
||||||
{
|
{
|
||||||
return CELL_EPERM; // caller must own this lwmutex
|
return CELL_EPERM; // caller must own this lwmutex
|
||||||
}
|
}
|
||||||
|
@ -205,7 +205,7 @@ int sys_lwcond_wait(mem_ptr_t<sys_lwcond_t> lwcond, u64 timeout)
|
||||||
sq->push(tid_le);
|
sq->push(tid_le);
|
||||||
|
|
||||||
mutex->recursive_count = 0;
|
mutex->recursive_count = 0;
|
||||||
mutex->vars.parts.owner.unlock(tid);
|
mutex->mutex.owner.unlock(tid);
|
||||||
|
|
||||||
u32 counter = 0;
|
u32 counter = 0;
|
||||||
const u32 max_counter = timeout ? (timeout / 1000) : ~0;
|
const u32 max_counter = timeout ? (timeout / 1000) : ~0;
|
||||||
|
@ -216,7 +216,7 @@ int sys_lwcond_wait(mem_ptr_t<sys_lwcond_t> lwcond, u64 timeout)
|
||||||
case SMR_OK: mutex->unlock(tid); break;
|
case SMR_OK: mutex->unlock(tid); break;
|
||||||
case SMR_SIGNAL: return CELL_OK;
|
case SMR_SIGNAL: return CELL_OK;
|
||||||
} */
|
} */
|
||||||
if (mutex->vars.parts.owner.GetOwner() == tid)
|
if (mutex->mutex.owner.GetOwner() == tid)
|
||||||
{
|
{
|
||||||
_mm_mfence();
|
_mm_mfence();
|
||||||
mutex->recursive_count = 1;
|
mutex->recursive_count = 1;
|
||||||
|
|
|
@ -28,9 +28,9 @@ int sys_lwmutex_create(mem_ptr_t<sys_lwmutex_t> lwmutex, mem_ptr_t<sys_lwmutex_a
|
||||||
}
|
}
|
||||||
|
|
||||||
lwmutex->attribute = attr->attr_protocol | attr->attr_recursive;
|
lwmutex->attribute = attr->attr_protocol | attr->attr_recursive;
|
||||||
lwmutex->vars.all_info = 0;
|
lwmutex->mutex.all_info() = 0;
|
||||||
lwmutex->vars.all_info = 0;
|
lwmutex->mutex.all_info() = 0;
|
||||||
lwmutex->vars.parts.owner.initialize();
|
lwmutex->mutex.owner.initialize();
|
||||||
//lwmutex->waiter = lwmutex->owner.GetOwner();
|
//lwmutex->waiter = lwmutex->owner.GetOwner();
|
||||||
lwmutex->pad = 0;
|
lwmutex->pad = 0;
|
||||||
lwmutex->recursive_count = 0;
|
lwmutex->recursive_count = 0;
|
||||||
|
@ -54,10 +54,10 @@ int sys_lwmutex_destroy(mem_ptr_t<sys_lwmutex_t> lwmutex)
|
||||||
if (!Emu.GetIdManager().CheckID(sq_id)) return CELL_ESRCH;
|
if (!Emu.GetIdManager().CheckID(sq_id)) return CELL_ESRCH;
|
||||||
|
|
||||||
// try to make it unable to lock
|
// try to make it unable to lock
|
||||||
switch (int res = lwmutex->trylock(lwmutex->vars.parts.owner.GetDeadValue()))
|
switch (int res = lwmutex->trylock(lwmutex->mutex.owner.GetDeadValue()))
|
||||||
{
|
{
|
||||||
case CELL_OK:
|
case CELL_OK:
|
||||||
lwmutex->vars.all_info = 0;
|
lwmutex->mutex.all_info() = 0;
|
||||||
lwmutex->attribute = 0;
|
lwmutex->attribute = 0;
|
||||||
lwmutex->sleep_queue = 0;
|
lwmutex->sleep_queue = 0;
|
||||||
Emu.GetIdManager().RemoveID(sq_id);
|
Emu.GetIdManager().RemoveID(sq_id);
|
||||||
|
@ -208,7 +208,7 @@ int sys_lwmutex_t::trylock(be_t<u32> tid)
|
||||||
{
|
{
|
||||||
if (!attribute.ToBE()) return CELL_EINVAL;
|
if (!attribute.ToBE()) return CELL_EINVAL;
|
||||||
|
|
||||||
if (tid == vars.parts.owner.GetOwner())
|
if (tid == mutex.owner.GetOwner())
|
||||||
{
|
{
|
||||||
if (attribute.ToBE() & se32(SYS_SYNC_RECURSIVE))
|
if (attribute.ToBE() & se32(SYS_SYNC_RECURSIVE))
|
||||||
{
|
{
|
||||||
|
@ -222,7 +222,7 @@ int sys_lwmutex_t::trylock(be_t<u32> tid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (vars.parts.owner.trylock(tid))
|
switch (mutex.owner.trylock(tid))
|
||||||
{
|
{
|
||||||
case SMR_OK: recursive_count = 1; return CELL_OK;
|
case SMR_OK: recursive_count = 1; return CELL_OK;
|
||||||
case SMR_FAILED: return CELL_EBUSY;
|
case SMR_FAILED: return CELL_EBUSY;
|
||||||
|
@ -232,7 +232,7 @@ int sys_lwmutex_t::trylock(be_t<u32> tid)
|
||||||
|
|
||||||
int sys_lwmutex_t::unlock(be_t<u32> tid)
|
int sys_lwmutex_t::unlock(be_t<u32> tid)
|
||||||
{
|
{
|
||||||
if (tid != vars.parts.owner.GetOwner())
|
if (tid != mutex.owner.GetOwner())
|
||||||
{
|
{
|
||||||
return CELL_EPERM;
|
return CELL_EPERM;
|
||||||
}
|
}
|
||||||
|
@ -251,8 +251,8 @@ int sys_lwmutex_t::unlock(be_t<u32> tid)
|
||||||
target = attribute.ToBE() & se32(SYS_SYNC_FIFO) ? sq->pop() : sq->pop_prio();
|
target = attribute.ToBE() & se32(SYS_SYNC_FIFO) ? sq->pop() : sq->pop_prio();
|
||||||
case se32(SYS_SYNC_RETRY): break;
|
case se32(SYS_SYNC_RETRY): break;
|
||||||
}
|
}
|
||||||
if (target) vars.parts.owner.unlock(tid, target);
|
if (target) mutex.owner.unlock(tid, target);
|
||||||
else vars.parts.owner.unlock(tid);
|
else mutex.owner.unlock(tid);
|
||||||
}
|
}
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
@ -277,7 +277,7 @@ int sys_lwmutex_t::lock(be_t<u32> tid, u64 timeout)
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (vars.parts.owner.lock(tid, timeout))
|
switch (mutex.owner.lock(tid, timeout))
|
||||||
{
|
{
|
||||||
case SMR_OK:
|
case SMR_OK:
|
||||||
sq->invalidate(tid);
|
sq->invalidate(tid);
|
||||||
|
|
|
@ -64,16 +64,14 @@ struct SleepQueue
|
||||||
};
|
};
|
||||||
|
|
||||||
struct sys_lwmutex_t
|
struct sys_lwmutex_t
|
||||||
{
|
|
||||||
union sys_lwmutex_variable_t
|
|
||||||
{
|
{
|
||||||
struct sys_lwmutex_lock_info_t
|
struct sys_lwmutex_lock_info_t
|
||||||
{
|
{
|
||||||
/* volatile */ SMutexBase<be_t<u32>, 0xffffffff, 0> owner;
|
/* volatile */ SMutexBase<be_t<u32>, 0xffffffff, 0> owner;
|
||||||
/* volatile */ be_t<u32> waiter; // not used
|
/* volatile */ be_t<u32> waiter; // not used
|
||||||
}parts;
|
u64 &all_info(){return *(reinterpret_cast<u64*>(this));
|
||||||
/* volatile */ be_t<u64> all_info;
|
}
|
||||||
}vars;
|
}mutex;
|
||||||
be_t<u32> attribute;
|
be_t<u32> attribute;
|
||||||
be_t<u32> recursive_count;
|
be_t<u32> recursive_count;
|
||||||
be_t<u32> sleep_queue;
|
be_t<u32> sleep_queue;
|
||||||
|
|
|
@ -28,6 +28,7 @@ Emulator::Emulator()
|
||||||
, m_dbg_console(nullptr)
|
, m_dbg_console(nullptr)
|
||||||
, m_rsx_callback(0)
|
, m_rsx_callback(0)
|
||||||
, m_ppu_callback_thr(0)
|
, m_ppu_callback_thr(0)
|
||||||
|
, m_event_manager(new EventManager())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ class Emulator
|
||||||
AudioManager m_audio_manager;
|
AudioManager m_audio_manager;
|
||||||
CallbackManager m_callback_manager;
|
CallbackManager m_callback_manager;
|
||||||
CPUThread* m_ppu_callback_thr;
|
CPUThread* m_ppu_callback_thr;
|
||||||
EventManager &m_event_manager;
|
std::unique_ptr<EventManager> m_event_manager;
|
||||||
|
|
||||||
VFS m_vfs;
|
VFS m_vfs;
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ public:
|
||||||
Array<u64>& GetBreakPoints() { return m_break_points; }
|
Array<u64>& GetBreakPoints() { return m_break_points; }
|
||||||
Array<u64>& GetMarkedPoints() { return m_marked_points; }
|
Array<u64>& GetMarkedPoints() { return m_marked_points; }
|
||||||
CPUThread& GetCallbackThread() { return *m_ppu_callback_thr; }
|
CPUThread& GetCallbackThread() { return *m_ppu_callback_thr; }
|
||||||
EventManager& GetEventManager() { return m_event_manager; }
|
EventManager& GetEventManager() { return *m_event_manager; }
|
||||||
|
|
||||||
void AddModuleInit(ModuleInitializer* m)
|
void AddModuleInit(ModuleInitializer* m)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue