The Pedigree Project 0.1
ExecutionPersonality.h
1/* Copyright (c) 2026, Pedigree Developers. */
2#ifndef PEDIGREE_EXECUTION_PERSONALITY_H
3#define PEDIGREE_EXECUTION_PERSONALITY_H
4
5#include "pedigree/kernel/processor/types.h"
6
8 public:
9 static constexpr uint32_t Native = 0;
10 static constexpr uint32_t Linux32 = 8;
11 static constexpr uint32_t Query = 0xffffffffU;
12
13 uint32_t value() const {
14 return __atomic_load_n(&m_Value, __ATOMIC_ACQUIRE);
15 }
16 bool select(uint32_t requested, uint32_t& previous) {
17 if (requested == Query) {
18 previous = value();
19 return true;
20 }
21 if (requested != Native && requested != Linux32)
22 return false;
23 previous = __atomic_exchange_n(&m_Value, requested, __ATOMIC_ACQ_REL);
24 return true;
25 }
26 void inherit(const ExecutionPersonality& source) {
27 __atomic_store_n(&m_Value, source.value(), __ATOMIC_RELEASE);
28 }
29
30 private:
31 uint32_t m_Value = Native;
32};
33
34#endif