mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Add Freestanding OS Types (#2399)
* Add Freestanding OS Types to `env::`
This commit is contained in:
@@ -154,7 +154,12 @@ const bool NETBSD = LIBC && OS_TYPE == NETBSD;
|
||||
const bool BSD_FAMILY = env::FREEBSD || env::OPENBSD || env::NETBSD;
|
||||
const bool WASI = LIBC && OS_TYPE == WASI;
|
||||
const bool ANDROID = LIBC && OS_TYPE == ANDROID;
|
||||
const bool WASM_NOLIBC @builtin = !LIBC && ARCH_TYPE == ArchType.WASM32 || ARCH_TYPE == ArchType.WASM64;
|
||||
const bool WASM_NOLIBC @builtin @deprecated("Use 'FREESTANDING_WASM' instead") = !LIBC && ARCH_TYPE == ArchType.WASM32 || ARCH_TYPE == ArchType.WASM64;
|
||||
const bool FREESTANDING_PE32 = NO_LIBC && OS_TYPE == WIN32;
|
||||
const bool FREESTANDING_MACHO = NO_LIBC && OS_TYPE == MACOS;
|
||||
const bool FREESTANDING_ELF = NO_LIBC && !env::FREESTANDING_PE32 && !env::FREESTANDING_MACHO && !env::FREESTANDING_WASM;
|
||||
const bool FREESTANDING_WASM = NO_LIBC && (ARCH_TYPE == ArchType.WASM32 || ARCH_TYPE == ArchType.WASM64);
|
||||
const bool FREESTANDING = env::FREESTANDING_PE32 || env::FREESTANDING_MACHO || env::FREESTANDING_ELF || env::FREESTANDING_WASM;
|
||||
const bool ADDRESS_SANITIZER = $$ADDRESS_SANITIZER;
|
||||
const bool MEMORY_SANITIZER = $$MEMORY_SANITIZER;
|
||||
const bool THREAD_SANITIZER = $$THREAD_SANITIZER;
|
||||
|
||||
@@ -646,7 +646,7 @@ macro void @pool(usz reserve = 0; @body) @builtin
|
||||
@body();
|
||||
}
|
||||
|
||||
module std::core::mem @if(WASM_NOLIBC);
|
||||
module std::core::mem @if(env::FREESTANDING_WASM);
|
||||
import std::core::mem::allocator @public;
|
||||
SimpleHeapAllocator wasm_allocator @private;
|
||||
extern int __heap_base;
|
||||
|
||||
@@ -511,7 +511,7 @@ macro Allocator temp() @deprecated("Use 'tmem' instead")
|
||||
|
||||
alias tmem @builtin = current_temp;
|
||||
|
||||
fn void allow_implicit_temp_allocator_on_load_thread() @init(1) @local @if(env::LIBC || env::WASM_NOLIBC)
|
||||
fn void allow_implicit_temp_allocator_on_load_thread() @init(1) @local @if(env::LIBC || env::FREESTANDING_WASM)
|
||||
{
|
||||
auto_create_temp = true;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ macro @enum_lookup_new($Type, $name, value)
|
||||
}
|
||||
|
||||
|
||||
module std::core::runtime @if(WASM_NOLIBC);
|
||||
module std::core::runtime @if(env::FREESTANDING_WASM);
|
||||
|
||||
extern fn void __wasm_call_ctors();
|
||||
fn void wasm_initialize() @extern("_initialize") @wasm
|
||||
|
||||
@@ -72,7 +72,7 @@ macro uint hash(value) @local
|
||||
return (uint)a5hash::hash(&&bitcast(value, char[$sizeof(value)]));
|
||||
}
|
||||
|
||||
fn char[8 * 4] entropy() @if(!env::WASM_NOLIBC)
|
||||
fn char[8 * 4] entropy() @if(!env::FREESTANDING_WASM)
|
||||
{
|
||||
void* addr = malloc(1);
|
||||
free(addr);
|
||||
@@ -91,7 +91,7 @@ fn char[8 * 4] entropy() @if(!env::WASM_NOLIBC)
|
||||
return bitcast(entropy_data, char[8 * 4]);
|
||||
}
|
||||
|
||||
fn char[8 * 4] entropy() @if(env::WASM_NOLIBC)
|
||||
fn char[8 * 4] entropy() @if(env::FREESTANDING_WASM)
|
||||
{
|
||||
static uint random_int;
|
||||
random_int += 0xedf19156;
|
||||
|
||||
Reference in New Issue
Block a user