various base progress

This commit is contained in:
ed
2025-02-06 18:54:51 -05:00
parent 887851e36c
commit f0b8eaa232
13 changed files with 334 additions and 180 deletions
+71 -13
View File
@@ -1,5 +1,6 @@
#ifdef INTELLISENSE_DIRECTIVES
# pragma once
# include "base_types.h"
#endif
////////////////////////////////
@@ -24,16 +25,16 @@ typedef enum ImageType
Image_Macho
} ImageType;
typedef enum Architecture
typedef enum Arch
{
Architecture_Null,
Architecture_x64,
Architecture_x86,
Architecture_arm64,
Architecture_arm32,
Architecture_COUNT,
Arch_Null,
Arch_x64,
Arch_x86,
Arch_arm64,
Arch_arm32,
Arch_COUNT,
}
Architecture;
Arch;
typedef enum Compiler
{
@@ -48,9 +49,66 @@ Compiler;
////////////////////////////////
//~ rjf: Toolchain/Environment Enum Functions
internal U64 bit_size_from_arch(Arch arch);
internal U64 max_instruction_size_from_arch(Arch arch);
inline U64
bit_size_from_arch(Arch arch)
{
// TODO(rjf): metacode
U64 arch_bitsize = 0;
switch(arch)
{
case Arch_x64: arch_bitsize = 64; break;
case Arch_x86: arch_bitsize = 32; break;
case Arch_arm64: arch_bitsize = 64; break;
case Arch_arm32: arch_bitsize = 32; break;
default: break;
}
return arch_bitsize;
}
internal OperatingSystem operating_system_from_context(void);
internal Arch arch_from_context(void);
internal Compiler compiler_from_context(void);
inline U64
max_instruction_size_from_arch(Arch arch)
{
// TODO(rjf): make this real
return 64;
}
inline OperatingSystem
operating_system_from_context(void) {
OperatingSystem os = OperatingSystem_Null;
#if OS_WINDOWS
os = OperatingSystem_Windows;
#elif OS_LINUX
os = OperatingSystem_Linux;
#elif OS_MAC
os = OperatingSystem_Mac;
#endif
return os;
}
inline Arch
arch_from_context(void) {
Arch arch = Arch_Null;
#if ARCH_X64
arch = Arch_x64;
#elif ARCH_X86
arch = Arch_x86;
#elif ARCH_ARM64
arch = Arch_arm64;
#elif ARCH_ARM32
arch = Arch_arm32;
#endif
return arch;
}
inline Compiler
compiler_from_context(void) {
Compiler compiler = Compiler_Null;
#if COMPILER_MSVC
compiler = Compiler_msvc;
#elif COMPILER_GCC
compiler = Compiler_gcc;
#elif COMPILER_CLANG
compiler = Compiler_clang;
#endif
return compiler;
}