mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-16 16:01:26 -07:00
wasi: make the demo run on wasi and run it in CI
This commit is contained in:
@@ -95,7 +95,6 @@ tag_register_number :: proc(impl: Tag_Implementation, nr: Tag_Number, id: string
|
||||
}
|
||||
|
||||
// Controls initialization of default tag implementations.
|
||||
// JS and WASI default to a panic allocator so we don't want to do it on those.
|
||||
INITIALIZE_DEFAULT_TAGS :: #config(CBOR_INITIALIZE_DEFAULT_TAGS, !ODIN_DEFAULT_TO_PANIC_ALLOCATOR && !ODIN_DEFAULT_TO_NIL_ALLOCATOR)
|
||||
|
||||
@(private, init, disabled=!INITIALIZE_DEFAULT_TAGS)
|
||||
|
||||
@@ -6,6 +6,8 @@ import "base:runtime"
|
||||
Handle :: distinct i32
|
||||
Errno :: distinct i32
|
||||
|
||||
INVALID_HANDLE :: -1
|
||||
|
||||
ERROR_NONE :: Errno(wasi.errno_t.SUCCESS)
|
||||
|
||||
O_RDONLY :: 0x00000
|
||||
@@ -26,6 +28,16 @@ stdout: Handle = 1
|
||||
stderr: Handle = 2
|
||||
current_dir: Handle = 3
|
||||
|
||||
args := _alloc_command_line_arguments()
|
||||
|
||||
_alloc_command_line_arguments :: proc() -> (args: []string) {
|
||||
args = make([]string, len(runtime.args__))
|
||||
for &arg, i in args {
|
||||
arg = string(runtime.args__[i])
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
write :: proc(fd: Handle, data: []byte) -> (int, Errno) {
|
||||
iovs := wasi.ciovec_t(data)
|
||||
n, err := wasi.fd_write(wasi.fd_t(fd), {iovs})
|
||||
|
||||
@@ -6,6 +6,8 @@ import "base:intrinsics"
|
||||
|
||||
_ :: intrinsics
|
||||
|
||||
IS_SUPPORTED :: _IS_SUPPORTED
|
||||
|
||||
Thread_Proc :: #type proc(^Thread)
|
||||
|
||||
MAX_USER_ARGUMENTS :: 8
|
||||
@@ -58,7 +60,9 @@ Thread :: struct {
|
||||
creation_allocator: mem.Allocator,
|
||||
}
|
||||
|
||||
#assert(size_of(Thread{}.user_index) == size_of(uintptr))
|
||||
when IS_SUPPORTED {
|
||||
#assert(size_of(Thread{}.user_index) == size_of(uintptr))
|
||||
}
|
||||
|
||||
Thread_Priority :: enum {
|
||||
Normal,
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
//+build js
|
||||
package thread
|
||||
|
||||
import "base:intrinsics"
|
||||
import "core:sync"
|
||||
import "core:mem"
|
||||
|
||||
Thread_Os_Specific :: struct {}
|
||||
|
||||
_thread_priority_map := [Thread_Priority]i32{
|
||||
.Normal = 0,
|
||||
.Low = -2,
|
||||
.High = +2,
|
||||
}
|
||||
|
||||
_create :: proc(procedure: Thread_Proc, priority := Thread_Priority.Normal) -> ^Thread {
|
||||
unimplemented("core:thread procedure not supported on js target")
|
||||
}
|
||||
|
||||
_start :: proc(t: ^Thread) {
|
||||
unimplemented("core:thread procedure not supported on js target")
|
||||
}
|
||||
|
||||
_is_done :: proc(t: ^Thread) -> bool {
|
||||
unimplemented("core:thread procedure not supported on js target")
|
||||
}
|
||||
|
||||
_join :: proc(t: ^Thread) {
|
||||
unimplemented("core:thread procedure not supported on js target")
|
||||
}
|
||||
|
||||
_join_multiple :: proc(threads: ..^Thread) {
|
||||
unimplemented("core:thread procedure not supported on js target")
|
||||
}
|
||||
|
||||
_destroy :: proc(thread: ^Thread) {
|
||||
unimplemented("core:thread procedure not supported on js target")
|
||||
}
|
||||
|
||||
_terminate :: proc(using thread : ^Thread, exit_code: int) {
|
||||
unimplemented("core:thread procedure not supported on js target")
|
||||
}
|
||||
|
||||
_yield :: proc() {
|
||||
unimplemented("core:thread procedure not supported on js target")
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
//+build js, wasi, orca
|
||||
package thread
|
||||
|
||||
import "base:intrinsics"
|
||||
|
||||
_IS_SUPPORTED :: false
|
||||
|
||||
Thread_Os_Specific :: struct {}
|
||||
|
||||
_thread_priority_map := [Thread_Priority]i32{
|
||||
.Normal = 0,
|
||||
.Low = -2,
|
||||
.High = +2,
|
||||
}
|
||||
|
||||
_create :: proc(procedure: Thread_Proc, priority := Thread_Priority.Normal) -> ^Thread {
|
||||
unimplemented("core:thread procedure not supported on target")
|
||||
}
|
||||
|
||||
_start :: proc(t: ^Thread) {
|
||||
unimplemented("core:thread procedure not supported on target")
|
||||
}
|
||||
|
||||
_is_done :: proc(t: ^Thread) -> bool {
|
||||
unimplemented("core:thread procedure not supported on target")
|
||||
}
|
||||
|
||||
_join :: proc(t: ^Thread) {
|
||||
unimplemented("core:thread procedure not supported on target")
|
||||
}
|
||||
|
||||
_join_multiple :: proc(threads: ..^Thread) {
|
||||
unimplemented("core:thread procedure not supported on target")
|
||||
}
|
||||
|
||||
_destroy :: proc(thread: ^Thread) {
|
||||
unimplemented("core:thread procedure not supported on target")
|
||||
}
|
||||
|
||||
_terminate :: proc(using thread : ^Thread, exit_code: int) {
|
||||
unimplemented("core:thread procedure not supported on target")
|
||||
}
|
||||
|
||||
_yield :: proc() {
|
||||
unimplemented("core:thread procedure not supported on target")
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@ import "core:sync"
|
||||
import "core:sys/unix"
|
||||
import "core:time"
|
||||
|
||||
_IS_SUPPORTED :: true
|
||||
|
||||
CAS :: sync.atomic_compare_exchange_strong
|
||||
|
||||
// NOTE(tetra): Aligned here because of core/unix/pthread_linux.odin/pthread_t.
|
||||
|
||||
@@ -6,6 +6,8 @@ import "base:intrinsics"
|
||||
import "core:sync"
|
||||
import win32 "core:sys/windows"
|
||||
|
||||
_IS_SUPPORTED :: true
|
||||
|
||||
Thread_Os_Specific :: struct {
|
||||
win32_thread: win32.HANDLE,
|
||||
win32_thread_id: win32.DWORD,
|
||||
|
||||
Reference in New Issue
Block a user