Make Linked elements BSS conform
This commit is contained in:
@@ -10,18 +10,26 @@ namespace JabyEngine {
|
||||
|
||||
static constexpr uint32_t TerminationValue = 0x00FFFFFF;
|
||||
|
||||
uint32_t value = TerminationValue;
|
||||
static constexpr uint32_t default_link_value(size_t size) {
|
||||
return SizeRange.as_value(size >> 2) | TerminationValue;
|
||||
}
|
||||
|
||||
uint32_t link_value;
|
||||
|
||||
constexpr Link() = default;
|
||||
constexpr Link(size_t size) : value(SizeRange.as_value(size >> 2) | TerminationValue) {
|
||||
constexpr Link(size_t size) : link_value(default_link_value(size)) {
|
||||
}
|
||||
|
||||
constexpr void set_link_identitiy(size_t size) {
|
||||
this->link_value = default_link_value(size);
|
||||
}
|
||||
|
||||
void set_adr(const void* adr) {
|
||||
this->value = bit::value::set_normalized(this->value, AdrRange.with(reinterpret_cast<uint32_t>(adr)));
|
||||
this->link_value = bit::value::set_normalized(this->link_value, AdrRange.with(reinterpret_cast<uint32_t>(adr)));
|
||||
}
|
||||
|
||||
void* get_adr() const {
|
||||
return reinterpret_cast<void*>(bit::value::get_normalized(this->value, AdrRange));
|
||||
return reinterpret_cast<void*>(bit::value::get_normalized(this->link_value, AdrRange));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
@@ -45,7 +53,7 @@ namespace JabyEngine {
|
||||
}
|
||||
|
||||
constexpr void terminate() {
|
||||
this->value |= TerminationValue;
|
||||
this->link_value |= TerminationValue;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -59,6 +67,10 @@ namespace JabyEngine {
|
||||
constexpr LinkedElement(const T& element) : Link(sizeof(T)), element(element) {
|
||||
}
|
||||
|
||||
constexpr void set_link_identitiy() {
|
||||
Link::set_link_identitiy(sizeof(T));
|
||||
}
|
||||
|
||||
constexpr const T* operator->() const {
|
||||
return &this->element;
|
||||
}
|
||||
|
Reference in New Issue
Block a user