aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorJeroen van Rijn <Kelimion@users.noreply.github.com>2024-11-03 14:07:31 +0100
committerflysand7 <thebumboni@gmail.com>2024-12-01 11:54:52 +1100
commitc5d3fdca444689dfd96029e605a4d6e9f9d792c5 (patch)
tree4f97a56455ca579faf9a525e0a54bef4aac76188 /core
parentee84aa4ead1e06d29a112366842df7bd6e1bf87e (diff)
`mem.is_aligned` is in bytes, not log2 bytes
Fix formula and clarify comment
Diffstat (limited to 'core')
-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..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<<uintptr(align) - 1)) == 0
+ return (p & (uintptr(align) - 1) == 0
}
/*