diff options
author | Danny Holman <dholman@gymli.org> | 2025-08-04 12:32:39 -0500 |
---|---|---|
committer | Danny Holman <dholman@gymli.org> | 2025-08-04 12:32:39 -0500 |
commit | 7a268ae92d44a9f27f4874e1e50413ee33b86dd3 (patch) | |
tree | 47574f2a1d6c6d469e19627aacbcae03ae615dee /core | |
parent | render: vulkan: add check for null pointer for debug (diff) | |
download | rune-engine-7a268ae92d44a9f27f4874e1e50413ee33b86dd3.tar.gz rune-engine-7a268ae92d44a9f27f4874e1e50413ee33b86dd3.tar.zst rune-engine-7a268ae92d44a9f27f4874e1e50413ee33b86dd3.zip |
root: restructuring
Restructure the root of the project such that the engine is siloed from
the rest of the toolchain. Add two new subdirectories that contain an
editor and an offline profiling data analyzer.
Signed-off-by: Danny Holman <dholman@gymli.org>
Diffstat (limited to '')
-rw-r--r-- | engine/core/abort.c (renamed from core/abort.c) | 0 | ||||
-rw-r--r-- | engine/core/alloc.c (renamed from core/alloc.c) | 27 | ||||
-rw-r--r-- | engine/core/callbacks.c (renamed from core/callbacks.c) | 0 | ||||
-rw-r--r-- | engine/core/init.c (renamed from core/init.c) | 13 | ||||
-rw-r--r-- | engine/core/logging.c (renamed from core/logging.c) | 0 | ||||
-rw-r--r-- | engine/core/mod.c (renamed from core/mod.c) | 0 | ||||
-rw-r--r-- | engine/core/thread.c (renamed from core/thread.c) | 0 |
7 files changed, 36 insertions, 4 deletions
diff --git a/core/abort.c b/engine/core/abort.c index 5ee42f6..5ee42f6 100644 --- a/core/abort.c +++ b/engine/core/abort.c diff --git a/core/alloc.c b/engine/core/alloc.c index 0ed705c..b75f1d3 100644 --- a/core/alloc.c +++ b/engine/core/alloc.c @@ -21,6 +21,7 @@ #include <rune/core/alloc.h> #include <rune/core/logging.h> +#include <rune/core/profiling.h> #include <stdlib.h> #include <string.h> @@ -55,19 +56,22 @@ static mem_block_t* _find_block(void *ptr) { } static mem_block_t* _alloc_block(size_t sz) { + RUNE_PROFILE_SCOPE("Block allocation"); if (first_block.ptr == NULL) { - first_block.ptr == DEADBLOCK; + first_block.ptr = DEADBLOCK; first_block.sz = 0; } mem_block_t *ret = _find_free_block(sz); if (ret != NULL) { ret->free = 0; + RUNE_PROFILE_END(); return ret->ptr; } ret = malloc(sizeof(mem_block_t)); if (ret == NULL) { + RUNE_PROFILE_END(); log_output(LOG_ERROR, "Cannot allocate block of size %d", sz); return NULL; } @@ -76,15 +80,18 @@ static mem_block_t* _alloc_block(size_t sz) { ret->sz = sz; ret->free = 0; list_add(&ret->list, &first_block.list); + RUNE_PROFILE_END(); log_output(LOG_DEBUG, "Alloc'd block of size %d", sz); return ret; } static void _free_block(mem_block_t *block, int hard) { + RUNE_PROFILE_SCOPE("Block free"); if (hard == 1) { list_del(&block->list); - log_output(LOG_DEBUG, "Freed block of size %d", block->sz); + RUNE_PROFILE_END(); free(block); + log_output(LOG_DEBUG, "Freed block of size %d", block->sz); return; } block->free = 1; @@ -94,13 +101,16 @@ void* rune_alloc(size_t sz) { if (sz == 0) return NULL; + RUNE_PROFILE_SCOPE("Pool allocation"); mem_block_t *block = _find_free_block(sz); if (block != NULL) { block->free = 0; + RUNE_PROFILE_END(); return block->ptr; } block = _alloc_block(sz); + RUNE_PROFILE_END(); return block->ptr; } @@ -108,14 +118,17 @@ void* rune_calloc(size_t nmemb, size_t sz) { if (sz == 0) return NULL; + RUNE_PROFILE_SCOPE("Zero array pool allocation"); mem_block_t *block = _find_free_block(sz); if (block != NULL) { block->free = 0; + RUNE_PROFILE_END(); return block->ptr; } block = _alloc_block(sz); memset(block->ptr, 0, sz); + RUNE_PROFILE_END(); return block->ptr; } @@ -123,10 +136,12 @@ void* rune_realloc(void *ptr, size_t sz) { if (ptr == NULL || sz == 0) return rune_alloc(sz); + RUNE_PROFILE_SCOPE("Pool reallocation"); mem_block_t *old = _find_block(ptr); mem_block_t *new = _alloc_block(sz); memcpy(new->ptr, old->ptr, old->sz); old->free = 1; + RUNE_PROFILE_END(); return new->ptr; } @@ -134,13 +149,18 @@ void rune_free(void *ptr) { if (ptr == NULL) return; + RUNE_PROFILE_SCOPE("Pool free"); mem_block_t *block = _find_block(ptr); - if (block->free == 1) + if (block->free == 1) { + RUNE_PROFILE_END(); return; + } block->free = 1; + RUNE_PROFILE_END(); } void rune_free_all(void) { + RUNE_PROFILE_SCOPE("Pool free all"); list_head_t *temp = &first_block.list; mem_block_t *block; while (temp != NULL) { @@ -154,4 +174,5 @@ void rune_free_all(void) { if (block->ptr != NULL) _free_block(block, 1); } + RUNE_PROFILE_END(); } diff --git a/core/callbacks.c b/engine/core/callbacks.c index ea7f50e..ea7f50e 100644 --- a/core/callbacks.c +++ b/engine/core/callbacks.c diff --git a/core/init.c b/engine/core/init.c index 5df4d04..6fcd086 100644 --- a/core/init.c +++ b/engine/core/init.c @@ -21,17 +21,28 @@ #include <rune/core/init.h> #include <rune/core/abort.h> +#include <rune/core/alloc.h> +#include <rune/core/config.h> #include <rune/core/logging.h> #include <rune/core/thread.h> +#include <rune/core/mod.h> +#include <rune/core/object.h> int rune_init(int argc, char* argv[]) { log_output(LOG_INFO, "Started Rune Engine version %s", RUNE_VER); - _parse_args(argc, argv); + + rune_init_default_settings(); rune_init_thread_api(); + + rune_load_mods(); + rune_init_mods(); + return 0; } void rune_exit(void) { log_output(LOG_INFO, "Engine shutdown requested"); + rune_clear_objs(); + rune_close_mods(); rune_free_all(); } diff --git a/core/logging.c b/engine/core/logging.c index b7f77bd..b7f77bd 100644 --- a/core/logging.c +++ b/engine/core/logging.c diff --git a/core/mod.c b/engine/core/mod.c index 3d9e710..3d9e710 100644 --- a/core/mod.c +++ b/engine/core/mod.c diff --git a/core/thread.c b/engine/core/thread.c index 3c5db8c..3c5db8c 100644 --- a/core/thread.c +++ b/engine/core/thread.c |