From a141c401f78467bc15f62882fca5d55a007cacbb Mon Sep 17 00:00:00 2001 From: Steven Le Rouzic Date: Mon, 17 Feb 2025 00:21:48 +0100 Subject: Reorganize everything --- asl/memory/layout.hpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 asl/memory/layout.hpp (limited to 'asl/memory/layout.hpp') diff --git a/asl/memory/layout.hpp b/asl/memory/layout.hpp new file mode 100644 index 0000000..af867d8 --- /dev/null +++ b/asl/memory/layout.hpp @@ -0,0 +1,37 @@ +#pragma once + +#include "asl/base/integers.hpp" +#include "asl/base/meta.hpp" + +namespace asl +{ + +template +inline constexpr isize_t size_of = static_cast(sizeof(T)); + +template +inline constexpr isize_t align_of = static_cast(alignof(T)); + +struct layout +{ + isize_t size; + isize_t align; + + constexpr bool operator==(const layout&) const = default; + + template + static constexpr layout of() + { + return layout{ size_of, align_of }; + } + + template + static constexpr layout array(isize_t size) + { + return layout{ size_of * size, align_of }; + } +}; + +} // namespace asl + +#define AslOffsetOf(S, M) (static_cast(__builtin_offsetof(S, M))) -- cgit