summaryrefslogtreecommitdiff
path: root/AK
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-09-07 15:39:26 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-09-07 15:39:26 +0200
commitbcfdf9ffa7c17f5f080b5a45d17497be7d1a28f9 (patch)
tree5ada962ae552efe70053fc1dd028e23f4fdeb80b /AK
parentdb48dfcaaf48581531a0557a1c133acf27d84342 (diff)
downloadserenity-bcfdf9ffa7c17f5f080b5a45d17497be7d1a28f9.zip
AK: Add a useful align_up_to(value, power_of_two) function
Diffstat (limited to 'AK')
-rw-r--r--AK/Types.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/AK/Types.h b/AK/Types.h
index be93bedd63..c90299d2bd 100644
--- a/AK/Types.h
+++ b/AK/Types.h
@@ -73,4 +73,9 @@ static_assert(explode_byte(0x80) == 0x80808080);
static_assert(explode_byte(0x7f) == 0x7f7f7f7f);
static_assert(explode_byte(0) == 0);
+inline constexpr size_t align_up_to(const size_t value, const size_t alignment)
+{
+ return (value + (alignment - 1)) & ~(alignment - 1);
+}
+
enum class TriState : u8 { False, True, Unknown };