From 49ca7f3406bd5ee245bd73ab52000ca2ed9f7413 Mon Sep 17 00:00:00 2001 From: Charlie <66182434+asbott@users.noreply.github.com> Date: Fri, 28 Jun 2024 12:16:48 +0200 Subject: [PATCH] Oogaboogafy main() --- main.c | 11 ++++------- oogabooga/oogabooga.c | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/main.c b/main.c index 829061a..3bd6ab4 100644 --- a/main.c +++ b/main.c @@ -1,7 +1,7 @@ -int main() { - printf("Program started\n"); - oogabooga_init(1024 * 1024 * 100); // Start with 100mb program memory +int oogabooga_main(int argc, char **argv) { + + // alloc calls to context.allocator.proc which by default is set to the // heap allocator in memory.c @@ -37,10 +37,7 @@ int main() { context.extra.monkee = 69; - // This can be disabled in build.c -#if RUN_TESTS - oogabooga_run_tests(); -#endif + int hello; hello = 5; diff --git a/oogabooga/oogabooga.c b/oogabooga/oogabooga.c index 12ffe2f..42ed9fa 100644 --- a/oogabooga/oogabooga.c +++ b/oogabooga/oogabooga.c @@ -24,4 +24,27 @@ void oogabooga_init(u64 program_memory_size) { os_init(program_memory_size); heap_init(); temporary_storage_init(); +} + +#ifndef INITIAL_PROGRAM_MEMORY_SIZE + #define INITIAL_PROGRAM_MEMORY_SIZE (1024ULL * 1024ULL * 100ULL) // Start with 100mb program memory +#endif +#ifndef RUN_TESTS + #define RUN_TESTS 0 +#endif + +int main(int argc, char **argv) { + printf("Ooga booga program started\n"); + oogabooga_init(INITIAL_PROGRAM_MEMORY_SIZE); + + // This can be disabled in build.c + #if RUN_TESTS + oogabooga_run_tests(); + #endif + + int code = oogabooga_main(argc, argv); + + printf("Ooga booga program exit with code %i\n", code); + + return code; } \ No newline at end of file