aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeroen van Rijn <Kelimion@users.noreply.github.com>2024-11-03 14:16:23 +0100
committerGitHub <noreply@github.com>2024-11-03 14:16:23 +0100
commit468bd3dfdeeba97c6c5f3f62228c3fa30d730196 (patch)
treeb1f6e8431caf864ea279a3c344b9f43a56a7a33b
parent7cfaf0b181ef53e783b8b8be30d05538477f3511 (diff)
parentc33d2ff96bc2104f6b5cd794fd589ecd32687d09 (diff)
Merge pull request #4447 from Kelimion/is_aligned
`mem.is_aligned` is in bytes, not log2 bytes
-rw-r--r--core/mem/mem.odin4
1 files changed, 3 insertions, 1 deletions
diff --git a/core/mem/mem.odin b/core/mem/mem.odin
index 67ed56c39..ccbc77798 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<<uintptr(align) - 1)) == 0
+ return (p & (uintptr(align) - 1)) == 0
}
/*