Silly macro removed-3

This commit is contained in:
Nekotekina 2016-08-15 18:30:33 +03:00
parent dbcb5df172
commit 3c82e1a58d
7 changed files with 44 additions and 46 deletions

View file

@ -868,6 +868,16 @@ public:
}
};
enum class not_an_error_t : s32
{
};
template <typename T>
FORCE_INLINE not_an_error_t not_an_error(const T& value)
{
return static_cast<not_an_error_t>(static_cast<s32>(value));
}
template <typename T, typename ID>
struct fmt_unveil<id_value<T, ID>>
{

View file

@ -110,11 +110,8 @@ struct ppu_error_code
{
}
// Helper
enum class not_an_error : s32 {};
// Silence any error
constexpr ppu_error_code(not_an_error value)
constexpr ppu_error_code(not_an_error_t value)
: value(static_cast<s32>(value))
{
}
@ -126,9 +123,6 @@ struct ppu_error_code
}
};
// Helper macro for silencing possible error checks on returning ppu_error_code values
#define NOT_AN_ERROR(...) static_cast<ppu_error_code::not_an_error>(__VA_ARGS__)
template<typename T, typename>
struct ppu_gpr_cast_impl;
@ -142,7 +136,7 @@ struct ppu_gpr_cast_impl<ppu_error_code, void>
static inline ppu_error_code from(const u64 reg)
{
return NOT_AN_ERROR(reg);
return not_an_error(reg);
}
};

View file

@ -288,7 +288,7 @@ ppu_error_code cellFsReadWithOffset(u32 fd, u64 offset, vm::ptr<void> buf, u64 b
// Write size read
if (nread) *nread = rc && rc != CELL_EFSSPECIFIC ? 0 : arg->out_size.value();
return NOT_AN_ERROR(rc ? rc : arg->out_code.value());
return not_an_error(rc ? rc : arg->out_code.value());
}
ppu_error_code cellFsWriteWithOffset(u32 fd, u64 offset, vm::cptr<void> buf, u64 data_size, vm::ptr<u64> nwrite)
@ -323,7 +323,7 @@ ppu_error_code cellFsWriteWithOffset(u32 fd, u64 offset, vm::cptr<void> buf, u64
// Write size written
if (nwrite) *nwrite = rc && rc != CELL_EFSSPECIFIC ? 0 : arg->out_size.value();
return NOT_AN_ERROR(rc ? rc : arg->out_code.value());
return not_an_error(rc ? rc : arg->out_code.value());
}
s32 cellFsStReadInit(u32 fd, vm::cptr<CellFsRingBuffer> ringbuf)

View file

