Format the code via clang-format (#1)

This commit is contained in:
Maschell 2022-02-02 19:42:35 +01:00 committed by GitHub
parent 4e29e33931
commit e5ead1af44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 210 additions and 100 deletions

66
.clang-format Normal file
View File

@ -0,0 +1,66 @@
# Generated from CLion C/C++ Code Style settings
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: None
AlignOperands: Align
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Always
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterReturnType: None
AlwaysBreakTemplateDeclarations: Yes
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: true
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
ColumnLimit: 0
CompactNamespaces: false
ContinuationIndentWidth: 8
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 4
KeepEmptyLinesAtTheStartOfBlocks: true
MaxEmptyLinesToKeep: 2
NamespaceIndentation: All
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PointerAlignment: Right
ReflowComments: false
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 0
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
TabWidth: 4
UseTab: Never

View File

@ -6,8 +6,16 @@ on:
- master
jobs:
clang-format:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: clang-format
run: |
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./src
build-binary:
runs-on: ubuntu-18.04
needs: clang-format
steps:
- uses: actions/checkout@v2
- name: build binary

View File

@ -3,8 +3,16 @@ name: CI-PR
on: [pull_request]
jobs:
clang-format:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: clang-format
run: |
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./src
build-binary:
runs-on: ubuntu-18.04
needs: clang-format
steps:
- uses: actions/checkout@v2
- name: build binary

View File

@ -1,3 +1,4 @@
[![CI-Release](https://github.com/wiiu-env/CustomRPXLoader/actions/workflows/ci.yml/badge.svg)](https://github.com/wiiu-env/CustomRPXLoader/actions/workflows/ci.yml)
# CustomRPXLoader
This custom loader for `.rpx` files which can be used with any `payload.elf` loader. (For example [PayloadFromRPX](https://github.com/wiiu-env/PayloadFromRPX) or [JsTypeHax](https://github.com/wiiu-env/JsTypeHax))
@ -23,6 +24,10 @@ docker run -it --rm -v ${PWD}:/project customrpxloader-builder make
docker run -it --rm -v ${PWD}:/project customrpxloader-builder make clean
```
## Format the code via docker
`docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./src -i`
## Credits
- Maschell
- orboditilt

View File

@ -15,11 +15,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#include <cstring>
#include <coreinit/cache.h>
#include <whb/log.h>
#include "utils/logger.h"
#include "ElfUtils.h"
#include "utils/logger.h"
#include <coreinit/cache.h>
#include <cstring>
#include <whb/log.h>
// See https://github.com/decaf-emu/decaf-emu/blob/43366a34e7b55ab9d19b2444aeb0ccd46ac77dea/src/libdecaf/src/cafe/loader/cafe_loader_reloc.cpp#L144
bool ElfUtils::elfLinkOne(char type, size_t offset, int32_t addend, uint32_t destination, uint32_t symbol_addr, relocation_trampolin_entry_t *trampolin_data, uint32_t trampolin_data_length,

View File

@ -17,13 +17,15 @@
#pragma once
#include <cstdint>
#include "common/relocation_defines.h"
#include <cstddef>
#include <cstdint>
#ifdef __cplusplus
extern "C" {
#endif
// clang-format off
#define R_PPC_NONE 0
#define R_PPC_ADDR32 1
#define R_PPC_ADDR16_LO 4
@ -51,6 +53,7 @@ extern "C" {
#define PPC_LOW24 0x03FFFFFC
#define PPC_LOW14 0x0020FFFC
#define PPC_HALF16 0xFFFF
// clang-format on
#ifdef __cplusplus
}

View File

@ -17,13 +17,14 @@
#pragma once
#include <cstdint>
#include <cstddef>
#include <cstdint>
#ifdef __cplusplus
extern "C" {
#endif
// clang-format off
#define DYN_LINK_FUNCTION_NAME_LENGTH 351
#define DYN_LINK_IMPORT_NAME_LENGTH 50
@ -31,6 +32,7 @@ extern "C" {
#define DYN_LINK_IMPORT_LIST_LENGTH 50
#define DYN_LINK_TRAMPOLIN_LIST_LENGTH DYN_LINK_FUNCTION_LIST_LENGTH
// clang-format on
typedef struct _dyn_linking_function_t {
char functionName[DYN_LINK_FUNCTION_NAME_LENGTH + 1];

View File

@ -17,10 +17,10 @@
#pragma once
#include <cstdint>
#include <cstddef>
#include "dynamic_linking_defines.h"
#include "relocation_defines.h"
#include <cstddef>
#include <cstdint>
#ifdef __cplusplus
extern "C" {

View File

@ -19,6 +19,7 @@
#include <cstdint>
// clang-format off
typedef enum RelocationTrampolinStatus {
RELOC_TRAMP_FREE = 0,
RELOC_TRAMP_FIXED = 1,
@ -30,6 +31,7 @@ typedef enum RelocationType{
RELOC_TYPE_FIXED = 0,
RELOC_TYPE_IMPORT = 1
} RelocationType;
// clang-format on
typedef struct relocation_trampolin_entry_t {
uint32_t trampolin[4];

View File

@ -1,5 +1,5 @@
#include <coreinit/dynload.h>
#include <coreinit/debug.h>
#include <coreinit/dynload.h>
#define IMPORT(name) void *addr_##name
#define IMPORT_BEGIN(lib)
@ -11,7 +11,10 @@
#undef IMPORT_BEGIN
#undef IMPORT_END
#define IMPORT(name) do{if(OSDynLoad_FindExport(handle, 0, #name, &addr_##name) < 0)OSFatal("Function " # name " is NULL");} while(0)
#define IMPORT(name) \
do { \
if (OSDynLoad_FindExport(handle, 0, #name, &addr_##name) < 0) OSFatal("Function " #name " is NULL"); \
} while (0)
#define IMPORT_BEGIN(lib) OSDynLoad_Acquire(#lib ".rpl", &handle)
/* #define IMPORT_END() OSDynLoad_Release(handle) */
#define IMPORT_END()

View File

@ -1,3 +1,4 @@
// clang-format off
/*
Copyright (C) 2001-2015 by Serge Lamikhov-Center

View File

@ -1,3 +1,4 @@
// clang-format off
/*
Copyright (C) 2001-2015 by Serge Lamikhov-Center

View File

@ -1,3 +1,4 @@
// clang-format off
/*
Copyright (C) 2001-2015 by Serge Lamikhov-Center

View File

@ -1,3 +1,4 @@
// clang-format off
/*
Copyright (C) 2001-2015 by Serge Lamikhov-Center

View File

@ -1,3 +1,4 @@
// clang-format off
/*
Copyright (C) 2001-2015 by Serge Lamikhov-Center

View File

@ -1,3 +1,4 @@
// clang-format off
/*
Copyright (C) 2001-2015 by Serge Lamikhov-Center

View File

@ -1,3 +1,4 @@
// clang-format off
/*
Copyright (C) 2001-2015 by Serge Lamikhov-Center

View File

@ -1,3 +1,4 @@
// clang-format off
/*
Copyright (C) 2001-2015 by Serge Lamikhov-Center

View File

@ -1,3 +1,4 @@
// clang-format off
/*
Copyright (C) 2001-2015 by Serge Lamikhov-Center

View File

@ -1,3 +1,4 @@
// clang-format off
/*
Copyright (C) 2001-2015 by Serge Lamikhov-Center

View File

@ -1,3 +1,4 @@
// clang-format off
/*
Copyright (C) 2001-2015 by Serge Lamikhov-Center

View File

@ -1,3 +1,4 @@
// clang-format off
/*
Copyright (C) 2001-2015 by Serge Lamikhov-Center

View File

@ -15,11 +15,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#include <coreinit/cache.h>
#include <coreinit/memorymap.h>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <coreinit/cache.h>
#include <coreinit/memorymap.h>
#include "kernel.h"
@ -80,7 +80,6 @@ void doKernelSetup2() {
kern_write((void *) (KERN_SYSCALL_TBL_3 + (0x25 * 4)), (unsigned int) SCKernelCopyData);
kern_write((void *) (KERN_SYSCALL_TBL_4 + (0x25 * 4)), (unsigned int) SCKernelCopyData);
kern_write((void *) (KERN_SYSCALL_TBL_5 + (0x25 * 4)), (unsigned int) SCKernelCopyData);
}
/* Write a 32-bit word with kernel permissions */
@ -101,6 +100,5 @@ void __attribute__ ((noinline)) kern_write(void *addr, uint32_t value) {
:
: "r"(addr), "r"(value)
: "memory", "ctr", "lr", "0", "3", "4", "5", "6", "7", "8", "9", "10",
"11", "12"
);
"11", "12");
}

View File

@ -15,29 +15,29 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#include <cstdint>
#include <coreinit/cache.h>
#include <coreinit/dynload.h>
#include <coreinit/title.h>
#include <sysapp/launch.h>
#include <proc_ui/procui.h>
#include <coreinit/foreground.h>
#include <coreinit/screen.h>
#include <coreinit/title.h>
#include <cstdint>
#include <nn/act/client_cpp.h>
#include <proc_ui/procui.h>
#include <sysapp/launch.h>
#include "ElfUtils.h"
#include "common/module_defines.h"
#include "module/ModuleData.h"
#include "module/ModuleDataFactory.h"
#include "common/module_defines.h"
#include <utils/StringTools.h>
#include "kernel.h"
#include "dynamic.h"
#include "kernel.h"
#include "utils/logger.h"
#include <malloc.h>
#include <coreinit/memexpheap.h>
#include <coreinit/debug.h>
#include <coreinit/memexpheap.h>
#include <malloc.h>
bool doRelocation(const std::vector<RelocationData> &relocData, relocation_trampolin_entry_t *tramp_data, uint32_t tramp_length);
@ -105,7 +105,9 @@ extern "C" int _start(int argc, char **argv) {
__fini_wut();
if (entrypoint > 0) {
// clang-format off
return ((int(*)(int, char **)) entrypoint)(argc, argv);
// clang-format on
}
return -1;
@ -121,7 +123,8 @@ uint32_t do_start(int argc, char **argv) {
uint32_t ApplicationMemoryEnd;
asm volatile("lis %0, __CODE_END@h; ori %0, %0, __CODE_END@l" : "=r" (ApplicationMemoryEnd));
asm volatile("lis %0, __CODE_END@h; ori %0, %0, __CODE_END@l"
: "=r"(ApplicationMemoryEnd));
ApplicationMemoryEnd = (ApplicationMemoryEnd + 0x100) & 0xFFFFFF00;

View File

@ -17,9 +17,9 @@
#pragma once
#include <string>
#include <optional>
#include "utils/logger.h"
#include <optional>
#include <string>
class ImportRPLInformation {

View File

@ -17,9 +17,9 @@
#pragma once
#include "RelocationData.h"
#include <string>
#include <vector>
#include "RelocationData.h"
class ModuleData {
public:

View File

@ -15,13 +15,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
****************************************************************************/
#include "ModuleDataFactory.h"
#include "../ElfUtils.h"
#include "elfio/elfio.hpp"
#include <coreinit/cache.h>
#include <map>
#include <string>
#include <vector>
#include <map>
#include <coreinit/cache.h>
#include "ModuleDataFactory.h"
#include "elfio/elfio.hpp"
#include "../ElfUtils.h"
using namespace ELFIO;

View File

@ -17,12 +17,12 @@
#pragma once
#include "ModuleData.h"
#include "common/relocation_defines.h"
#include "elfio/elfio.hpp"
#include <map>
#include <string>
#include <vector>
#include <map>
#include "common/relocation_defines.h"
#include "ModuleData.h"
#include "elfio/elfio.hpp"
class ModuleDataFactory {
public:

View File

@ -17,8 +17,8 @@
#pragma once
#include <string>
#include "ImportRPLInformation.h"
#include <string>
class RelocationData {

View File

@ -23,17 +23,16 @@
*
* for WiiXplorer 2010
***************************************************************************/
#include <vector>
#include <string>
#include <string.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
#include <wchar.h>
#include <string.h>
#include <string>
#include <strings.h>
#include <wut_types.h>
#include <stdio.h>
#include <utils/StringTools.h>
#include <vector>
#include <wchar.h>
#include <wut_types.h>
BOOL StringTools::EndsWith(const std::string &a, const std::string &b) {

View File

@ -25,8 +25,8 @@
***************************************************************************/
#pragma once
#include <vector>
#include <string>
#include <vector>
#include <wut_types.h>
class StringTools {

View File

@ -1,8 +1,8 @@
#ifdef DEBUG
#include <stdint.h>
#include <whb/log_udp.h>
#include <whb/log_cafe.h>
#include <whb/log_module.h>
#include <whb/log_udp.h>
uint32_t moduleLogInit = false;
uint32_t cafeLogInit = false;

View File

@ -1,7 +1,7 @@
#pragma once
#include <whb/log.h>
#include <string.h>
#include <whb/log.h>
#ifdef __cplusplus
extern "C" {
@ -14,11 +14,13 @@ extern "C" {
#define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while (0)
#define DEBUG_FUNCTION_LINE(FMT, ARGS...)do { \
#define DEBUG_FUNCTION_LINE(FMT, ARGS...) \
do { \
WHBLogPrintf("[%23s]%30s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \
} while (0)
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...)do { \
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) \
do { \
WHBLogWritef("[%23s]%30s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \
} while (0)
@ -39,4 +41,3 @@ void deinitLogging();
#ifdef __cplusplus
}
#endif