REG_FUNC+ macro improved

This includes REG_FNID, REG_VAR, REG_VNID
Allows to specify alternative function name
This commit is contained in:
Nekotekina 2017-04-26 23:38:24 +03:00
parent f6383f6e06
commit 5f26c2fc8f
4 changed files with 16 additions and 16 deletions

View File

@ -146,7 +146,7 @@ s32 cellVideoOutGetScreenSize(u32 videoOut, vm::ptr<float> screenSize)
DECLARE(ppu_module_manager::cellAvconfExt)("cellSysutilAvconfExt", []() DECLARE(ppu_module_manager::cellAvconfExt)("cellSysutilAvconfExt", []()
{ {
REG_VNID(cellSysutilAvconfExt, 0x00000000, g_gamma).init = [] REG_VNID(cellSysutilAvconfExt, 0x00000000u, g_gamma).init = []
{ {
// Test // Test
*g_gamma = 1.0f; *g_gamma = 1.0f;

View File

@ -995,7 +995,7 @@ s32 cellSaveDataUserGetListItem(u32 userId, vm::cptr<char> dirName, vm::ptr<Cell
void cellSysutil_SaveData_init() void cellSysutil_SaveData_init()
{ {
REG_VNID(cellSysutil, 0x00000000, g_savedata_context); REG_VNID(cellSysutil, 0x00000000u, g_savedata_context);
// libsysutil functions: // libsysutil functions:
REG_FUNC(cellSysutil, cellSaveDataEnableOverlay); REG_FUNC(cellSysutil, cellSaveDataEnableOverlay);

View File

@ -7,20 +7,14 @@ namespace vm { using namespace ps3; }
logs::channel sys_libc("sys_libc", logs::level::notice); logs::channel sys_libc("sys_libc", logs::level::notice);
namespace sys_libc_func void sys_libc_memcpy(vm::ptr<void> dst, vm::cptr<void> src, u32 size)
{ {
void memcpy(vm::ptr<void> dst, vm::cptr<void> src, u32 size) sys_libc.trace("memcpy(dst=*0x%x, src=*0x%x, size=0x%x)", dst, src, size);
{
sys_libc.trace("memcpy(dst=*0x%x, src=*0x%x, size=0x%x)", dst, src, size);
::memcpy(dst.get_ptr(), src.get_ptr(), size); ::memcpy(dst.get_ptr(), src.get_ptr(), size);
}
} }
// Define macro for namespace
#define REG_FUNC_(name) REG_FNID(sys_libc, ppu_generate_id(#name), sys_libc_func::name)
DECLARE(ppu_module_manager::sys_libc)("sys_libc", []() DECLARE(ppu_module_manager::sys_libc)("sys_libc", []()
{ {
REG_FUNC_(memcpy); REG_FNID(sys_libc, "memcpy", sys_libc_memcpy);
}); });

View File

@ -9,6 +9,12 @@
// Generate FNID or VNID for given name // Generate FNID or VNID for given name
extern u32 ppu_generate_id(const char* name); extern u32 ppu_generate_id(const char* name);
// Overload for REG_FNID, REG_VNID macro
constexpr u32 ppu_generate_id(u32 id)
{
return id;
}
// Flags set with REG_FUNC // Flags set with REG_FUNC
enum ppu_static_function_flags : u32 enum ppu_static_function_flags : u32
{ {
@ -220,12 +226,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<decltype(&func), &func>(#func, ppu, __VA_ARGS__) #define CALL_FUNC(ppu, func, ...) ppu_execute_function_or_callback<decltype(&func), &func>(#func, ppu, __VA_ARGS__)
#define REG_FNID(module, nid, func) ppu_module_manager::register_static_function<decltype(&func), &func>(#module, #func, BIND_FUNC(func), nid) #define REG_FNID(module, nid, func) ppu_module_manager::register_static_function<decltype(&func), &func>(#module, #func, BIND_FUNC(func), ppu_generate_id(nid))
#define REG_FUNC(module, func) REG_FNID(module, ppu_generate_id(#func), func) #define REG_FUNC(module, func) REG_FNID(module, #func, func)
#define REG_VNID(module, nid, var) ppu_module_manager::register_static_variable<decltype(var), &var>(#module, #var, nid) #define REG_VNID(module, nid, var) ppu_module_manager::register_static_variable<decltype(var), &var>(#module, #var, ppu_generate_id(nid))
#define REG_VAR(module, var) REG_VNID(module, ppu_generate_id(#var), var) #define REG_VAR(module, var) REG_VNID(module, #var, var)
#define UNIMPLEMENTED_FUNC(module) module.todo("%s", __func__) #define UNIMPLEMENTED_FUNC(module) module.todo("%s", __func__)