From 3c82e1a58dca1df8c81fdc4652ff8b1fd29902fc Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Mon, 15 Aug 2016 18:30:33 +0300 Subject: [PATCH] Silly macro removed-3 --- Utilities/types.h | 10 ++++++++ rpcs3/Emu/Cell/ErrorCodes.h | 10 ++------ rpcs3/Emu/Cell/Modules/cellFs.cpp | 4 ++-- rpcs3/Emu/Cell/Modules/cellSync.cpp | 32 ++++++++++++------------- rpcs3/Emu/Cell/Modules/cellVideoOut.cpp | 8 +++---- rpcs3/Emu/PSP2/ErrorCodes.h | 10 ++------ rpcs3/Emu/PSP2/Modules/sceLibKernel.cpp | 16 ++++++------- 7 files changed, 44 insertions(+), 46 deletions(-) diff --git a/Utilities/types.h b/Utilities/types.h index 8f34744100..d33a8d08db 100644 --- a/Utilities/types.h +++ b/Utilities/types.h @@ -868,6 +868,16 @@ public: } }; +enum class not_an_error_t : s32 +{ +}; + +template +FORCE_INLINE not_an_error_t not_an_error(const T& value) +{ + return static_cast(static_cast(value)); +} + template struct fmt_unveil> { diff --git a/rpcs3/Emu/Cell/ErrorCodes.h b/rpcs3/Emu/Cell/ErrorCodes.h index 15c0698bb8..82b5148fb3 100644 --- a/rpcs3/Emu/Cell/ErrorCodes.h +++ b/rpcs3/Emu/Cell/ErrorCodes.h @@ -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(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(__VA_ARGS__) - template struct ppu_gpr_cast_impl; @@ -142,7 +136,7 @@ struct ppu_gpr_cast_impl static inline ppu_error_code from(const u64 reg) { - return NOT_AN_ERROR(reg); + return not_an_error(reg); } }; diff --git a/rpcs3/Emu/Cell/Modules/cellFs.cpp b/rpcs3/Emu/Cell/Modules/cellFs.cpp index e3ea2a8086..5447a5c89a 100644 --- a/rpcs3/Emu/Cell/Modules/cellFs.cpp +++ b/rpcs3/Emu/Cell/Modules/cellFs.cpp @@ -288,7 +288,7 @@ ppu_error_code cellFsReadWithOffset(u32 fd, u64 offset, vm::ptr 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 buf, u64 data_size, vm::ptr nwrite) @@ -323,7 +323,7 @@ ppu_error_code cellFsWriteWithOffset(u32 fd, u64 offset, vm::cptr 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 ringbuf) diff --git a/rpcs3/Emu/Cell/Modules/cellSync.cpp b/rpcs3/Emu/Cell/Modules/cellSync.cpp index 710fa5639d..ce39bfbc1d 100644 --- a/rpcs3/Emu/Cell/Modules/cellSync.cpp +++ b/rpcs3/Emu/Cell/Modules/cellSync.cpp @@ -90,7 +90,7 @@ ppu_error_code cellSyncMutexTryLock(vm::ptr 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 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 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 rwm, vm::ptr 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 rwm, vm::cptr 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 queue, vm::cptr 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 queue, vm::ptr 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 queue, vm::ptr 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 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 queue) @@ -748,7 +748,7 @@ ppu_error_code cellSyncLFQueueInitialize(vm::ptr 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::ptrpush3.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::ptrpop3.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 if (!isBlocking || res != CELL_SYNC_ERROR_AGAIN) { - if (res) return NOT_AN_ERROR(res); + if (res) return not_an_error(res); break; } diff --git a/rpcs3/Emu/Cell/Modules/cellVideoOut.cpp b/rpcs3/Emu/Cell/Modules/cellVideoOut.cpp index c9ada71a10..b823e24a09 100644 --- a/rpcs3/Emu/Cell/Modules/cellVideoOut.cpp +++ b/rpcs3/Emu/Cell/Modules/cellVideoOut.cpp @@ -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; diff --git a/rpcs3/Emu/PSP2/ErrorCodes.h b/rpcs3/Emu/PSP2/ErrorCodes.h index 924c337b5d..81c5275c06 100644 --- a/rpcs3/Emu/PSP2/ErrorCodes.h +++ b/rpcs3/Emu/PSP2/ErrorCodes.h @@ -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(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(static_cast(__VA_ARGS__)) - template struct arm_gpr_cast_impl; @@ -211,7 +205,7 @@ struct arm_gpr_cast_impl static inline arm_error_code from(const u32 reg) { - return NOT_AN_ERROR(reg); + return not_an_error(reg); } }; diff --git a/rpcs3/Emu/PSP2/Modules/sceLibKernel.cpp b/rpcs3/Emu/PSP2/Modules/sceLibKernel.cpp index 683c64147f..559f0cdd62 100644 --- a/rpcs3/Emu/PSP2/Modules/sceLibKernel.cpp +++ b/rpcs3/Emu/PSP2/Modules/sceLibKernel.cpp @@ -98,7 +98,7 @@ arm_error_code sceKernelCreateThread(vm::cptr pName, vm::ptrwrite_pc(entry.addr(), 0); thread->TLS = fxm::get()->alloc(); - return NOT_AN_ERROR(thread->id); + return not_an_error(thread->id); } arm_error_code sceKernelStartThread(s32 threadId, u32 argSize, vm::cptr pArgBlock) @@ -747,7 +747,7 @@ arm_error_code sceKernelCreateEventFlag(vm::cptr 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 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(std::max(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 pResultPat, vm::ptr 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 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(pName.get_ptr(), attr, initCount, maxCount)); + return not_an_error(idm::make(pName.get_ptr(), attr, initCount, maxCount)); } arm_error_code sceKernelDeleteSema(s32 semaId) @@ -1097,7 +1097,7 @@ arm_error_code sceKernelCreateMutex(vm::cptr 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(pName.get_ptr(), attr, initCount)); + return not_an_error(idm::make(pName.get_ptr(), attr, initCount)); } arm_error_code sceKernelDeleteMutex(s32 mutexId) @@ -1211,7 +1211,7 @@ arm_error_code sceKernelCreateCond(vm::cptr pName, u32 attr, s32 mutexId, return SCE_KERNEL_ERROR_INVALID_UID; } - return NOT_AN_ERROR(idm::make(pName.get_ptr(), attr, mutex)); + return not_an_error(idm::make(pName.get_ptr(), attr, mutex)); } arm_error_code sceKernelDeleteCond(s32 condId)