This repository has been archived on 2025-02-04. You can view files and clone it, but cannot push or open issues or pull requests.
helpless/oogabooga/oogabooga.c
Charlie db73d0bd2e - Basic fixed-length string with replacement for C standard printing & fmt stuff
- Jai-like print procedures
	- %s formats 'string' and to format a char* you do %cs
	- It detects if %cs pointer is outside of program memory or stack and asserts
	- AND same for if a char* is passed to %s
	- Print directly writes to stdout without any allocations
	- Basic utlity procedures
	- Buncha string tests
- Beef up assert to display file & line as well
- Don't define memcpy procedures if compiler has intrinsics for them
- Init memory arena for allocations in initialization time before heap is ready (stack memory)
- os_compare_and_swap
- Spinlock "primitive" (wrapper around a bool using compare_and_swap)
- Switched to using spinlock instead of os mutex in heap for synchronization.
- is_pointer_valid() which checks if address is in program_memory or thread stack
2024-06-28 18:50:30 +02:00

70 lines
No EOL
1.3 KiB
C

#ifdef _WIN32
#include <Windows.h>
#define OS_WINDOWS
#elif defined(__linux__)
// Include whatever #Incomplete #Portability
#define OS_LINUX
#error "Linux is not supported yet";
#elif defined(__APPLE__) && defined(__MACH__)
// Include whatever #Incomplete #Portability
#define OS_MAC
#error "Mac is not supported yet";
#else
#error "Current OS not supported!";
#endif
#include "base.c"
#include "string.c"
#include "os_interface.c"
#include "memory.c"
#ifdef OS_WINDOWS
#include "os_impl_windows.c"
#elif defined (OS_LINUX)
#elif defined (OS_MAC)
#endif
#include "tests.c"
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 oogabooga_main(int argc, char **argv);
int main(int argc, char **argv) {
context.allocator.proc = initialization_allocator_proc;
oogabooga_init(INITIAL_PROGRAM_MEMORY_SIZE);
printf("Ooga booga program started\n");
// 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;
}