소스 검색

Merge pull request #4447 from Kelimion/is_aligned

`mem.is_aligned` is in bytes, not log2 bytes
Jeroen van Rijn 10 달 전
부모
커밋
468bd3dfde
1개의 변경된 파일3개의 추가작업 그리고 1개의 파일을 삭제
  1. 3 1
      core/mem/mem.odin

+ 3 - 1
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
 }
 
 /*