mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Add memory-env option.
This commit is contained in:
committed by
Christoffer Lerno
parent
6a73c8e90e
commit
6eb65d5b37
@@ -11,6 +11,14 @@ enum CompilerOptLevel
|
||||
O3
|
||||
}
|
||||
|
||||
enum MemoryEnvironment
|
||||
{
|
||||
NORMAL,
|
||||
SMALL,
|
||||
TINY,
|
||||
NONE
|
||||
}
|
||||
|
||||
enum OsType
|
||||
{
|
||||
UNKNOWN,
|
||||
@@ -51,9 +59,9 @@ enum OsType
|
||||
EMSCRIPTEN,
|
||||
}
|
||||
|
||||
const OsType OS_TYPE = (OsType)($$OS_TYPE);
|
||||
const OsType OS_TYPE = (OsType)$$OS_TYPE;
|
||||
const bool COMPILER_LIBC_AVAILABLE = $$COMPILER_LIBC_AVAILABLE;
|
||||
const CompilerOptLevel COMPILER_OPT_LEVEL = (CompilerOptLevel)($$COMPILER_OPT_LEVEL);
|
||||
const CompilerOptLevel COMPILER_OPT_LEVEL = (CompilerOptLevel)$$COMPILER_OPT_LEVEL;
|
||||
const bool BIG_ENDIAN = $$PLATFORM_BIG_ENDIAN;
|
||||
const bool I128_NATIVE_SUPPORT = $$PLATFORM_I128_SUPPORTED;
|
||||
const bool F16_SUPPORT = $$PLATFORM_F16_SUPPORTED;
|
||||
@@ -62,7 +70,7 @@ const bool COMPILER_SAFE_MODE = $$COMPILER_SAFE_MODE;
|
||||
const usz LLVM_VERSION = $$LLVM_VERSION;
|
||||
const bool BENCHMARKING = $$BENCHMARKING;
|
||||
const bool TESTING = $$TESTING;
|
||||
const usz TEMP_ALLOCATOR_SIZE = 128 * 1024;
|
||||
const MemoryEnvironment MEMORY_ENV = (MemoryEnvironment)$$MEMORY_ENVIRONMENT;
|
||||
|
||||
macro bool os_is_posix()
|
||||
{
|
||||
@@ -86,4 +94,5 @@ macro bool os_is_posix()
|
||||
$echo("Assuming non-Posix environment");
|
||||
return false;
|
||||
$endswitch;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -275,7 +275,16 @@ macro TempAllocator* temp_allocator()
|
||||
{
|
||||
if (!thread_temp_allocator)
|
||||
{
|
||||
thread_temp_allocator = allocator::new_temp(env::TEMP_ALLOCATOR_SIZE, allocator::LIBC_ALLOCATOR)!!;
|
||||
$switch (env::MEMORY_ENV):
|
||||
$case NORMAL:
|
||||
thread_temp_allocator = allocator::new_temp(1024 * 256, allocator::LIBC_ALLOCATOR)!!;
|
||||
$case SMALL:
|
||||
thread_temp_allocator = allocator::new_temp(1024 * 16, allocator::LIBC_ALLOCATOR)!!;
|
||||
$case TINY:
|
||||
thread_temp_allocator = allocator::new_temp(1024 * 4, allocator::LIBC_ALLOCATOR)!!;
|
||||
$case NONE:
|
||||
unreachable("Temp allocator must explicitly created when memory-env is set to 'none'.");
|
||||
$endswitch;
|
||||
}
|
||||
return thread_temp_allocator;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user