From 442e5f2840df79db6cc006f0fe136123e8eacf9f Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Mon, 4 May 2015 19:03:30 -0700 Subject: [PATCH] clang-format --- .../cpu/frontend/test/xe-cpu-ppc-test.cc | 14 +++++++----- src/xenia/kernel/objects/xmodule.cc | 8 ++----- src/xenia/kernel/objects/xmodule.h | 2 +- src/xenia/kernel/objects/xuser_module.cc | 5 ++--- src/xenia/kernel/util/xex2.cc | 22 +++++++++++++------ src/xenia/kernel/util/xex2.h | 8 +++---- src/xenia/kernel/xboxkrnl_modules.cc | 6 ++--- 7 files changed, 36 insertions(+), 29 deletions(-) diff --git a/src/xenia/cpu/frontend/test/xe-cpu-ppc-test.cc b/src/xenia/cpu/frontend/test/xe-cpu-ppc-test.cc index 3b220cf88..f50a95e26 100644 --- a/src/xenia/cpu/frontend/test/xe-cpu-ppc-test.cc +++ b/src/xenia/cpu/frontend/test/xe-cpu-ppc-test.cc @@ -369,14 +369,16 @@ bool DiscoverTests(std::wstring& test_path, #ifdef _MSC_VER int filter(unsigned int code) { - if (code == EXCEPTION_ILLEGAL_INSTRUCTION) + if (code == EXCEPTION_ILLEGAL_INSTRUCTION) { return EXCEPTION_EXECUTE_HANDLER; - + } return EXCEPTION_CONTINUE_SEARCH; } #endif -void ProtectedRunTest(TestSuite &test_suite, TestRunner &runner, TestCase &test_case, int &failed_count, int &passed_count) { +void ProtectedRunTest(TestSuite& test_suite, TestRunner& runner, + TestCase& test_case, int& failed_count, + int& passed_count) { #ifdef _MSC_VER __try { #endif @@ -393,7 +395,8 @@ void ProtectedRunTest(TestSuite &test_suite, TestRunner &runner, TestCase &test_ } #ifdef _MSC_VER - } __except (filter(GetExceptionCode())) { + } + __except(filter(GetExceptionCode())) { XELOGE(" TEST FAILED (UNSUPPORTED INSTRUCTION)"); ++failed_count; } @@ -442,7 +445,8 @@ bool RunTests(const std::wstring& test_name) { for (auto& test_case : test_suite.test_cases) { XELOGI(" - %s", test_case.name.c_str()); TestRunner runner; - ProtectedRunTest(test_suite, runner, test_case, failed_count, passed_count); + ProtectedRunTest(test_suite, runner, test_case, failed_count, + passed_count); } XELOGI(""); diff --git a/src/xenia/kernel/objects/xmodule.cc b/src/xenia/kernel/objects/xmodule.cc index 8cb9c8181..192ae6525 100644 --- a/src/xenia/kernel/objects/xmodule.cc +++ b/src/xenia/kernel/objects/xmodule.cc @@ -29,13 +29,9 @@ XModule::XModule(KernelState* kernel_state, const std::string& path) } } -XModule::~XModule() { - kernel_state_->UnregisterModule(this); -} +XModule::~XModule() { kernel_state_->UnregisterModule(this); } -void XModule::OnLoad() { - kernel_state_->RegisterModule(this); -} +void XModule::OnLoad() { kernel_state_->RegisterModule(this); } X_STATUS XModule::GetSection(const char* name, uint32_t* out_section_data, uint32_t* out_section_size) { diff --git a/src/xenia/kernel/objects/xmodule.h b/src/xenia/kernel/objects/xmodule.h index 225a80987..1fd714aa3 100644 --- a/src/xenia/kernel/objects/xmodule.h +++ b/src/xenia/kernel/objects/xmodule.h @@ -27,7 +27,7 @@ class XModule : public XObject { const std::string& name() const { return name_; } virtual void* GetProcAddressByOrdinal(uint16_t ordinal) = 0; - virtual void* GetProcAddressByName(const char *name) = 0; + virtual void* GetProcAddressByName(const char* name) = 0; virtual X_STATUS GetSection(const char* name, uint32_t* out_section_data, uint32_t* out_section_size); diff --git a/src/xenia/kernel/objects/xuser_module.cc b/src/xenia/kernel/objects/xuser_module.cc index 86ecb025a..71eae83a3 100644 --- a/src/xenia/kernel/objects/xuser_module.cc +++ b/src/xenia/kernel/objects/xuser_module.cc @@ -153,10 +153,9 @@ void* XUserModule::GetProcAddressByName(const char* name) { int ret = xe_xex2_lookup_export(xex_, name, export); // Failure. - if (ret) - return NULL; + if (ret) return NULL; - return (void *)export.addr; + return (void*)export.addr; } X_STATUS XUserModule::GetSection(const char* name, uint32_t* out_section_data, diff --git a/src/xenia/kernel/util/xex2.cc b/src/xenia/kernel/util/xex2.cc index 4c6eefbd1..87b023bba 100644 --- a/src/xenia/kernel/util/xex2.cc +++ b/src/xenia/kernel/util/xex2.cc @@ -989,7 +989,7 @@ int xe_xex2_get_import_infos(xe_xex2_ref xex, } int xe_xex2_lookup_export(xe_xex2_ref xex, const char *name, - PEExport &peexport) { + PEExport &peexport) { auto header = xe_xex2_get_header(xex); // no exports :( @@ -997,15 +997,23 @@ int xe_xex2_lookup_export(xe_xex2_ref xex, const char *name, return 1; } - uint64_t baseaddr = (uint64_t)xex->memory->TranslateVirtual(header->exe_address); - IMAGE_EXPORT_DIRECTORY *e = (PIMAGE_EXPORT_DIRECTORY)(baseaddr + header->export_table_offset); + uint64_t baseaddr = + (uint64_t)xex->memory->TranslateVirtual(header->exe_address); + IMAGE_EXPORT_DIRECTORY *e = + (PIMAGE_EXPORT_DIRECTORY)(baseaddr + header->export_table_offset); // e->AddressOfX RVAs are relative to the IMAGE_EXPORT_DIRECTORY! - uint32_t* function_table = (uint32_t*)((uint64_t)e + e->AddressOfFunctions); // Functions relative to base - uint32_t* name_table = (uint32_t*)((uint64_t)e + e->AddressOfNames); // Names relative to directory - uint16_t* ordinal_table = (uint16_t*)((uint64_t)e + e->AddressOfNameOrdinals); // Table of ordinals + uint32_t *function_table = + (uint32_t *)((uint64_t)e + + e->AddressOfFunctions); // Functions relative to base + uint32_t *name_table = + (uint32_t *)((uint64_t)e + + e->AddressOfNames); // Names relative to directory + uint16_t *ordinal_table = + (uint16_t *)((uint64_t)e + + e->AddressOfNameOrdinals); // Table of ordinals - const char* mod_name = (const char*)((uint64_t)e + e->Name); + const char *mod_name = (const char *)((uint64_t)e + e->Name); for (int i = 0; i < e->NumberOfNames; i++) { const char *fn_name = (const char *)((uint64_t)e + name_table[i]); diff --git a/src/xenia/kernel/util/xex2.h b/src/xenia/kernel/util/xex2.h index dbea70cf5..1d86f6dac 100644 --- a/src/xenia/kernel/util/xex2.h +++ b/src/xenia/kernel/util/xex2.h @@ -44,10 +44,10 @@ class PESection { }; struct PEExport { - const char *name; + const char* name; uint32_t ordinal; - uint64_t addr; // Function address + uint64_t addr; // Function address }; xe_xex2_ref xe_xex2_load(xe::Memory* memory, const void* addr, @@ -62,7 +62,7 @@ int xe_xex2_get_import_infos(xe_xex2_ref xex, xe_xex2_import_info_t** out_import_infos, size_t* out_import_info_count); -int xe_xex2_lookup_export(xe_xex2_ref xex, const char *name, - PEExport &peexport); +int xe_xex2_lookup_export(xe_xex2_ref xex, const char* name, + PEExport& peexport); #endif // XENIA_KERNEL_UTIL_XEX2_H_ diff --git a/src/xenia/kernel/xboxkrnl_modules.cc b/src/xenia/kernel/xboxkrnl_modules.cc index 4351e4f37..c1cc51be3 100644 --- a/src/xenia/kernel/xboxkrnl_modules.cc +++ b/src/xenia/kernel/xboxkrnl_modules.cc @@ -246,15 +246,15 @@ SHIM_CALL XexGetProcedureAddress_shim(PPCContext* ppc_state, KernelState* state) { uint32_t module_handle = SHIM_GET_ARG_32(0); uint32_t ordinal = SHIM_GET_ARG_32(1); - const char *name = (const char *)SHIM_MEM_ADDR(ordinal); + const char* name = (const char*)SHIM_MEM_ADDR(ordinal); uint32_t out_function_ptr = SHIM_GET_ARG_32(2); if (ordinal < 0x10000) { XELOGD("XexGetProcedureAddress(%.8X, %.8X, %.8X)", module_handle, ordinal, out_function_ptr); } else { - XELOGD("XexGetProcedureAddress(%.8X, %.8X(%s), %.8X)", module_handle, ordinal, - name, out_function_ptr); + XELOGD("XexGetProcedureAddress(%.8X, %.8X(%s), %.8X)", module_handle, + ordinal, name, out_function_ptr); } X_STATUS result = X_STATUS_INVALID_HANDLE;