mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-08 12:18:31 +00:00
Fix minor suboptimalities in memory manager
This commit is contained in:
parent
76cea6c687
commit
23dfb79d33
3 changed files with 49 additions and 60 deletions
|
@ -89,7 +89,7 @@ privileged bool __maps_lock(void) {
|
|||
if (!__tls_enabled)
|
||||
return false;
|
||||
tib = __get_tls_privileged();
|
||||
if (tib->tib_relock_maps++)
|
||||
if (atomic_fetch_add_explicit(&tib->tib_relock_maps, 1, memory_order_relaxed))
|
||||
return true;
|
||||
while (atomic_exchange_explicit(&__maps.lock, 1, memory_order_acquire)) {
|
||||
#if defined(__GNUC__) && defined(__aarch64__)
|
||||
|
@ -106,6 +106,7 @@ privileged void __maps_unlock(void) {
|
|||
if (!__tls_enabled)
|
||||
return;
|
||||
tib = __get_tls_privileged();
|
||||
if (!--tib->tib_relock_maps)
|
||||
if (atomic_fetch_sub_explicit(&tib->tib_relock_maps, 1,
|
||||
memory_order_relaxed) == 1)
|
||||
atomic_store_explicit(&__maps.lock, 0, memory_order_release);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue