aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-05-05 13:26:01 -0700
committerAndrew Kelley <andrew@ziglang.org>2023-06-10 20:42:28 -0700
commit75cf06c187d9d0288c2ea31f34b18c3a7da4bd1d (patch)
treecc92e5708c46b8d9047d6ec52d32229b59b44f72 /lib
parent41cdcd5486ba10dcd21dc45cb8470c556b7497dd (diff)
downloadzig-75cf06c187d9d0288c2ea31f34b18c3a7da4bd1d.tar.gz
zig-75cf06c187d9d0288c2ea31f34b18c3a7da4bd1d.zip
std.mem.alignForwardGeneric: manually inline the assertions
This matches more directly the documentation comments, and makes it more obvious what went wrong when an assertion fails.
Diffstat (limited to 'lib')
-rw-r--r--lib/std/mem.zig3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/std/mem.zig b/lib/std/mem.zig
index 212d09a1a8..d6ca4a9ea1 100644
--- a/lib/std/mem.zig
+++ b/lib/std/mem.zig
@@ -4226,7 +4226,8 @@ pub fn alignForwardLog2(addr: usize, log2_alignment: u8) usize {
/// The alignment must be a power of 2 and greater than 0.
/// Asserts that rounding up the address does not cause integer overflow.
pub fn alignForwardGeneric(comptime T: type, addr: T, alignment: T) T {
- assert(isValidAlignGeneric(T, alignment));
+ assert(alignment > 0);
+ assert(std.math.isPowerOfTwo(alignment));
return alignBackwardGeneric(T, addr + (alignment - 1), alignment);
}