From 27cbd0d93147cbf00f289375ae4e09e94d99610f Mon Sep 17 00:00:00 2001 From: flysand7 Date: Tue, 24 Oct 2023 10:23:38 +1100 Subject: [PATCH 1/4] GLFW binding fixes --- vendor/glfw/bindings/bindings.odin | 2 +- vendor/glfw/bindings/types.odin | 2 +- vendor/glfw/wrapper.odin | 14 +++++++++++++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/vendor/glfw/bindings/bindings.odin b/vendor/glfw/bindings/bindings.odin index 891d06a93..afe5a3081 100644 --- a/vendor/glfw/bindings/bindings.odin +++ b/vendor/glfw/bindings/bindings.odin @@ -39,7 +39,7 @@ when ODIN_OS == .Windows { /*** Functions ***/ @(default_calling_convention="c", link_prefix="glfw") foreign glfw { - Init :: proc() -> c.int --- + Init :: proc() -> bool --- Terminate :: proc() --- InitHint :: proc(hint, value: c.int) --- diff --git a/vendor/glfw/bindings/types.odin b/vendor/glfw/bindings/types.odin index 89640075a..a3bee3fae 100644 --- a/vendor/glfw/bindings/types.odin +++ b/vendor/glfw/bindings/types.odin @@ -41,7 +41,7 @@ WindowMaximizeProc :: #type proc "c" (window: WindowHandle, iconified: c.int WindowContentScaleProc :: #type proc "c" (window: WindowHandle, xscale, yscale: f32) FramebufferSizeProc :: #type proc "c" (window: WindowHandle, width, height: c.int) DropProc :: #type proc "c" (window: WindowHandle, count: c.int, paths: [^]cstring) -MonitorProc :: #type proc "c" (window: WindowHandle) +MonitorProc :: #type proc "c" (window: WindowHandle, event: c.int) KeyProc :: #type proc "c" (window: WindowHandle, key, scancode, action, mods: c.int) MouseButtonProc :: #type proc "c" (window: WindowHandle, button, action, mods: c.int) diff --git a/vendor/glfw/wrapper.odin b/vendor/glfw/wrapper.odin index 2c09731ca..5fa56ddf2 100644 --- a/vendor/glfw/wrapper.odin +++ b/vendor/glfw/wrapper.odin @@ -49,7 +49,19 @@ SetGammaRamp :: glfw.SetGammaRamp CreateWindow :: glfw.CreateWindow DestroyWindow :: glfw.DestroyWindow -WindowHint :: glfw.WindowHint +WindowHint_int :: proc "contextless" (hint: c.int, value: c.int) { + glfw.WindowHint(hint, value) +} + +WindowHint_bool :: proc "contextless" (hint: c.int, value: bool) { + glfw.WindowHint(hint, cast(c.int) value) +} + +WindowHint :: proc { + WindowHint_int, + WindowHint_bool, +} + DefaultWindowHints :: glfw.DefaultWindowHints WindowHintString :: glfw.WindowHintString WindowShouldClose :: glfw.WindowShouldClose From 7e40a5a7113f48a9b54c04e0af6f1ec1b22eddff Mon Sep 17 00:00:00 2001 From: flysand7 Date: Tue, 24 Oct 2023 10:28:11 +1100 Subject: [PATCH 2/4] Change bool to b32 --- vendor/glfw/bindings/bindings.odin | 2 +- vendor/glfw/wrapper.odin | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/vendor/glfw/bindings/bindings.odin b/vendor/glfw/bindings/bindings.odin index afe5a3081..ac41bbf52 100644 --- a/vendor/glfw/bindings/bindings.odin +++ b/vendor/glfw/bindings/bindings.odin @@ -39,7 +39,7 @@ when ODIN_OS == .Windows { /*** Functions ***/ @(default_calling_convention="c", link_prefix="glfw") foreign glfw { - Init :: proc() -> bool --- + Init :: proc() -> b32 --- Terminate :: proc() --- InitHint :: proc(hint, value: c.int) --- diff --git a/vendor/glfw/wrapper.odin b/vendor/glfw/wrapper.odin index 5fa56ddf2..db0e8364e 100644 --- a/vendor/glfw/wrapper.odin +++ b/vendor/glfw/wrapper.odin @@ -53,7 +53,7 @@ WindowHint_int :: proc "contextless" (hint: c.int, value: c.int) { glfw.WindowHint(hint, value) } -WindowHint_bool :: proc "contextless" (hint: c.int, value: bool) { +WindowHint_bool :: proc "contextless" (hint: c.int, value: b32) { glfw.WindowHint(hint, cast(c.int) value) } From ba536d67b4e08e1149f78eea46377d727f6d7251 Mon Sep 17 00:00:00 2001 From: jakubtomsu <66876057+jakubtomsu@users.noreply.github.com> Date: Wed, 25 Oct 2023 22:17:38 +0200 Subject: [PATCH 3/4] Change and to or --- src/check_builtin.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/check_builtin.cpp b/src/check_builtin.cpp index 49095a7a8..77ba6b435 100644 --- a/src/check_builtin.cpp +++ b/src/check_builtin.cpp @@ -5170,7 +5170,7 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As Operand op = {}; check_expr(c, &op, ce->args[1]); - if (op.mode != Addressing_Constant && !is_type_integer(op.type)) { + if (op.mode != Addressing_Constant || !is_type_integer(op.type)) { error(op.expr, "Expected a constant integer for the index of procedure parameter value"); return false; } @@ -5229,7 +5229,7 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As Operand op = {}; check_expr(c, &op, ce->args[1]); - if (op.mode != Addressing_Constant && !is_type_integer(op.type)) { + if (op.mode != Addressing_Constant || !is_type_integer(op.type)) { error(op.expr, "Expected a constant integer for the index of procedure parameter value"); return false; } @@ -5307,7 +5307,7 @@ gb_internal bool check_builtin_procedure(CheckerContext *c, Operand *operand, As } else { Operand op = {}; check_expr(c, &op, ce->args[1]); - if (op.mode != Addressing_Constant && !is_type_integer(op.type)) { + if (op.mode != Addressing_Constant || !is_type_integer(op.type)) { error(op.expr, "Expected a constant integer for the index of record parameter value"); return false; } From 962d59999639edfe64fb15c5b4587993c4e4a5ec Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Thu, 26 Oct 2023 14:30:04 +0200 Subject: [PATCH 4/4] Fix reading from `/sys/` pseudo fx --- core/os/os.odin | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/os/os.odin b/core/os/os.odin index b71ea261e..15864e47e 100644 --- a/core/os/os.odin +++ b/core/os/os.odin @@ -63,8 +63,8 @@ read_at_least :: proc(fd: Handle, buf: []byte, min: int) -> (n: int, err: Errno) if len(buf) < min { return 0, -1 } - for n < min && err == 0 { - nn: int + nn := max(int) + for nn > 0 && n < min && err == 0 { nn, err = read(fd, buf[n:]) n += nn }