Format the code via clang-format

This commit is contained in:
Maschell 2022-02-04 22:24:22 +01:00
parent c7b9039dae
commit fdf9993069
16 changed files with 341 additions and 147 deletions

67
.clang-format Normal file
View File

@ -0,0 +1,67 @@
# Generated from CLion C/C++ Code Style settings
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: Consecutive
AlignConsecutiveMacros: AcrossEmptyLinesAndComments
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: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
TabWidth: 4
UseTab: Never

25
.github/workflows/pr.yml vendored Normal file
View File

@ -0,0 +1,25 @@
name: CI-PR
on: [pull_request]
jobs:
clang-format-lib:
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 ./include ./libraries
build-lib:
runs-on: ubuntu-18.04
needs: clang-format-lib
steps:
- uses: actions/checkout@v2
- name: build binary
run: |
docker build . -f Dockerfile.buildlocal -t builder
docker run --rm -v ${PWD}:/project builder make
- uses: actions/upload-artifact@master
with:
name: binary
path: "/lib/*.a"

View File

@ -4,8 +4,25 @@ on:
branches: branches:
- master - master
jobs: jobs:
build: clang-format-lib:
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 ./include ./libraries
build-lib:
runs-on: ubuntu-18.04
needs: clang-format-lib
steps:
- uses: actions/checkout@v2
- name: build binary
run: |
docker build . -f Dockerfile.buildlocal -t builder
docker run --rm -v ${PWD}:/project builder make
push_image:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: build-lib
steps: steps:
- uses: actions/checkout@master - uses: actions/checkout@master
- name: Get release version - name: Get release version

View File

@ -1,4 +1,4 @@
FROM wiiuenv/devkitppc:20210920 FROM wiiuenv/devkitppc:20211229
WORKDIR build WORKDIR build
COPY . . COPY . .

3
Dockerfile.buildlocal Normal file
View File

@ -0,0 +1,3 @@
FROM wiiuenv/devkitppc:20211229
WORKDIR project

80
README.MD Normal file
View File

