From 7ebaf2854a2d31ef30691427681286e35130b1ae Mon Sep 17 00:00:00 2001 From: paoda Date: Mon, 11 Mar 2024 10:36:43 -0500 Subject: [PATCH] chore: add force align fn (used in arm32, turbo, and zba) --- src/lib.zig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lib.zig b/src/lib.zig index 686543a..8d64c61 100644 --- a/src/lib.zig +++ b/src/lib.zig @@ -90,3 +90,7 @@ pub inline fn rotr(comptime T: type, x: T, r: anytype) T { const ar: Log2Int(T) = @intCast(@mod(r, @typeInfo(T).Int.bits)); return x >> ar | x << (1 +% ~ar); } + +pub inline fn alignAddr(comptime T: type, address: u32) u32 { + return address & ~@as(u32, @sizeOf(T) - 1); +}