diff options
| author | Matteo Gmür <matteo.gmuer1@ost.ch> | 2025-04-27 09:32:59 +0000 |
|---|---|---|
| committer | Matteo Gmür <matteo.gmuer1@ost.ch> | 2025-04-27 09:32:59 +0000 |
| commit | 5f149faeb9d41bb56733075b0e56908b3731d38d (patch) | |
| tree | 92e58f90cfefed50b25026cc8887d74f7245811a /arch/x86_64/src/memory | |
| parent | 0986058bb9ca5b4afd7c578c815dc3a4c08808a9 (diff) | |
| download | teachos-5f149faeb9d41bb56733075b0e56908b3731d38d.tar.xz teachos-5f149faeb9d41bb56733075b0e56908b3731d38d.zip | |
Move gnu function attributes to header file
Diffstat (limited to 'arch/x86_64/src/memory')
| -rw-r--r-- | arch/x86_64/src/memory/heap/bump_allocator.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/arch/x86_64/src/memory/heap/bump_allocator.cpp b/arch/x86_64/src/memory/heap/bump_allocator.cpp index df95346..525f45c 100644 --- a/arch/x86_64/src/memory/heap/bump_allocator.cpp +++ b/arch/x86_64/src/memory/heap/bump_allocator.cpp @@ -24,11 +24,13 @@ namespace teachos::arch::memory::heap auto bump_allocator::allocate(std::size_t size) -> void * { + // Reading the value only has to be done once, because compare_exchange_weak updates the value as well if the + // exchange failed, becuase the value was not the expected one. + auto alloc_start = next.load(std::memory_order::relaxed); // Repeat allocation until it succeeds, has to be done, because another allocator could overtake it at any time // causing the value to differ and the calculation to have to be redone. for (;;) { - auto alloc_start = next.load(std::memory_order::relaxed); auto const alloc_end = saturating_add(alloc_start, size); arch::exception_handling::assert(alloc_end <= heap_end, "[Heap Allocator] Out of memory"); // Check if the atomic value is still the one initally loaded, if it isn't we have been overtaken by another |
