From 64ac6a59c447b3464be69af0a536cd1082830d76 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Mon, 13 Feb 2017 14:54:58 +0300 Subject: [PATCH] REG_FUNC simplified --- rpcs3/Emu/Cell/Modules/cellAvconfExt.cpp | 4 ++-- rpcs3/Emu/Cell/Modules/cellFs.cpp | 20 ++++++++++---------- rpcs3/Emu/Cell/Modules/cellVideoOut.cpp | 2 +- rpcs3/Emu/Cell/PPUModule.h | 20 ++++++++++++-------- rpcs3/Emu/PSP2/ARMv7Module.h | 16 ++++++++++------ 5 files changed, 35 insertions(+), 27 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellAvconfExt.cpp b/rpcs3/Emu/Cell/Modules/cellAvconfExt.cpp index b2d0f11a7b..abdecbdc6b 100644 --- a/rpcs3/Emu/Cell/Modules/cellAvconfExt.cpp +++ b/rpcs3/Emu/Cell/Modules/cellAvconfExt.cpp @@ -132,11 +132,11 @@ s32 cellVideoOutGetScreenSize(u32 videoOut, vm::ptr screenSize) DECLARE(ppu_module_manager::cellAvconfExt)("cellSysutilAvconfExt", []() { - REG_VNID(cellSysutilAvconfExt, 0x00000000, g_gamma, [] + REG_VNID(cellSysutilAvconfExt, 0x00000000, g_gamma).init = [] { // Test *g_gamma = 1.0f; - }); + }; REG_FUNC(cellSysutilAvconfExt, cellAudioOutUnregisterDevice); REG_FUNC(cellSysutilAvconfExt, cellAudioOutGetDeviceInfo2); diff --git a/rpcs3/Emu/Cell/Modules/cellFs.cpp b/rpcs3/Emu/Cell/Modules/cellFs.cpp index 5342edaf3d..d1039ccef5 100644 --- a/rpcs3/Emu/Cell/Modules/cellFs.cpp +++ b/rpcs3/Emu/Cell/Modules/cellFs.cpp @@ -928,24 +928,24 @@ DECLARE(ppu_module_manager::cellFs)("sys_fs", []() REG_FUNC(sys_fs, cellFsOpen); REG_FUNC(sys_fs, cellFsSdataOpen); REG_FUNC(sys_fs, cellFsSdataOpenByFd); - REG_FUNC(sys_fs, cellFsRead, MFF_PERFECT); - REG_FUNC(sys_fs, cellFsWrite, MFF_PERFECT); - REG_FUNC(sys_fs, cellFsClose, MFF_PERFECT); + REG_FUNC(sys_fs, cellFsRead).flags = MFF_PERFECT; + REG_FUNC(sys_fs, cellFsWrite).flags = MFF_PERFECT; + REG_FUNC(sys_fs, cellFsClose).flags = MFF_PERFECT; REG_FUNC(sys_fs, cellFsOpendir); - REG_FUNC(sys_fs, cellFsReaddir, MFF_PERFECT); - REG_FUNC(sys_fs, cellFsClosedir, MFF_PERFECT); + REG_FUNC(sys_fs, cellFsReaddir).flags = MFF_PERFECT; + REG_FUNC(sys_fs, cellFsClosedir).flags = MFF_PERFECT; REG_FUNC(sys_fs, cellFsStat); - REG_FUNC(sys_fs, cellFsFstat, MFF_PERFECT); + REG_FUNC(sys_fs, cellFsFstat).flags = MFF_PERFECT; REG_FUNC(sys_fs, cellFsMkdir); REG_FUNC(sys_fs, cellFsRename); REG_FUNC(sys_fs, cellFsChmod); REG_FUNC(sys_fs, cellFsFsync); REG_FUNC(sys_fs, cellFsRmdir); REG_FUNC(sys_fs, cellFsUnlink); - REG_FUNC(sys_fs, cellFsLseek, MFF_PERFECT); - REG_FUNC(sys_fs, cellFsFtruncate, MFF_PERFECT); + REG_FUNC(sys_fs, cellFsLseek).flags = MFF_PERFECT; + REG_FUNC(sys_fs, cellFsFtruncate).flags = MFF_PERFECT; REG_FUNC(sys_fs, cellFsTruncate); - REG_FUNC(sys_fs, cellFsFGetBlockSize, MFF_PERFECT); + REG_FUNC(sys_fs, cellFsFGetBlockSize).flags = MFF_PERFECT; REG_FUNC(sys_fs, cellFsAioInit); REG_FUNC(sys_fs, cellFsAioFinish); REG_FUNC(sys_fs, cellFsAioRead); @@ -978,7 +978,7 @@ DECLARE(ppu_module_manager::cellFs)("sys_fs", []() REG_FUNC(sys_fs, cellFsAllocateFileAreaByFdWithInitialData); REG_FUNC(sys_fs, cellFsTruncate2); REG_FUNC(sys_fs, cellFsChangeFileSizeWithoutAllocation); - REG_FUNC(sys_fs, cellFsAllocateFileAreaWithoutZeroFill, MFF_FORCED_HLE); + REG_FUNC(sys_fs, cellFsAllocateFileAreaWithoutZeroFill).flags = MFF_FORCED_HLE; REG_FUNC(sys_fs, cellFsChangeFileSizeByFdWithoutAllocation); REG_FUNC(sys_fs, cellFsSetDiscReadRetrySetting); REG_FUNC(sys_fs, cellFsRegisterConversionCallback); diff --git a/rpcs3/Emu/Cell/Modules/cellVideoOut.cpp b/rpcs3/Emu/Cell/Modules/cellVideoOut.cpp index a701f67083..66f7b8dbb9 100644 --- a/rpcs3/Emu/Cell/Modules/cellVideoOut.cpp +++ b/rpcs3/Emu/Cell/Modules/cellVideoOut.cpp @@ -258,7 +258,7 @@ s32 cellVideoOutUnregisterCallback(u32 slot) void cellSysutil_VideoOut_init() { REG_FUNC(cellSysutil, cellVideoOutGetState); - REG_FUNC(cellSysutil, cellVideoOutGetResolution, MFF_PERFECT); + REG_FUNC(cellSysutil, cellVideoOutGetResolution).flags = MFF_PERFECT; REG_FUNC(cellSysutil, cellVideoOutConfigure); REG_FUNC(cellSysutil, cellVideoOutGetConfiguration); REG_FUNC(cellSysutil, cellVideoOutGetDeviceInfo); diff --git a/rpcs3/Emu/Cell/PPUModule.h b/rpcs3/Emu/Cell/PPUModule.h index 2d12983889..3cf893ef4b 100644 --- a/rpcs3/Emu/Cell/PPUModule.h +++ b/rpcs3/Emu/Cell/PPUModule.h @@ -76,17 +76,19 @@ public: static const ppu_static_module* get_module(const std::string& name); template - static void register_static_function(const char* module, const char* name, ppu_function_t func, u32 fnid, u32 flags) + static auto& register_static_function(const char* module, const char* name, ppu_function_t func, u32 fnid) { auto& info = access_static_function(module, fnid); info.name = name; info.index = ppu_function_manager::register_function(func); - info.flags = flags; + info.flags = 0; + + return info; } template - static void register_static_variable(const char* module, const char* name, u32 vnid, void(*init)()) + static auto& register_static_variable(const char* module, const char* name, u32 vnid) { static_assert(std::is_same>::value, "Static variable registration: vm::gvar expected"); @@ -94,9 +96,11 @@ public: info.name = name; info.var = reinterpret_cast*>(Var); - info.init = init ? init : [] {}; + info.init = [] {}; info.size = SIZE_32(typename T::type); info.align = ALIGN_32(typename T::type); + + return info; } static const ppu_static_module cellAdec; @@ -202,12 +206,12 @@ inline RT ppu_execute_function_or_callback(const char* name, ppu_thread& ppu, Ar #define CALL_FUNC(ppu, func, ...) ppu_execute_function_or_callback(#func, ppu, __VA_ARGS__) -#define REG_FNID(module, nid, func, ...) ppu_module_manager::register_static_function(#module, #func, BIND_FUNC(func), nid, {__VA_ARGS__}) +#define REG_FNID(module, nid, func) ppu_module_manager::register_static_function(#module, #func, BIND_FUNC(func), nid) -#define REG_FUNC(module, func, ...) REG_FNID(module, ppu_generate_id(#func), func, __VA_ARGS__) +#define REG_FUNC(module, func) REG_FNID(module, ppu_generate_id(#func), func) -#define REG_VNID(module, nid, var, ...) ppu_module_manager::register_static_variable(#module, #var, nid, {__VA_ARGS__}) +#define REG_VNID(module, nid, var) ppu_module_manager::register_static_variable(#module, #var, nid) -#define REG_VAR(module, var, ...) REG_VNID(module, ppu_generate_id(#var), var, __VA_ARGS__) +#define REG_VAR(module, var) REG_VNID(module, ppu_generate_id(#var), var) #define UNIMPLEMENTED_FUNC(module) module.todo("%s", __func__) diff --git a/rpcs3/Emu/PSP2/ARMv7Module.h b/rpcs3/Emu/PSP2/ARMv7Module.h index 3a40c3b0ef..52d67f8e4b 100644 --- a/rpcs3/Emu/PSP2/ARMv7Module.h +++ b/rpcs3/Emu/PSP2/ARMv7Module.h @@ -68,17 +68,19 @@ public: static const arm_static_module* get_module(const std::string& name); template - static void register_static_function(const char* module, const char* name, arm_function_t func, u32 fnid, u32 flags) + static auto& register_static_function(const char* module, const char* name, arm_function_t func, u32 fnid) { auto& info = access_static_function(module, fnid); info.name = name; info.index = arm_function_manager::register_function(func); - info.flags = flags; + info.flags = 0; + + return info; } template - static void register_static_variable(const char* module, const char* name, u32 vnid, void(*init)()) + static auto& register_static_variable(const char* module, const char* name, u32 vnid) { static_assert(std::is_same::value, "Static variable registration: vm::gvar expected"); @@ -86,9 +88,11 @@ public: info.name = name; info.var = reinterpret_cast*>(Var); - info.init = init ? init : [] {}; + info.init = [] {}; info.size = SIZE_32(typename T::type); info.align = ALIGN_32(typename T::type); + + return info; } static const arm_static_module SceAppMgr; @@ -163,6 +167,6 @@ public: static const arm_static_module SceVoiceQoS; }; -#define REG_FNID(module, nid, func, ...) arm_module_manager::register_static_function(#module, #func, BIND_FUNC(func), nid, {__VA_ARGS__}) +#define REG_FNID(module, nid, func) arm_module_manager::register_static_function(#module, #func, BIND_FUNC(func), nid) -#define REG_VNID(module, nid, var, ...) arm_module_manager::register_static_variable(#module, #var, nid, {__VA_ARGS__}) +#define REG_VNID(module, nid, var) arm_module_manager::register_static_variable(#module, #var, nid)