mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-03 22:28:46 +00:00
mem.is_aligned is in bytes, not log2 bytes
Fix formula and clarify comment
This commit is contained in:
committed by
flysand7
parent
ee84aa4ead
commit
c5d3fdca44
+3
-1
@@ -461,10 +461,12 @@ Check if a pointer is aligned.
|
|||||||
|
|
||||||
This procedure checks whether a pointer `x` is aligned to a boundary specified
|
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.
|
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 {
|
is_aligned :: proc "contextless" (x: rawptr, align: int) -> bool {
|
||||||
p := uintptr(x)
|
p := uintptr(x)
|
||||||
return (p & (1<<uintptr(align) - 1)) == 0
|
return (p & (uintptr(align) - 1) == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user