Skip to content

Commit 1dae21d

Browse files
committed
add FREESTANDING_WASM; preserve old builtin for WASM_NOLIBC but deprecate it
1 parent e0a1e6f commit 1dae21d

5 files changed

Lines changed: 9 additions & 8 deletions

File tree

lib/std/core/env.c3

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,12 @@ const bool NETBSD = LIBC && OS_TYPE == NETBSD;
154154
const bool BSD_FAMILY = env::FREEBSD || env::OPENBSD || env::NETBSD;
155155
const bool WASI = LIBC && OS_TYPE == WASI;
156156
const bool ANDROID = LIBC && OS_TYPE == ANDROID;
157-
const bool WASM_NOLIBC = NO_LIBC && (ARCH_TYPE == ArchType.WASM32 || ARCH_TYPE == ArchType.WASM64);
157+
const bool WASM_NOLIBC @builtin @deprecated("Use 'FREESTANDING_WASM' instead") = !LIBC && ARCH_TYPE == ArchType.WASM32 || ARCH_TYPE == ArchType.WASM64;
158158
const bool FREESTANDING_PE32 = NO_LIBC && OS_TYPE == WIN32;
159159
const bool FREESTANDING_MACHO = NO_LIBC && OS_TYPE == MACOS;
160-
const bool FREESTANDING_ELF = NO_LIBC && !env::FREESTANDING_PE32 && !env::FREESTANDING_MACHO && !env::WASM_NOLIBC;
161-
const bool FREESTANDING = env::FREESTANDING_PE32 || env::FREESTANDING_MACHO || env::FREESTANDING_ELF || env::WASM_NOLIBC;
160+
const bool FREESTANDING_ELF = NO_LIBC && !env::FREESTANDING_PE32 && !env::FREESTANDING_MACHO && !env::FREESTANDING_WASM;
161+
const bool FREESTANDING_WASM = NO_LIBC && (ARCH_TYPE == ArchType.WASM32 || ARCH_TYPE == ArchType.WASM64);
162+
const bool FREESTANDING = env::FREESTANDING_PE32 || env::FREESTANDING_MACHO || env::FREESTANDING_ELF || env::FREESTANDING_WASM;
162163
const bool ADDRESS_SANITIZER = $$ADDRESS_SANITIZER;
163164
const bool MEMORY_SANITIZER = $$MEMORY_SANITIZER;
164165
const bool THREAD_SANITIZER = $$THREAD_SANITIZER;

lib/std/core/mem.c3

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ macro void @pool(usz reserve = 0; @body) @builtin
646646
@body();
647647
}
648648

649-
module std::core::mem @if(env::WASM_NOLIBC);
649+
module std::core::mem @if(env::FREESTANDING_WASM);
650650
import std::core::mem::allocator @public;
651651
SimpleHeapAllocator wasm_allocator @private;
652652
extern int __heap_base;

lib/std/core/mem_allocator.c3

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ macro Allocator temp() @deprecated("Use 'tmem' instead")
494494

495495
alias tmem @builtin = current_temp;
496496

497-
fn void allow_implicit_temp_allocator_on_load_thread() @init(1) @local @if(env::LIBC || env::WASM_NOLIBC)
497+
fn void allow_implicit_temp_allocator_on_load_thread() @init(1) @local @if(env::LIBC || env::FREESTANDING_WASM)
498498
{
499499
auto_create_temp = true;
500500
}

lib/std/core/runtime.c3

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ macro @enum_lookup_new($Type, $name, value)
3939
}
4040

4141

42-
module std::core::runtime @if(env::WASM_NOLIBC);
42+
module std::core::runtime @if(env::FREESTANDING_WASM);
4343

4444
extern fn void __wasm_call_ctors();
4545
fn void wasm_initialize() @extern("_initialize") @wasm

lib/std/math/random/math.seeder.c3

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ macro uint hash(value) @local
7272
return (uint)a5hash::hash(&&bitcast(value, char[$sizeof(value)]));
7373
}
7474

75-
fn char[8 * 4] entropy() @if(!env::WASM_NOLIBC)
75+
fn char[8 * 4] entropy() @if(!env::FREESTANDING_WASM)
7676
{
7777
void* addr = malloc(1);
7878
free(addr);
@@ -91,7 +91,7 @@ fn char[8 * 4] entropy() @if(!env::WASM_NOLIBC)
9191
return bitcast(entropy_data, char[8 * 4]);
9292
}
9393

94-
fn char[8 * 4] entropy() @if(env::WASM_NOLIBC)
94+
fn char[8 * 4] entropy() @if(env::FREESTANDING_WASM)
9595
{
9696
static uint random_int;
9797
random_int += 0xedf19156;

0 commit comments

Comments
 (0)