From 9199c6df3426dddff588c3347a3198e673a1dd11 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Sun, 3 Nov 2024 14:07:31 +0100 Subject: [PATCH 1/2] `mem.is_aligned` is in bytes, not log2 bytes Fix formula and clarify comment --- core/mem/mem.odin | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/mem/mem.odin b/core/mem/mem.odin index 67ed56c39..f00980af5 100644 --- a/core/mem/mem.odin +++ b/core/mem/mem.odin @@ -461,10 +461,12 @@ Check if a pointer is aligned. This procedure checks whether a pointer `x` is aligned to a boundary specified by `align`, and returns `true` if the pointer is aligned, and false otherwise. + +The specified alignment must be a power of 2. */ is_aligned :: proc "contextless" (x: rawptr, align: int) -> bool { p := uintptr(x) - return (p & (1< Date: Sun, 3 Nov 2024 14:10:29 +0100 Subject: [PATCH 2/2] Missing paren. --- core/mem/mem.odin | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/mem/mem.odin b/core/mem/mem.odin index f00980af5..ccbc77798 100644 --- a/core/mem/mem.odin +++ b/core/mem/mem.odin @@ -466,7 +466,7 @@ The specified alignment must be a power of 2. */ is_aligned :: proc "contextless" (x: rawptr, align: int) -> bool { p := uintptr(x) - return (p & (uintptr(align) - 1) == 0 + return (p & (uintptr(align) - 1)) == 0 } /*