@ -0,0 +1,80 @@
[![Publish Docker Image](https://github.com/wiiu-env/WiiUModuleSystem/actions/workflows/push_image.yml/badge.svg)](https://github.com/wiiu-env/WiiUModuleSystem/actions/workflows/push_image.yml)
# Wii U Module System
This lib is required to build Modules to be loaded with the [Wii U Module System Loader](https://github.com/wiiu-env/WUMSLoader).
## Usage
A module needs to implements at least the following macros.
```C++
#include <wums.h>
WUMS_MODULE_EXPORT_NAME("homebrew_modulename");
WUMS_INITIALIZE() {
/** THIS CODE WILL BE RUN ONCE **/
}
```
The `WUMS_MODULE_EXPORT_NAME` needs to be a globally unique name across all loaded modules. `WUMS_INITIALIZE` defines the code that will be run after the module was loaded.
The module will have full permission to the sd card via `fs:/vol/external01`.
### Optional macros/hooks
Other optional macros/hooks are support, here some examples:
```C++
WUMS_APPLICATION_STARTS() {
/** Is called when a new application was started. **/
}
WUMS_APPLICATION_REQUESTS_EXIT() {
/** Is called when a new application is going to be closed. **/
}
```
This list is incomplete, see `hooks.h` for all hooks and `meta.h` for all macros.
### Export functions
Modules can be used to export functions for other modules or "normal" applications.
```C++
#include <wums.h>
void MyCustomFunction() {
/** Some special code that should be useable for everyone */
}
WUMS_EXPORT_FUNCTION(MyCustomFunction);
```
This function can then be used like they would be inside a .rpl, where the name of the "rpl" is the one defined in `WUMS_MODULE_EXPORT_NAME`.
Example using the Cafe OS OSDynLoad API:
```C++
if (OSDynLoad_Acquire("homebrew_modulename", &sModuleHandle) != OS_DYNLOAD_OK) {
OSFatal("OSDynLoad_Acquire failed.");
}
void (*sMyCustomFunction)() = NULL;
if (OSDynLoad_FindExport(sModuleHandle, FALSE, "MyCustomFunction", (void**) &sMyCustomFunction) != OS_DYNLOAD_OK) {
OSFatal("OSDynLoad_FindExport failed.");
}
```
## Use this lib in Dockerfiles.
A prebuilt version of this lib can found on dockerhub. To use it for your projects, add this to your Dockerfile.
```Dockerfile
[...]
COPY --from=wiiuenv/wiiumodulesystem:[tag] /artifacts $DEVKITPRO
[...]
```
Replace [tag] with a tag you want to use, a list of tags can be found [here](https://hub.docker.com/r/wiiuenv/wiiumodulesystem/tags).
It's highly recommended to pin the version to the **latest date** instead of using `latest`.
## Format the code via docker
```bash
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./include ./libraries -i
```

View File

@ -1,6 +1,6 @@
#pragma once #pragma once
#include "wums/meta.h"
#include "wums/common.h" #include "wums/common.h"
#include "wums/exports.h" #include "wums/exports.h"
#include "wums/hooks.h" #include "wums/hooks.h"
#include "wums/meta.h"

View File

@ -31,11 +31,11 @@
extern "C" { extern "C" {
#endif #endif
#define WUMS_SECTION(x) __attribute__((__section__ (".wums." x))) #define WUMS_SECTION(x) __attribute__((__section__(".wums." x)))
#define WUMS_META(id, value) \ #define WUMS_META(id, value) \
extern const char wums_meta_ ## id [] WUMS_SECTION("meta"); \ extern const char wums_meta_##id[] WUMS_SECTION("meta"); \
const char wums_meta_ ## id [] = #id "=" value const char wums_meta_##id[] = #id "=" value
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -18,20 +18,20 @@
#pragma once #pragma once
#include <stdbool.h> #include <stdbool.h>
#include <stdint.h>
#include <stddef.h> #include <stddef.h>
#include <stdint.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#define DYN_LINK_FUNCTION_NAME_LENGTH 351 #define DYN_LINK_FUNCTION_NAME_LENGTH 351
#define DYN_LINK_IMPORT_NAME_LENGTH 50 #define DYN_LINK_IMPORT_NAME_LENGTH 50
#define DYN_LINK_FUNCTION_LIST_LENGTH 500 #define DYN_LINK_FUNCTION_LIST_LENGTH 500
#define DYN_LINK_IMPORT_LIST_LENGTH 50 #define DYN_LINK_IMPORT_LIST_LENGTH 50
#define DYN_LINK_TRAMPOLINE_LIST_LENGTH DYN_LINK_FUNCTION_LIST_LENGTH #define DYN_LINK_TRAMPOLINE_LIST_LENGTH DYN_LINK_FUNCTION_LIST_LENGTH
typedef struct _dyn_linking_function_t { typedef struct _dyn_linking_function_t {
char functionName[DYN_LINK_FUNCTION_NAME_LENGTH + 1]; char functionName[DYN_LINK_FUNCTION_NAME_LENGTH + 1];

View File

@ -2,7 +2,7 @@
#include <stdint.h> #include <stdint.h>
#define EXPORT_MAXIMUM_NAME_LENGTH 50 #define EXPORT_MAXIMUM_NAME_LENGTH 50
typedef struct export_data_t { typedef struct export_data_t {
uint32_t type; uint32_t type;
char name[EXPORT_MAXIMUM_NAME_LENGTH]; char name[EXPORT_MAXIMUM_NAME_LENGTH];

View File

@ -17,23 +17,23 @@
#pragma once #pragma once
#include <stdint.h>
#include <stddef.h>
#include "dynamic_linking_defines.h" #include "dynamic_linking_defines.h"
#include "relocation_defines.h"
#include "export_defines.h" #include "export_defines.h"
#include "relocation_defines.h"
#include <stddef.h>
#include <stdint.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#define MAXIMUM_MODULE_PATH_NAME_LENGTH 256 #define MAXIMUM_MODULE_PATH_NAME_LENGTH 256
#define MAXIMUM_EXPORT_MODULE_NAME_LENGTH 51 #define MAXIMUM_EXPORT_MODULE_NAME_LENGTH 51
#define FUNCTION_SYMBOL_LIST_LENGTH 50000 #define FUNCTION_SYMBOL_LIST_LENGTH 50000
#define DYN_LINK_RELOCATION_LIST_LENGTH 500 #define DYN_LINK_RELOCATION_LIST_LENGTH 500
#define EXPORT_ENTRY_LIST_LENGTH 100 #define EXPORT_ENTRY_LIST_LENGTH 100
#define HOOK_ENTRY_LIST_LENGTH 20 #define HOOK_ENTRY_LIST_LENGTH 20
typedef struct hook_data_t { typedef struct hook_data_t {
uint32_t type; uint32_t type;
@ -41,18 +41,19 @@ typedef struct hook_data_t {
} hook_data_t; } hook_data_t;
typedef struct module_function_symbol_data_t { typedef struct module_function_symbol_data_t {
char* name; char *name;
void* address; void *address;
uint32_t size; uint32_t size;
} module_function_symbol_data_t; } module_function_symbol_data_t;
// clang-format off
typedef struct module_information_single_t { typedef struct module_information_single_t {
char path[MAXIMUM_MODULE_PATH_NAME_LENGTH]; // Path where the module is stored char path[MAXIMUM_MODULE_PATH_NAME_LENGTH]; // Path where the module is stored
dyn_linking_relocation_entry_t linking_entries[DYN_LINK_RELOCATION_LIST_LENGTH]; dyn_linking_relocation_entry_t linking_entries[DYN_LINK_RELOCATION_LIST_LENGTH];
char module_export_name[MAXIMUM_EXPORT_MODULE_NAME_LENGTH]; char module_export_name[MAXIMUM_EXPORT_MODULE_NAME_LENGTH];
export_data_t export_entries[EXPORT_ENTRY_LIST_LENGTH]; export_data_t export_entries[EXPORT_ENTRY_LIST_LENGTH];
hook_data_t hook_entries[HOOK_ENTRY_LIST_LENGTH]; hook_data_t hook_entries[HOOK_ENTRY_LIST_LENGTH];
int32_t priority; // Priority of this module int32_t priority; // Priority of this module
uint32_t bssAddr; uint32_t bssAddr;
uint32_t bssSize; uint32_t bssSize;
uint32_t sbssAddr; uint32_t sbssAddr;
@ -65,19 +66,22 @@ typedef struct module_information_single_t {
module_function_symbol_data_t * function_symbol_entries; module_function_symbol_data_t * function_symbol_entries;
uint32_t number_used_function_symbols; uint32_t number_used_function_symbols;
} module_information_single_t; } module_information_single_t;
// clang-format on
#define MAXIMUM_MODULES 32 #define MAXIMUM_MODULES 32
#define MODULE_INFORMATION_VERSION 0x00000007 #define MODULE_INFORMATION_VERSION 0x00000007
// clang-format off
typedef struct module_information_t { typedef struct module_information_t {
uint32_t version; uint32_t version;
int32_t number_used_modules; // Number of used function. Maximum is MAXIMUM_MODULES int32_t number_used_modules; // Number of used function. Maximum is MAXIMUM_MODULES
dyn_linking_relocation_data_t linking_data; dyn_linking_relocation_data_t linking_data;
relocation_trampoline_entry_t trampolines[DYN_LINK_TRAMPOLINE_LIST_LENGTH]; relocation_trampoline_entry_t trampolines[DYN_LINK_TRAMPOLINE_LIST_LENGTH];
module_function_symbol_data_t function_symbols[FUNCTION_SYMBOL_LIST_LENGTH]; module_function_symbol_data_t function_symbols[FUNCTION_SYMBOL_LIST_LENGTH];
uint32_t number_used_function_symbols; uint32_t number_used_function_symbols;
module_information_single_t module_data[MAXIMUM_MODULES]; module_information_single_t module_data[MAXIMUM_MODULES];
} module_information_t; } module_information_t;
// clang-format on
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -2,16 +2,16 @@
#include <stdint.h> #include <stdint.h>
typedef enum RelocationTrampolineStatus{ typedef enum RelocationTrampolineStatus {
RELOC_TRAMP_FREE = 0, RELOC_TRAMP_FREE = 0,
RELOC_TRAMP_FIXED = 1, RELOC_TRAMP_FIXED = 1,
RELOC_TRAMP_IMPORT_IN_PROGRESS = 2, RELOC_TRAMP_IMPORT_IN_PROGRESS = 2,
RELOC_TRAMP_IMPORT_DONE = 3, RELOC_TRAMP_IMPORT_DONE = 3,
} RelocationTrampolineStatus; } RelocationTrampolineStatus;
typedef enum RelocationType{ typedef enum RelocationType {
RELOC_TYPE_FIXED = 0, RELOC_TYPE_FIXED = 0,
RELOC_TYPE_IMPORT = 1 RELOC_TYPE_IMPORT = 1
} RelocationType; } RelocationType;
typedef struct relocation_trampoline_entry_t { typedef struct relocation_trampoline_entry_t {

View File

@ -38,21 +38,20 @@ typedef enum wums_entry_type_t {
typedef struct wums_entry_t { typedef struct wums_entry_t {
wums_entry_type_t type; wums_entry_type_t type;
const char *name; /* name of the export */ const char *name; /* name of the export */
const void *address; /* pointer to the export */ const void *address; /* pointer to the export */
} wums_loader_entry_t; } wums_loader_entry_t;
#define WUMS_EXPORT_FUNCTION(function) WUMS_EXPORT(WUMS_FUNCTION_EXPORT, function, function) #define WUMS_EXPORT_FUNCTION(function) WUMS_EXPORT(WUMS_FUNCTION_EXPORT, function, function)
#define WUMS_EXPORT_DATA(pointer) WUMS_EXPORT(WUMS_DATA_EXPORT, pointer, &pointer) #define WUMS_EXPORT_DATA(pointer) WUMS_EXPORT(WUMS_DATA_EXPORT, pointer, &pointer)
#define WUMS_EXPORT(_type, pointer, value) \ #define WUMS_EXPORT(_type, pointer, value) \
extern const wums_loader_entry_t wums_entry_##pointer \ extern const wums_loader_entry_t wums_entry_##pointer \
WUMS_SECTION("exports"); \ WUMS_SECTION("exports"); \
const wums_loader_entry_t wums_entry_##pointer = { \ const wums_loader_entry_t wums_entry_##pointer = { \
.type = _type, \ .type = _type, \
.name = # pointer, \ .name = #pointer, \
.address = (const void*) value \ .address = (const void *) value}
}
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -32,12 +32,11 @@
extern "C" { extern "C" {
#endif #endif
#define WUMS_HOOK_EX(type_def, original_func) \ #define WUMS_HOOK_EX(type_def, original_func) \
extern const wums_hook_t wums_hooks_ ## original_func WUMS_SECTION("hooks"); \ extern const wums_hook_t wums_hooks_##original_func WUMS_SECTION("hooks"); \
const wums_hook_t wums_hooks_ ## original_func = { \ const wums_hook_t wums_hooks_##original_func = { \
.type = type_def, \ .type = type_def, \
.target = (const void*)&(original_func) \ .target = (const void *) &(original_func)}
}
typedef enum wums_hook_type_t { typedef enum wums_hook_type_t {
WUMS_HOOK_INIT_WUT_MALLOC, WUMS_HOOK_INIT_WUT_MALLOC,
@ -51,8 +50,8 @@ typedef enum wums_hook_type_t {
WUMS_HOOK_INIT_WUT_SOCKETS, WUMS_HOOK_INIT_WUT_SOCKETS,
WUMS_HOOK_FINI_WUT_SOCKETS, WUMS_HOOK_FINI_WUT_SOCKETS,
WUMS_HOOK_INIT_WRAPPER, /* Calls __init */ WUMS_HOOK_INIT_WRAPPER, /* Calls __init */
WUMS_HOOK_FINI_WRAPPER, /* Calls __fini */ WUMS_HOOK_FINI_WRAPPER, /* Calls __fini */
WUMS_HOOK_INIT, WUMS_HOOK_INIT,
WUMS_HOOK_APPLICATION_STARTS, WUMS_HOOK_APPLICATION_STARTS,
@ -62,8 +61,8 @@ typedef enum wums_hook_type_t {
} wums_hook_type_t; } wums_hook_type_t;
typedef struct wums_hook_t { typedef struct wums_hook_t {
wums_hook_type_t type; /* Defines the type of the hook */ wums_hook_type_t type; /* Defines the type of the hook */
const void *target; /* Address of our own, new function */ const void *target; /* Address of our own, new function */
} wums_hook_t; } wums_hook_t;
typedef struct wums_app_init_args_t { typedef struct wums_app_init_args_t {
@ -74,28 +73,28 @@ typedef struct wums_relocs_done_args_t {
module_information_t *module_information; module_information_t *module_information;
} wums_relocs_done_args_t; } wums_relocs_done_args_t;
#define WUMS_INITIALIZE(myargs) \ #define WUMS_INITIALIZE(myargs) \
void __wums__init(wums_app_init_args_t);\ void __wums__init(wums_app_init_args_t); \
WUMS_HOOK_EX(WUMS_HOOK_INIT, __wums__init); \ WUMS_HOOK_EX(WUMS_HOOK_INIT, __wums__init); \
void __wums__init(wums_app_init_args_t myargs) void __wums__init(wums_app_init_args_t myargs)
#define WUMS_APPLICATION_STARTS() \ #define WUMS_APPLICATION_STARTS() \
void __wums_start(void);\ void __wums_start(void); \
WUMS_HOOK_EX(WUMS_HOOK_APPLICATION_STARTS, __wums_start); \ WUMS_HOOK_EX(WUMS_HOOK_APPLICATION_STARTS, __wums_start); \
void __wums_start() void __wums_start()
#define WUMS_APPLICATION_ENDS() \ #define WUMS_APPLICATION_ENDS() \
void __wums_end(void);\ void __wums_end(void); \
WUMS_HOOK_EX(WUMS_HOOK_APPLICATION_ENDS, __wums_end); \ WUMS_HOOK_EX(WUMS_HOOK_APPLICATION_ENDS, __wums_end); \
void __wums_end() void __wums_end()
#define WUMS_APPLICATION_REQUESTS_EXIT() \ #define WUMS_APPLICATION_REQUESTS_EXIT() \
void __wums_requests_exit(void);\ void __wums_requests_exit(void); \
WUMS_HOOK_EX(WUMS_HOOK_APPLICATION_REQUESTS_EXIT, __wums_requests_exit); \ WUMS_HOOK_EX(WUMS_HOOK_APPLICATION_REQUESTS_EXIT, __wums_requests_exit); \
void __wums_requests_exit() void __wums_requests_exit()
#define WUMS_RELOCATIONS_DONE(myargs) \ #define WUMS_RELOCATIONS_DONE(myargs) \
void __wums_relocations_done(wums_relocs_done_args_t);\ void __wums_relocations_done(wums_relocs_done_args_t); \
WUMS_HOOK_EX(WUMS_HOOK_RELOCATIONS_DONE, __wums_relocations_done); \ WUMS_HOOK_EX(WUMS_HOOK_RELOCATIONS_DONE, __wums_relocations_done); \
void __wums_relocations_done(wums_relocs_done_args_t myargs) void __wums_relocations_done(wums_relocs_done_args_t myargs)
@ -105,73 +104,73 @@ typedef struct wums_relocs_done_args_t {
#define __EXTERN_C_MACRO #define __EXTERN_C_MACRO
#endif #endif
#define WUMS_USE_WUT_MALLOC() \ #define WUMS_USE_WUT_MALLOC() \
__EXTERN_C_MACRO void __init_wut_malloc(); \ __EXTERN_C_MACRO void __init_wut_malloc(); \
void on_init_wut_malloc(){ \ void on_init_wut_malloc() { \
__init_wut_malloc(); \ __init_wut_malloc(); \
}\ } \
WUMS_HOOK_EX(WUMS_HOOK_INIT_WUT_MALLOC,on_init_wut_malloc); \ WUMS_HOOK_EX(WUMS_HOOK_INIT_WUT_MALLOC, on_init_wut_malloc); \
__EXTERN_C_MACRO void __fini_wut_malloc(); \ __EXTERN_C_MACRO void __fini_wut_malloc(); \
void on_fini_wut_malloc(){ \ void on_fini_wut_malloc() { \
__fini_wut_malloc(); \ __fini_wut_malloc(); \
} \ } \
WUMS_HOOK_EX(WUMS_HOOK_FINI_WUT_MALLOC,on_fini_wut_malloc) WUMS_HOOK_EX(WUMS_HOOK_FINI_WUT_MALLOC, on_fini_wut_malloc)
#define WUMS_USE_WUT_DEVOPTAB() \ #define WUMS_USE_WUT_DEVOPTAB() \
__EXTERN_C_MACRO void __init_wut_devoptab(); \ __EXTERN_C_MACRO void __init_wut_devoptab(); \
void on_init_wut_devoptab(){ \ void on_init_wut_devoptab() { \
__init_wut_devoptab(); \ __init_wut_devoptab(); \
}\ } \
WUMS_HOOK_EX(WUMS_HOOK_INIT_WUT_DEVOPTAB,on_init_wut_devoptab); \ WUMS_HOOK_EX(WUMS_HOOK_INIT_WUT_DEVOPTAB, on_init_wut_devoptab); \
__EXTERN_C_MACRO void __fini_wut_devoptab(); \ __EXTERN_C_MACRO void __fini_wut_devoptab(); \
void on_fini_wut_devoptab(){ \ void on_fini_wut_devoptab() { \
__fini_wut_devoptab(); \ __fini_wut_devoptab(); \
}\ } \
WUMS_HOOK_EX(WUMS_HOOK_FINI_WUT_DEVOPTAB,on_fini_wut_devoptab) WUMS_HOOK_EX(WUMS_HOOK_FINI_WUT_DEVOPTAB, on_fini_wut_devoptab)
#define WUMS_USE_WUT_NEWLIB() \ #define WUMS_USE_WUT_NEWLIB() \
__EXTERN_C_MACRO void __init_wut_newlib(); \ __EXTERN_C_MACRO void __init_wut_newlib(); \
void on_init_wut_newlib(){ \ void on_init_wut_newlib() { \
__init_wut_newlib(); \ __init_wut_newlib(); \
}\ } \
WUMS_HOOK_EX(WUMS_HOOK_INIT_WUT_NEWLIB,on_init_wut_newlib); \ WUMS_HOOK_EX(WUMS_HOOK_INIT_WUT_NEWLIB, on_init_wut_newlib); \
__EXTERN_C_MACRO void __fini_wut_newlib(); \ __EXTERN_C_MACRO void __fini_wut_newlib(); \
void on_fini_wut_newlib(){ \ void on_fini_wut_newlib() { \
__fini_wut_newlib(); \ __fini_wut_newlib(); \
}\ } \
WUMS_HOOK_EX(WUMS_HOOK_FINI_WUT_NEWLIB,on_fini_wut_newlib) WUMS_HOOK_EX(WUMS_HOOK_FINI_WUT_NEWLIB, on_fini_wut_newlib)
#define WUMS_USE_WUT_STDCPP() \ #define WUMS_USE_WUT_STDCPP() \
__EXTERN_C_MACRO void __init_wut_stdcpp(); \ __EXTERN_C_MACRO void __init_wut_stdcpp(); \
void on_init_wut_stdcpp(){ \ void on_init_wut_stdcpp() { \
__init_wut_stdcpp(); \ __init_wut_stdcpp(); \
}\ } \
WUMS_HOOK_EX(WUMS_HOOK_INIT_WUT_STDCPP,on_init_wut_stdcpp); \ WUMS_HOOK_EX(WUMS_HOOK_INIT_WUT_STDCPP, on_init_wut_stdcpp); \
__EXTERN_C_MACRO void __fini_wut_stdcpp(); \ __EXTERN_C_MACRO void __fini_wut_stdcpp(); \
void on_fini_wut_stdcpp(){ \ void on_fini_wut_stdcpp() { \
__fini_wut_stdcpp(); \ __fini_wut_stdcpp(); \
}\ } \
WUMS_HOOK_EX(WUMS_HOOK_FINI_WUT_STDCPP,on_fini_wut_stdcpp) WUMS_HOOK_EX(WUMS_HOOK_FINI_WUT_STDCPP, on_fini_wut_stdcpp)
#define WUMS_USE_WUT_SOCKETS() \ #define WUMS_USE_WUT_SOCKETS() \
__EXTERN_C_MACRO void __init_wut_socket(); \ __EXTERN_C_MACRO void __init_wut_socket(); \
WUMS_HOOK_EX(WUMS_HOOK_INIT_WUT_SOCKETS,__init_wut_socket); \ WUMS_HOOK_EX(WUMS_HOOK_INIT_WUT_SOCKETS, __init_wut_socket); \
__EXTERN_C_MACRO void __fini_wut_socket(); \ __EXTERN_C_MACRO void __fini_wut_socket(); \
WUMS_HOOK_EX(WUMS_HOOK_FINI_WUT_SOCKETS,__fini_wut_socket) WUMS_HOOK_EX(WUMS_HOOK_FINI_WUT_SOCKETS, __fini_wut_socket)
#define WUMS___INIT_WRAPPER() \ #define WUMS___INIT_WRAPPER() \
__EXTERN_C_MACRO void __init(); \ __EXTERN_C_MACRO void __init(); \
void __init_wrapper(){ \ void __init_wrapper() { \
__init(); \ __init(); \
}\ } \
WUMS_HOOK_EX(WUMS_HOOK_INIT_WRAPPER,__init_wrapper); WUMS_HOOK_EX(WUMS_HOOK_INIT_WRAPPER, __init_wrapper);
#define WUMS___FINI_WRAPPER() \ #define WUMS___FINI_WRAPPER() \
__EXTERN_C_MACRO void __fini(); \ __EXTERN_C_MACRO void __fini(); \
void __fini_wrapper(){ \ void __fini_wrapper() { \
__fini(); \ __fini(); \
}\ } \
WUMS_HOOK_EX(WUMS_HOOK_FINI_WRAPPER,__fini_wrapper); WUMS_HOOK_EX(WUMS_HOOK_FINI_WRAPPER, __fini_wrapper);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -32,22 +32,22 @@
extern "C" { extern "C" {
#endif #endif
#define WUMS_MODULE_EXPORT_NAME(x) \ #define WUMS_MODULE_EXPORT_NAME(x) \
WUMS_META(export_name, x); \ WUMS_META(export_name, x); \
WUMS_META(wum, "0.3.1"); \ WUMS_META(wum, "0.3.1"); \
WUMS_USE_WUT_MALLOC(); \ WUMS_USE_WUT_MALLOC(); \
WUMS_USE_WUT_SOCKETS(); \ WUMS_USE_WUT_SOCKETS(); \
WUMS_USE_WUT_NEWLIB(); \ WUMS_USE_WUT_NEWLIB(); \
WUMS_USE_WUT_STDCPP(); \ WUMS_USE_WUT_STDCPP(); \
WUMS___INIT_WRAPPER(); \ WUMS___INIT_WRAPPER(); \
WUMS___FINI_WRAPPER(); \ WUMS___FINI_WRAPPER(); \
WUMS_META(buildtimestamp, __DATE__ " " __TIME__) WUMS_META(buildtimestamp, __DATE__ " " __TIME__)
#define WUMS_MODULE_AUTHOR(x) WUMS_META(author, x) #define WUMS_MODULE_AUTHOR(x) WUMS_META(author, x)
#define WUMS_MODULE_VERSION(x) WUMS_META(version, x) #define WUMS_MODULE_VERSION(x) WUMS_META(version, x)
#define WUMS_MODULE_LICENSE(x) WUMS_META(license, x) #define WUMS_MODULE_LICENSE(x) WUMS_META(license, x)
#define WUMS_MODULE_DESCRIPTION(x) WUMS_META(description, x) #define WUMS_MODULE_DESCRIPTION(x) WUMS_META(description, x)
#define WUMS_MODULE_SKIP_INIT_FINI() WUMS_META(skipInitFini, "true") #define WUMS_MODULE_SKIP_INIT_FINI() WUMS_META(skipInitFini, "true")
#define WUMS_MODULE_INIT_BEFORE_RELOCATION_DONE_HOOK() WUMS_META(initBeforeRelocationDoneHook, "true") #define WUMS_MODULE_INIT_BEFORE_RELOCATION_DONE_HOOK() WUMS_META(initBeforeRelocationDoneHook, "true")
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -10,7 +10,7 @@ static int __wut_socket_devoptab_added = 0;
extern void socket_lib_init(); extern void socket_lib_init();
void __attribute__((weak)) __init_wut_socket() { void __attribute__((weak)) __init_wut_socket() {
if(!&__wut_socket_init_devoptab) return; if (!&__wut_socket_init_devoptab) return;
if (!__wut_socket_devoptab_added) { if (!__wut_socket_devoptab_added) {
socket_lib_init(); socket_lib_init();
__wut_socket_init_devoptab(); __wut_socket_init_devoptab();
@ -19,7 +19,7 @@ void __attribute__((weak)) __init_wut_socket() {
} }
void __attribute__((weak)) __fini_wut_socket() { void __attribute__((weak)) __fini_wut_socket() {
if(!&__wut_socket_init_devoptab || !&__wut_socket_fini_devoptab) return; if (!&__wut_socket_init_devoptab || !&__wut_socket_fini_devoptab) return;
if (__wut_socket_devoptab_added) { if (__wut_socket_devoptab_added) {
__wut_socket_fini_devoptab(); __wut_socket_fini_devoptab();
__wut_socket_devoptab_added = 0; __wut_socket_devoptab_added = 0;