From 33214c29d38f958ca968a6a39d4d52cbf0d0d5d6 Mon Sep 17 00:00:00 2001 From: Idan Horowitz Date: Tue, 5 Jul 2022 01:16:42 +0300 Subject: [PATCH] AK: Add an align_down_to power of two helper Matching the similar align_up_to helper --- AK/Types.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/AK/Types.h b/AK/Types.h index bf223afca9..b478185e60 100644 --- a/AK/Types.h +++ b/AK/Types.h @@ -84,6 +84,11 @@ constexpr size_t align_up_to(const size_t value, const size_t alignment) return (value + (alignment - 1)) & ~(alignment - 1); } +constexpr size_t align_down_to(const size_t value, const size_t alignment) +{ + return value & ~(alignment - 1); +} + enum class [[nodiscard]] TriState : u8 { False, True,