From 078bf4b271e96ec38853b4e96c9abe2a3293f6d7 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Sat, 1 Feb 2025 22:58:35 -0500 Subject: [PATCH] base progress --- .vscode/settings.json | 3 ++- code/base/arena.c | 4 ++-- code/base/arena.h | 6 +++--- code/base/base_types.h | 3 +++ code/base/command_line.c | 4 ++-- code/base/command_line.h | 4 ++-- code/base/constants.h | 7 +++++-- code/base/context_cracking.h | 30 ++++++++++++++-------------- code/base/cracking_os.h | 3 --- code/base/entry_point.h | 12 +++++++----- code/base/linkage.h | 3 +-- code/base/macros.h | 3 ++- code/base/markup.h | 13 ++++++------ code/base/math.h | 12 ++++-------- code/base/memory.h | 38 +++++++++++++++++++----------------- code/base/memory_substrate.h | 10 ++++++---- code/base/namespace.h | 4 ++-- code/base/platform.c | 4 ++-- code/base/platform.h | 6 ++++-- code/base/profiling.h | 9 ++++----- code/base/strings.h | 15 +++++++------- code/metadesk.h | 2 +- 22 files changed, 101 insertions(+), 94 deletions(-) delete mode 100644 code/base/cracking_os.h diff --git a/.vscode/settings.json b/.vscode/settings.json index bd20fff..193a956 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -13,6 +13,7 @@ "type_traits": "cpp", "xtr1common": "cpp", "cstddef": "cpp", - "xmemory": "cpp" + "xmemory": "cpp", + "memory.h": "c" } } \ No newline at end of file diff --git a/code/base/arena.c b/code/base/arena.c index 901beac..ac134cc 100644 --- a/code/base/arena.c +++ b/code/base/arena.c @@ -1,6 +1,6 @@ #ifdef MD_INTELLISENSE_DIRECTIVES -#pragma once -#include "rarena.h" +# pragma once +# include "arena.h" #endif // Copyright (c) 2024 Epic Games Tools diff --git a/code/base/arena.h b/code/base/arena.h index 951f2e5..501826b 100644 --- a/code/base/arena.h +++ b/code/base/arena.h @@ -1,7 +1,7 @@ #ifdef MD_INTELLISENSE_DIRECTIVES -#pragma once -#include "macros.h" -#include "base_types.h" +# pragma once +# include "macros.h" +# include "base_types.h" #endif // Copyright (c) 2024 Epic Games Tools diff --git a/code/base/base_types.h b/code/base/base_types.h index 3d727d6..8f7876c 100644 --- a/code/base/base_types.h +++ b/code/base/base_types.h @@ -1,6 +1,9 @@ #ifdef MD_INTELLISENSE_DIRECTIVES # pragma once +# include "context_cracking.h" +# include "linkage.h" # include "macros.h" +# include "platform.h" #endif #if defined( MD_COMPILER_MSVC ) diff --git a/code/base/command_line.c b/code/base/command_line.c index 6e09e8f..a5b33fd 100644 --- a/code/base/command_line.c +++ b/code/base/command_line.c @@ -1,6 +1,6 @@ #ifdef MD_INTELLISENSE_DIRECTIVES -#pragma once -#include "command_line.h" +# pragma once +# include "command_line.h" #endif // Copyright (c) 2024 Epic Games Tools diff --git a/code/base/command_line.h b/code/base/command_line.h index 2053f7a..8e55f84 100644 --- a/code/base/command_line.h +++ b/code/base/command_line.h @@ -1,6 +1,6 @@ #ifdef MD_INTELLISENSE_DIRECTIVES -#pragma once -#include "strings.h" +# pragma once +# include "strings.h" #endif // Copyright (c) 2024 Epic Games Tools diff --git a/code/base/constants.h b/code/base/constants.h index bcfeef3..e70d41e 100644 --- a/code/base/constants.h +++ b/code/base/constants.h @@ -1,6 +1,9 @@ #ifdef MD_INTELLISENSE_DIRECTIVES -#pragma once -#include "linkage.h" +# pragma once +# include "context_cracking.h" +# include "linkage.h" +# include "macros.h" +# include "base_types.h" #endif //////////////////////////////// diff --git a/code/base/context_cracking.h b/code/base/context_cracking.h index ac057ac..bb3f5cc 100644 --- a/code/base/context_cracking.h +++ b/code/base/context_cracking.h @@ -206,46 +206,46 @@ //~ rjf: Zero All Undefined Options #if !defined(MD_ARCH_32BIT) -# define MD_ARCH_32BIT 0 +# define MD_ARCH_32BIT 0 #endif #if !defined(MD_ARCH_64BIT) -# define MD_ARCH_64BIT 0 +# define MD_ARCH_64BIT 0 #endif #if !defined(MD_ARCH_X64) -# define MD_ARCH_X64 0 +# define MD_ARCH_X64 0 #endif #if !defined(MD_ARCH_X86) -# define MD_ARCH_X86 0 +# define MD_ARCH_X86 0 #endif #if !defined(MD_ARCH_ARM64) -# define MD_ARCH_ARM64 0 +# define MD_ARCH_ARM64 0 #endif #if !defined(MD_ARCH_ARM32) -# define MD_ARCH_ARM32 0 +# define MD_ARCH_ARM32 0 #endif #if !defined(MD_COMPILER_MSVC) -# define MD_COMPILER_MSVC 0 +# define MD_COMPILER_MSVC 0 #endif -#if !defined(MD-COMPILER_GCC) -# define MD_COMPILER_GCC 0 +#if !defined(MD_COMPILER_GCC) +# define MD_COMPILER_GCC 0 #endif #if !defined(MD_COMPILER_CLANG) -# define MD_COMPILER_CLANG 0 +# define MD_COMPILER_CLANG 0 #endif #if !defined(MD_OS_WINDOWS) -# define MD_OS_WINDOWS 0 +# define MD_OS_WINDOWS 0 #endif #if !defined(MD_OS_LINUX) -# define MD_OS_LINUX 0 +# define MD_OS_LINUX 0 #endif #if !defined(MD_OS_MAC) -# define MD_OS_MAC 0 +# define MD_OS_MAC 0 #endif #if !defined(MD_LANG_CPP) -# define MD_LANG_CPP 0 +# define MD_LANG_CPP 0 #endif #if !defined(MD_LANG_C) -# define MD_LANG_C 0 +# define MD_LANG_C 0 #endif //////////////////////////////// diff --git a/code/base/cracking_os.h b/code/base/cracking_os.h deleted file mode 100644 index 6f3b291..0000000 --- a/code/base/cracking_os.h +++ /dev/null @@ -1,3 +0,0 @@ -#if MD_INTELLISENSE_DIRECTIVES -#pragma once -#endif diff --git a/code/base/entry_point.h b/code/base/entry_point.h index fd6c0d9..386b3c5 100644 --- a/code/base/entry_point.h +++ b/code/base/entry_point.h @@ -1,10 +1,12 @@ +#ifdef MD_INTELLISENSE_DIRECTIVES +# pragma once +# include "context_cracking.h" +# include "linkage.h" +# include "command_line.h" +#endif + // Copyright (c) 2024 Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) -#ifndef BASE_ENTRY_POINT_H -#define BASE_ENTRY_POINT_H - internal void main_thread_base_entry_point(void (*entry_point)(CmdLine *cmdline), char **arguments, U64 arguments_count); internal void supplement_thread_base_entry_point(void (*entry_point)(void *params), void *params); - -#endif // BASE_ENTRY_POINT_H diff --git a/code/base/linkage.h b/code/base/linkage.h index e35ee04..1b7e92c 100644 --- a/code/base/linkage.h +++ b/code/base/linkage.h @@ -1,7 +1,6 @@ #ifdef MD_INTELLISENSE_DIRECTIVES # pragma once -# include "cracking_arch.h" -# include "cracking_compiler.h" +# include "context_cracking.h" #endif #ifndef MD_API diff --git a/code/base/macros.h b/code/base/macros.h index 0f7167f..28e75e2 100644 --- a/code/base/macros.h +++ b/code/base/macros.h @@ -1,6 +1,7 @@ #if MD_INTELLISENSE_DIRECTIVES # pragma once -# include "platform.h" +# include "context_cracking.h" +# include "linkage.h" #endif #ifndef local_persist diff --git a/code/base/markup.h b/code/base/markup.h index 0f255ef..65a27ca 100644 --- a/code/base/markup.h +++ b/code/base/markup.h @@ -1,12 +1,13 @@ +#ifdef MD_INTELLISENSE_DIRECTIVES +# pragma once +# include "linkage.h" +# include "strings.h" +#endif + // Copyright (c) 2024 Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) -#ifndef BASE_MARKUP_H -#define BASE_MARKUP_H - internal void set_thread_name(String8 string); internal void set_thread_namef(char *fmt, ...); #define ThreadNameF(...) (set_thread_namef(__VA_ARGS__)) -#define ThreadName(str) (set_thread_name(str)) - -#endif // BASE_MARKUP_H +#define ThreadName(str) (set_thread_name(str)) diff --git a/code/base/math.h b/code/base/math.h index fcfe060..f563f17 100644 --- a/code/base/math.h +++ b/code/base/math.h @@ -1,10 +1,8 @@ #ifdef MD_INTELLISENSE_DIRECTIVES -#pragma once -#include "cracking_arch.h" -#include "cracking_compiler.h" -#include "cracking_os.h" -#include "linkage.h" -#include "macros.h" +# pragma once +# include "context_cracking.h" +# include "linkage.h" +# include "macros.h" #endif // Copyright (c) 2024 Epic Games Tools @@ -651,5 +649,3 @@ internal U32 u32_from_rgba(Vec4F32 rgba); internal void rng1s64_list_push(Arena *arena, Rng1S64List *list, Rng1S64 rng); internal Rng1S64Array rng1s64_array_from_list(Arena *arena, Rng1S64List *list); - -#endif // BASE_MATH_H diff --git a/code/base/memory.h b/code/base/memory.h index 4225c66..e97b0ea 100644 --- a/code/base/memory.h +++ b/code/base/memory.h @@ -1,7 +1,10 @@ #ifdef MD_INTELLISENSE_DIRECTIVES -#pragma once -#include "cracking_arch.h" -#include "macros.h" +# pragma once +# include "context_cracking.h" +# include "linkage.h" +# include "macros.h" +# include "platform.h" +# include "memory_substrate.h" #endif //////////////////////////////// @@ -278,26 +281,27 @@ MD_C_API void __asan_unpoison_memory_region(void const volatile *addr, size_t si //////////////////////////////// //~ rjf: Misc. Helper Macros -#define Stringify_(S) #S -#define Stringify(S) Stringify_(S) +#define stringify_(S) #S +#define stringify(S) Stringify_(S) -#define Glue_(A,B) A##B -#define Glue(A,B) Glue_(A,B) +#define glue_(A,B) A ## B +#define glue(A,B) glue_(A,B) -#define ArrayCount(a) (sizeof(a) / sizeof((a)[0])) +#define array_count(a) (sizeof(a) / sizeof((a)[0])) -#define CeilIntegerDiv(a,b) (((a) + (b) - 1)/(b)) +#define ceil_integer_div(a,b) (((a) + (b) - 1) / (b)) -#define Swap(T,a,b) do{T t__ = a; a = b; b = t__;}while(0) +#define swap(T, a, b) do { T t__ = a; a = b; b = t__; } while(0) -#if ARCH_64BIT -# define IntFromPtr(ptr) ((U64)(ptr)) -#elif ARCH_32BIT -# define IntFromPtr(ptr) ((U32)(ptr)) +#if MD_ARCH_64BIT +# define int_from_ptr(ptr) ((U64)(ptr)) +#elif MD_ARCH_32BIT +# define int_from_ptr(ptr) ((U32)(ptr)) #else -# error Missing pointer-to-integer cast for this architecture. +# error Missing pointer-to-integer cast for this architecture. #endif -#define PtrFromInt(i) (void*)((U8*)0 + (i)) + +#define ptr_from_int(i) (void*)((U8*)0 + (i)) #define Compose64Bit(a,b) ((((U64)a) << 32) | ((U64)b)); #define AlignPow2(x,b) (((x) + (b) - 1)&(~((b) - 1))) @@ -319,5 +323,3 @@ MD_C_API void __asan_unpoison_memory_region(void const volatile *addr, size_t si #else # define this_function_name __func__ #endif - - diff --git a/code/base/memory_substrate.h b/code/base/memory_substrate.h index 320e7c7..ab364ff 100644 --- a/code/base/memory_substrate.h +++ b/code/base/memory_substrate.h @@ -1,8 +1,10 @@ #ifdef MD_INTELLISENSE_DIRECTIVES -#pragma once -#include "base_types.h" -#include "macros.h" -#include "linkage.h" +# pragma once +# include "context_cracking.h" +# include "linkage.h" +# include "macros.h" +# include "linkage.h" +# include "base_types.h" #endif // This provides an alterntive memory strategy to HMH/Casey Muratori/RJF styled arenas diff --git a/code/base/namespace.h b/code/base/namespace.h index e7a19de..fe9b675 100644 --- a/code/base/namespace.h +++ b/code/base/namespace.h @@ -1,10 +1,10 @@ #ifdef MD_INTELLISENSE_DIRECTIVES # pragma once -# include "cracking_compiler.h" +# include "context_cracking.h" #endif // C++ namespace support -#if MD_DONT_USE_NAMESPACE || MD_COMPILER_C +#if MD_DONT_USE_NAMESPACE || MD_LANG_C # if MD_COMPILER_C # define MD_NS # define MD_NS_BEGIN diff --git a/code/base/platform.c b/code/base/platform.c index 9a4f908..9354d52 100644 --- a/code/base/platform.c +++ b/code/base/platform.c @@ -1,6 +1,6 @@ #ifdef MD_INTELLISENSE_DIRECTIVES -#pragma once -#include "platform.h" +# pragma once +# include "platform.h" #endif diff --git a/code/base/platform.h b/code/base/platform.h index b029b1f..426de3d 100644 --- a/code/base/platform.h +++ b/code/base/platform.h @@ -1,16 +1,18 @@ #if MD_INTELLISENSE_DIRECTIVES # pragma once # include "context_cracking.h" +# include "linkage.h" +# include "macros.h" #endif #include #include -#if defined( MD_SYSTEM_WINDOWS ) +#if defined( MD_OS_WINDOWS ) # include #endif -#if MD_COMPILER_C +#if MD_LANG_C # include # include #endif diff --git a/code/base/profiling.h b/code/base/profiling.h index 0809f20..cab2a01 100644 --- a/code/base/profiling.h +++ b/code/base/profiling.h @@ -1,9 +1,10 @@ +#ifdef MD_INTELLISENSE_DIRECTIVES +# pragma once +#endif + // Copyright (c) 2024 Epic Games Tools // Licensed under the MIT license (https://opensource.org/license/mit/) -#ifndef BASE_PROFILE_H -#define BASE_PROFILE_H - //////////////////////////////// //~ rjf: Zero Settings @@ -70,5 +71,3 @@ #define ProfBeginFunction(...) ProfBegin(this_function_name) #define ProfScope(...) DeferLoop(ProfBeginDynamic(__VA_ARGS__), ProfEnd()) - -#endif // BASE_PROFILE_H diff --git a/code/base/strings.h b/code/base/strings.h index ef768b6..8c0d491 100644 --- a/code/base/strings.h +++ b/code/base/strings.h @@ -1,12 +1,11 @@ #ifdef MD_INTELLISENSE_DIRECTIVES -#pragma once -#include "cracking_arch.h" -#include "cracking_compiler.h" -#include "cracking_os.h" -#include "macros.h" -#include "linkage.h" -#include "base_types.h" -#include "memory.h" +# pragma once +# include "context_cracking.h" +# include "linkage.h" +# include "platform.h" +# include "macros.h" +# include "base_types.h" +# include "memory.h" #endif // Copyright (c) 2024 Epic Games Tools diff --git a/code/metadesk.h b/code/metadesk.h index 437ce46..ea6ec98 100644 --- a/code/metadesk.h +++ b/code/metadesk.h @@ -9,8 +9,8 @@ #include "base/context_cracking.h" #include "base/linkage.h" #include "base/macros.h" -#include "base/namespace.h" #include "base/platform.h" +#include "base/namespace.h" MD_NS_BEGIN