@ -90,7 +90,7 @@ ppu_error_code cellSyncMutexTryLock(vm::ptr<CellSyncMutex> mutex)
if (!mutex->ctrl.atomic_op(_sync::mutex_try_lock))
{
return NOT_AN_ERROR(CELL_SYNC_ERROR_BUSY);
return not_an_error(CELL_SYNC_ERROR_BUSY);
}
return CELL_OK;
@ -181,7 +181,7 @@ ppu_error_code cellSyncBarrierTryNotify(vm::ptr<CellSyncBarrier> barrier)
if (!barrier->ctrl.atomic_op(_sync::barrier::try_notify))
{
return NOT_AN_ERROR(CELL_SYNC_ERROR_BUSY);
return not_an_error(CELL_SYNC_ERROR_BUSY);
}
vm::notify_at(barrier.addr(), 4);
@ -230,7 +230,7 @@ ppu_error_code cellSyncBarrierTryWait(vm::ptr<CellSyncBarrier> barrier)
if (!barrier->ctrl.atomic_op(_sync::barrier::try_wait))
{
return NOT_AN_ERROR(CELL_SYNC_ERROR_BUSY);
return not_an_error(CELL_SYNC_ERROR_BUSY);
}
vm::notify_at(barrier.addr(), 4);
@ -315,7 +315,7 @@ ppu_error_code cellSyncRwmTryRead(vm::ptr<CellSyncRwm> rwm, vm::ptr<void> buffer
// increase `readers` if `writers` is zero
if (!rwm->ctrl.atomic_op(_sync::rwlock::try_read_begin))
{
return NOT_AN_ERROR(CELL_SYNC_ERROR_BUSY);
return not_an_error(CELL_SYNC_ERROR_BUSY);
}
// copy data to buffer
@ -380,7 +380,7 @@ ppu_error_code cellSyncRwmTryWrite(vm::ptr<CellSyncRwm> rwm, vm::cptr<void> buff
// set `writers` to 1 if `readers` and `writers` are zero
if (!rwm->ctrl.compare_and_swap_test({ 0, 0 }, { 0, 1 }))
{
return NOT_AN_ERROR(CELL_SYNC_ERROR_BUSY);
return not_an_error(CELL_SYNC_ERROR_BUSY);
}
// copy data from buffer
@ -480,7 +480,7 @@ ppu_error_code cellSyncQueueTryPush(vm::ptr<CellSyncQueue> queue, vm::cptr<void>
if (!queue->ctrl.atomic_op(_sync::queue::try_push_begin, depth, &position))
{
return NOT_AN_ERROR(CELL_SYNC_ERROR_BUSY);
return not_an_error(CELL_SYNC_ERROR_BUSY);
}
// copy data from the buffer at the position
@ -545,7 +545,7 @@ ppu_error_code cellSyncQueueTryPop(vm::ptr<CellSyncQueue> queue, vm::ptr<void> b
if (!queue->ctrl.atomic_op(_sync::queue::try_pop_begin, depth, &position))
{
return NOT_AN_ERROR(CELL_SYNC_ERROR_BUSY);
return not_an_error(CELL_SYNC_ERROR_BUSY);
}
// copy data at the position to the buffer
@ -610,7 +610,7 @@ ppu_error_code cellSyncQueueTryPeek(vm::ptr<CellSyncQueue> queue, vm::ptr<void>
if (!queue->ctrl.atomic_op(_sync::queue::try_peek_begin, depth, &position))
{
return NOT_AN_ERROR(CELL_SYNC_ERROR_BUSY);
return not_an_error(CELL_SYNC_ERROR_BUSY);
}
// copy data at the position to the buffer
@ -640,7 +640,7 @@ ppu_error_code cellSyncQueueSize(vm::ptr<CellSyncQueue> queue)
const u32 depth = queue->check_depth();
return NOT_AN_ERROR(queue->ctrl.load().count & 0xffffff);
return not_an_error(queue->ctrl.load().count & 0xffffff);
}
ppu_error_code cellSyncQueueClear(vm::ptr<CellSyncQueue> queue)
@ -748,7 +748,7 @@ ppu_error_code cellSyncLFQueueInitialize(vm::ptr<CellSyncLFQueue> queue, vm::cpt
if (s32 ret = process_get_sdk_version(process_getpid(), sdk_ver))
{
return NOT_AN_ERROR(ret);
return not_an_error(ret);
}
if (sdk_ver == -1)
@ -902,7 +902,7 @@ ppu_error_code _cellSyncLFQueueGetPushPointer(ppu_thread& ppu, vm::ptr<CellSyncL
{
if (!push.m_h7 || res)
{
return NOT_AN_ERROR(res);
return not_an_error(res);
}
break;
}
@ -1036,7 +1036,7 @@ ppu_error_code _cellSyncLFQueueCompletePushPointer(ppu_thread& ppu, vm::ptr<Cell
{
verify(HERE), (queue->push3.compare_and_swap_test(old2, push3));
verify(HERE), (fpSendSignal);
return NOT_AN_ERROR(fpSendSignal(ppu, (u32)queue->m_eaSignal.addr(), var6));
return not_an_error(fpSendSignal(ppu, (u32)queue->m_eaSignal.addr(), var6));
}
else
{
@ -1095,7 +1095,7 @@ ppu_error_code _cellSyncLFQueuePushBody(ppu_thread& ppu, vm::ptr<CellSyncLFQueue
if (!isBlocking || res != CELL_SYNC_ERROR_AGAIN)
{
if (res) return NOT_AN_ERROR(res);
if (res) return not_an_error(res);
break;
}
@ -1201,7 +1201,7 @@ ppu_error_code _cellSyncLFQueueGetPopPointer(ppu_thread& ppu, vm::ptr<CellSyncLF
{
if (!pop.m_h3 || res)
{
return NOT_AN_ERROR(res);
return not_an_error(res);
}
break;
}
@ -1335,7 +1335,7 @@ ppu_error_code _cellSyncLFQueueCompletePopPointer(ppu_thread& ppu, vm::ptr<CellS
{
verify(HERE), (queue->pop3.compare_and_swap_test(old2, pop3));
verify(HERE), (fpSendSignal);
return NOT_AN_ERROR(fpSendSignal(ppu, (u32)queue->m_eaSignal.addr(), var6));
return not_an_error(fpSendSignal(ppu, (u32)queue->m_eaSignal.addr(), var6));
}
else
{
@ -1394,7 +1394,7 @@ ppu_error_code _cellSyncLFQueuePopBody(ppu_thread& ppu, vm::ptr<CellSyncLFQueue>
if (!isBlocking || res != CELL_SYNC_ERROR_AGAIN)
{
if (res) return NOT_AN_ERROR(res);
if (res) return not_an_error(res);
break;
}

View file

@ -183,8 +183,8 @@ ppu_error_code cellVideoOutGetNumberOfDevice(u32 videoOut)
switch (videoOut)
{
case CELL_VIDEO_OUT_PRIMARY: return NOT_AN_ERROR(1);
case CELL_VIDEO_OUT_SECONDARY: return NOT_AN_ERROR(0);
case CELL_VIDEO_OUT_PRIMARY: return not_an_error(1);
case CELL_VIDEO_OUT_SECONDARY: return not_an_error(0);
}
return CELL_VIDEO_OUT_ERROR_UNSUPPORTED_VIDEO_OUT;
@ -196,8 +196,8 @@ ppu_error_code cellVideoOutGetResolutionAvailability(u32 videoOut, u32 resolutio
switch (videoOut)
{
case CELL_VIDEO_OUT_PRIMARY: return NOT_AN_ERROR(1);
case CELL_VIDEO_OUT_SECONDARY: return NOT_AN_ERROR(0);
case CELL_VIDEO_OUT_PRIMARY: return not_an_error(1);
case CELL_VIDEO_OUT_SECONDARY: return not_an_error(0);
}
return CELL_VIDEO_OUT_ERROR_UNSUPPORTED_VIDEO_OUT;

View file

@ -179,11 +179,8 @@ struct arm_error_code
{
}
// Helper
enum class not_an_error : s32 {};
// Silence any error
constexpr arm_error_code(not_an_error value)
constexpr arm_error_code(not_an_error_t value)
: value(static_cast<s32>(value))
{
}
@ -195,9 +192,6 @@ struct arm_error_code
}
};
// Helper macro for silencing possible error checks on returning arm_error_code values
#define NOT_AN_ERROR(...) static_cast<arm_error_code::not_an_error>(static_cast<s32>(__VA_ARGS__))
template<typename T, typename>
struct arm_gpr_cast_impl;
@ -211,7 +205,7 @@ struct arm_gpr_cast_impl<arm_error_code, void>
static inline arm_error_code from(const u32 reg)
{
return NOT_AN_ERROR(reg);
return not_an_error(reg);
}
};

View file

@ -98,7 +98,7 @@ arm_error_code sceKernelCreateThread(vm::cptr<char> pName, vm::ptr<SceKernelThre
thread->write_pc(entry.addr(), 0);
thread->TLS = fxm::get<arm_tls_manager>()->alloc();
return NOT_AN_ERROR(thread->id);
return not_an_error(thread->id);
}
arm_error_code sceKernelStartThread(s32 threadId, u32 argSize, vm::cptr<void> pArgBlock)
@ -747,7 +747,7 @@ arm_error_code sceKernelCreateEventFlag(vm::cptr<char> pName, u32 attr, u32 init
}
// Register ID
return NOT_AN_ERROR(idm::import_existing(evf));
return not_an_error(idm::import_existing(evf));
}
arm_error_code sceKernelDeleteEventFlag(s32 evfId)
@ -788,7 +788,7 @@ arm_error_code sceKernelOpenEventFlag(vm::cptr<char> pName)
return SCE_KERNEL_ERROR_UID_CANNOT_FIND_BY_NAME;
}
return NOT_AN_ERROR(idm::import_existing(evf));
return not_an_error(idm::import_existing(evf));
}
arm_error_code sceKernelCloseEventFlag(s32 evfId)
@ -881,7 +881,7 @@ arm_error_code sceKernelWaitEventFlag(ARMv7Thread& cpu, s32 evfId, u32 bitPatter
if (pResultPat) *pResultPat = cpu.GPR[1];
if (pTimeout) *pTimeout = static_cast<u32>(std::max<s64>(0, timeout - (get_system_time() - start_time)));
return NOT_AN_ERROR(cpu.GPR[0]);
return not_an_error(cpu.GPR[0]);
}
arm_error_code sceKernelWaitEventFlagCB(ARMv7Thread& cpu, s32 evfId, u32 bitPattern, u32 waitMode, vm::ptr<u32> pResultPat, vm::ptr<u32> pTimeout)
@ -931,7 +931,7 @@ arm_error_code sceKernelPollEventFlag(ARMv7Thread& cpu, s32 evfId, u32 bitPatter
}
}
return NOT_AN_ERROR(SCE_KERNEL_ERROR_EVENT_COND);
return not_an_error(SCE_KERNEL_ERROR_EVENT_COND);
}
arm_error_code sceKernelSetEventFlag(s32 evfId, u32 bitPattern)
@ -1021,7 +1021,7 @@ arm_error_code sceKernelCreateSema(vm::cptr<char> pName, u32 attr, s32 initCount
{
sceLibKernel.error("sceKernelCreateSema(pName=%s, attr=0x%x, initCount=%d, maxCount=%d, pOptParam=*0x%x)", pName, attr, initCount, maxCount, pOptParam);
return NOT_AN_ERROR(idm::make<psp2_semaphore>(pName.get_ptr(), attr, initCount, maxCount));
return not_an_error(idm::make<psp2_semaphore>(pName.get_ptr(), attr, initCount, maxCount));
}
arm_error_code sceKernelDeleteSema(s32 semaId)
@ -1097,7 +1097,7 @@ arm_error_code sceKernelCreateMutex(vm::cptr<char> pName, u32 attr, s32 initCoun
{
sceLibKernel.error("sceKernelCreateMutex(pName=%s, attr=0x%x, initCount=%d, pOptParam=*0x%x)", pName, attr, initCount, pOptParam);
return NOT_AN_ERROR(idm::make<psp2_mutex>(pName.get_ptr(), attr, initCount));
return not_an_error(idm::make<psp2_mutex>(pName.get_ptr(), attr, initCount));
}
arm_error_code sceKernelDeleteMutex(s32 mutexId)
@ -1211,7 +1211,7 @@ arm_error_code sceKernelCreateCond(vm::cptr<char> pName, u32 attr, s32 mutexId,
return SCE_KERNEL_ERROR_INVALID_UID;
}
return NOT_AN_ERROR(idm::make<psp2_cond>(pName.get_ptr(), attr, mutex));
return not_an_error(idm::make<psp2_cond>(pName.get_ptr(), attr, mutex));
}
arm_error_code sceKernelDeleteCond(s32 condId)