20#ifndef KERNEL_TARGETINFO_H
21#define KERNEL_TARGETINFO_H
22#include "pedigree/kernel/processor/types.h"
26#if !defined(TARGET_IS_LITTLE_ENDIAN)
27#error TARGET_IS_LITTLE_ENDIAN not defined
41 return PEDIGREE_TARGET_PAGE_SIZE;
44 static constexpr size_t getPageShift() noexcept {
47 while (pageSize > 1) {
54 static constexpr size_t getPageOffsetMask() noexcept {
58 static constexpr size_t getPointerBits() noexcept {
59 return sizeof(
void*) * __CHAR_BIT__;
62 static constexpr bool isLittleEndian() noexcept {
63 return TARGET_IS_LITTLE_ENDIAN != 0;
69 "The compatibility page-size macro must match TargetInfo.");
71 "Target page size must be a power of two.");
73 "Target page size and shift must agree.");
74static_assert(
sizeof(uintptr_t) ==
sizeof(
void*),
"uintptr_t must have the target pointer width.");
75static_assert(
sizeof(size_t) ==
sizeof(uintptr_t),
76 "size_t and uintptr_t must have the same target width.");
78#if defined(BITS_64) && BITS_64
79static_assert(TargetInfo::getPointerBits() == 64,
"BITS_64 disagrees with the compiler target.");
82#if defined(BITS_32) && BITS_32
83static_assert(TargetInfo::getPointerBits() == 32,
"BITS_32 disagrees with the compiler target.");
86#if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__)
87static_assert(TargetInfo::isLittleEndian() == (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__),
88 "Configured target endianness disagrees with the compiler target.");
static constexpr size_t getPageSize() noexcept