From: Brendan Hansen Date: Sat, 22 Apr 2023 18:02:08 +0000 (-0500) Subject: cleanup: random old code X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=18f9b01c22e08b330a1acfdb03b84d8e2fc1c49c;p=onyx.git cleanup: random old code --- diff --git a/core/io/stdio.onyx b/core/io/stdio.onyx index 1ecaba0a..05239148 100644 --- a/core/io/stdio.onyx +++ b/core/io/stdio.onyx @@ -187,8 +187,7 @@ __byte_dump :: (ptr: rawptr, byte_count: u32, bytes_per_line := 8) { read = (_: &io.Stream, buffer: [] u8) -> (io.Error, u32) { __flush_stdio(); bytes_read := runtime.platform.__read_from_input(buffer); - if bytes_read == 0 do return .ReadPending, 0; - if bytes_read < 0 do return .EOF, 0; + if bytes_read <= 0 do return .EOF, 0; return .None, bytes_read; }, diff --git a/core/runtime/platform/onyx/fs.onyx b/core/runtime/platform/onyx/fs.onyx index 63551dcf..7a3e8345 100644 --- a/core/runtime/platform/onyx/fs.onyx +++ b/core/runtime/platform/onyx/fs.onyx @@ -27,9 +27,6 @@ DirectoryData :: #distinct u64 __dir_read :: (dir: DirectoryData, out_entry: &os.DirectoryEntry) -> bool --- __dir_create :: (path: str) -> bool --- __dir_remove :: (path: str) -> bool --- - - - __enable_non_blocking_stdin :: () -> void --- } } diff --git a/core/runtime/platform/wasi/env.onyx b/core/runtime/platform/wasi/env.onyx index 9a30284f..0a7a8d19 100644 --- a/core/runtime/platform/wasi/env.onyx +++ b/core/runtime/platform/wasi/env.onyx @@ -34,7 +34,7 @@ get_env :: (allocator := context.allocator) -> Environment { while i := cast(i32) (env_var.count - 1); i >= 0 { defer i -= 1; - env_var[i] = cast(cstr) (cast(&u32) env_var.data)[i]; + env_var[i] = cast(cstr) (cast([&]u32) env_var.data)[i]; } env_map := map.make(str, str, ""); @@ -44,7 +44,8 @@ get_env :: (allocator := context.allocator) -> Environment { map.put(&env_map, var, string.advance(s, 1)); } - raw_free(allocator, env_var.data); + // raw_free(allocator, env_var.data); + memory.free_slice(&env_var, allocator); return .{ vars = env_map, diff --git a/core/runtime/platform/wasi/platform.onyx b/core/runtime/platform/wasi/platform.onyx index 92d38879..ea96bac7 100644 --- a/core/runtime/platform/wasi/platform.onyx +++ b/core/runtime/platform/wasi/platform.onyx @@ -92,7 +92,7 @@ __start :: () { argv_buf_size : Size; args_sizes_get(&args.count, &argv_buf_size); - args = memory.make_slice(cstr, args.count); + args = core.memory.make_slice(cstr, args.count); argv_buf := cast(cstr) calloc(argv_buf_size); args_get(args.data, argv_buf); @@ -107,7 +107,7 @@ __start :: () { while i := cast(i32) (args.count - 1); i >= 0 { defer i -= 1; - args[i] = cast(cstr) (cast(&u32) args.data)[i]; + args[i] = cast(cstr) (cast([&] u32) args.data)[i]; } (package main).main(args); diff --git a/runtime/onyx_runtime.c b/runtime/onyx_runtime.c index aa3af073..deb4d2ae 100644 --- a/runtime/onyx_runtime.c +++ b/runtime/onyx_runtime.c @@ -48,10 +48,6 @@ ONYX_LIBRARY { ONYX_FUNC(__file_get_standard) ONYX_FUNC(__file_rename) -#ifdef _BH_LINUX - ONYX_FUNC(__enable_non_blocking_stdin) -#endif - ONYX_FUNC(__dir_open) ONYX_FUNC(__dir_read) ONYX_FUNC(__dir_close) diff --git a/runtime/src/ort_files.h b/runtime/src/ort_files.h index b6f90491..de6e3e0b 100644 --- a/runtime/src/ort_files.h +++ b/runtime/src/ort_files.h @@ -210,12 +210,3 @@ ONYX_DEF(__file_rename, (WASM_I32, WASM_I32, WASM_I32, WASM_I32), (WASM_I32)) { #endif } -#ifdef _BH_LINUX -ONYX_DEF(__enable_non_blocking_stdin, (), ()) { - int flags = fcntl(STDIN_FILENO, F_GETFL, 0); - flags |= O_NONBLOCK; - fcntl(STDIN_FILENO, F_SETFL, flags); - - return NULL; -} -#endif diff --git a/runtime/src/ort_threads.h b/runtime/src/ort_threads.h index 46dad346..8af6fc06 100644 --- a/runtime/src/ort_threads.h +++ b/runtime/src/ort_threads.h @@ -51,7 +51,7 @@ static i32 onyx_run_thread(void *data) { i32 thread_id = thread->id; { // Call the _thread_start procedure - wasm_val_t args[] = { + wasm_val_t args[7] = { WASM_I32_VAL(thread_id), WASM_I32_VAL(thread->tls_base), WASM_I32_VAL(thread->stack_base), diff --git a/tests/aoc-2021/day12.onyx b/tests/aoc-2021/day12.onyx index c4723a9f..d253b7d7 100644 --- a/tests/aoc-2021/day12.onyx +++ b/tests/aoc-2021/day12.onyx @@ -7,7 +7,7 @@ Communative_Pair :: struct (T: type_expr) where hash.Hashable(T) { } #match hash.to_u32 (p: Communative_Pair($T)) => { - return hash.to_u32(p.a) * 13 + hash.to_u32(p.b) * 17; + return hash.to_u32(p.a) * hash.to_u32(p.b); } #operator == (p1, p2: Communative_Pair($T)) => {