mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-31 03:40:08 +00:00
Begin work in semi-standardized js_wasm32 target
This commit is contained in:
@@ -528,5 +528,5 @@ default_assertion_failure_proc :: proc(prefix, message: string, loc: Source_Code
|
||||
}
|
||||
print_byte('\n')
|
||||
}
|
||||
intrinsics.trap()
|
||||
trap()
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
//+build !windows
|
||||
//+build !freestanding
|
||||
//+build !wasi
|
||||
//+build !js
|
||||
package runtime
|
||||
|
||||
when ODIN_DEFAULT_TO_NIL_ALLOCATOR {
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
//+build js
|
||||
package runtime
|
||||
|
||||
default_allocator_proc :: nil_allocator_proc
|
||||
default_allocator :: nil_allocator
|
||||
@@ -3,7 +3,7 @@ package runtime
|
||||
DEFAULT_TEMP_ALLOCATOR_BACKING_SIZE: int : #config(DEFAULT_TEMP_ALLOCATOR_BACKING_SIZE, 1<<22)
|
||||
|
||||
|
||||
when ODIN_OS == "freestanding" || ODIN_DEFAULT_TO_NIL_ALLOCATOR {
|
||||
when ODIN_OS == "freestanding" || ODIN_OS == "js" || ODIN_DEFAULT_TO_NIL_ALLOCATOR {
|
||||
Default_Temp_Allocator :: struct {}
|
||||
|
||||
default_temp_allocator_init :: proc(s: ^Default_Temp_Allocator, size: int, backup_allocator := context.allocator) {}
|
||||
|
||||
@@ -9,7 +9,7 @@ RUNTIME_LINKAGE :: "strong" when (
|
||||
!ODIN_NO_CRT) &&
|
||||
!(ODIN_ARCH == "wasm32" ||
|
||||
ODIN_ARCH == "wasm64")) else "internal"
|
||||
RUNTIME_REQUIRE :: !(ODIN_ARCH == "wasm32" || ODIN_ARCH == "wasm64")
|
||||
RUNTIME_REQUIRE :: true
|
||||
|
||||
|
||||
@(private)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//+build !freestanding !wasi !windows
|
||||
//+build !freestanding !wasi !windows !js
|
||||
package runtime
|
||||
|
||||
import "core:os"
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
//+build js
|
||||
package runtime
|
||||
|
||||
foreign import "odin_env"
|
||||
|
||||
_os_write :: proc "contextless" (data: []byte) -> (int, _OS_Errno) {
|
||||
foreign odin_env {
|
||||
write :: proc "c" (fd: u32, p: []byte) ---
|
||||
}
|
||||
write(1, data)
|
||||
return len(data), 0
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
//+build js wasm32
|
||||
package runtime
|
||||
|
||||
init_default_context_for_js: Context
|
||||
@(init, private="file")
|
||||
init_default_context :: proc() {
|
||||
init_default_context_for_js = context
|
||||
}
|
||||
|
||||
@(export)
|
||||
@(link_name="default_context_ptr")
|
||||
default_context_ptr :: proc "contextless" () -> ^Context {
|
||||
return &init_default_context_for_js
|
||||
}
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
package runtime
|
||||
|
||||
@(link_name="__ashlti3", linkage="strong")
|
||||
__ashlti3 :: proc "c" (a: i64, b: u32) -> i64 {
|
||||
__ashlti3 :: proc "c" (a: i64, b_: i32) -> i64 {
|
||||
/*
|
||||
b := u32(b_)
|
||||
input := transmute([2]i32)a
|
||||
result: [2]i32
|
||||
if b & 32 != 0 {
|
||||
@@ -16,4 +18,6 @@ __ashlti3 :: proc "c" (a: i64, b: u32) -> i64 {
|
||||
result[1] = (input[1]<<b) | (input[0]>>(32-b))
|
||||
}
|
||||
return transmute(i64)result
|
||||
*/
|
||||
return 0
|
||||
}
|
||||
Reference in New Issue
Block a user