Make correction to last change

This commit is contained in:
Justine Tunney 2025-01-04 21:27:55 -08:00
parent 42a3bb729a
commit 53c6edfd18
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
2 changed files with 2 additions and 9 deletions

View file

@ -294,7 +294,6 @@ void __maps_free(struct Map *map) {
&__maps.freed, &tip, ABA(map, TAG(tip) + 1), memory_order_release, &__maps.freed, &tip, ABA(map, TAG(tip) + 1), memory_order_release,
memory_order_relaxed)) memory_order_relaxed))
break; break;
pthread_pause_np();
} }
} }
@ -462,8 +461,7 @@ textwindows dontinline static struct DirectMap sys_mmap_nt(
struct DirectMap dm; struct DirectMap dm;
// it's 5x faster // it's 5x faster
if (IsWindows() && (flags & MAP_ANONYMOUS) && if ((flags & MAP_ANONYMOUS) && (flags & MAP_TYPE) != MAP_SHARED) {
(flags & MAP_TYPE) != MAP_SHARED) {
if (!(dm.addr = VirtualAlloc(addr, size, kNtMemReserve | kNtMemCommit, if (!(dm.addr = VirtualAlloc(addr, size, kNtMemReserve | kNtMemCommit,
__prot2nt(prot, false)))) { __prot2nt(prot, false)))) {
dm.addr = MAP_FAILED; dm.addr = MAP_FAILED;
@ -579,13 +577,11 @@ static struct DirectMap sys_mmap(void *addr, size_t size, int prot, int flags,
struct Map *__maps_alloc(void) { struct Map *__maps_alloc(void) {
struct Map *map; struct Map *map;
uintptr_t tip = atomic_load_explicit(&__maps.freed, memory_order_relaxed); uintptr_t tip = atomic_load_explicit(&__maps.freed, memory_order_relaxed);
while ((map = (struct Map *)PTR(tip))) { while ((map = (struct Map *)PTR(tip)))
if (atomic_compare_exchange_weak_explicit( if (atomic_compare_exchange_weak_explicit(
&__maps.freed, &tip, ABA(map->freed, TAG(tip) + 1), &__maps.freed, &tip, ABA(map->freed, TAG(tip) + 1),
memory_order_acquire, memory_order_relaxed)) memory_order_acquire, memory_order_relaxed))
return map; return map;
pthread_pause_np();
}
// we're creating sudden surprise memory. the user might be in the // we're creating sudden surprise memory. the user might be in the
// middle of carefully planning a fixed memory structure. we don't // middle of carefully planning a fixed memory structure. we don't
// want the system allocator to put our surprise memory inside it, // want the system allocator to put our surprise memory inside it,
@ -595,8 +591,6 @@ struct Map *__maps_alloc(void) {
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (sys.addr == MAP_FAILED) if (sys.addr == MAP_FAILED)
return 0; return 0;
if (IsWindows())
CloseHandle(sys.hand);
struct MapSlab *slab = sys.addr; struct MapSlab *slab = sys.addr;
while (!atomic_compare_exchange_weak(&__maps.slabs, &slab->next, slab)) { while (!atomic_compare_exchange_weak(&__maps.slabs, &slab->next, slab)) {
} }

View file

@ -3273,7 +3273,6 @@ static char *ServeIndex(const char *path, size_t pathlen) {
p = RoutePath(q, n); p = RoutePath(q, n);
free(q); free(q);
} }
__print_maps(30);
return p; return p;
} }