Skip to content

Commit

Permalink
Make correction to last change
Browse files Browse the repository at this point in the history
  • Loading branch information
jart committed Jan 5, 2025
1 parent 42a3bb7 commit 53c6edf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
10 changes: 2 additions & 8 deletions libc/intrin/mmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ void __maps_free(struct Map *map) {
&__maps.freed, &tip, ABA(map, TAG(tip) + 1), memory_order_release,
memory_order_relaxed))
break;
pthread_pause_np();
}
}

Expand Down Expand Up @@ -462,8 +461,7 @@ textwindows dontinline static struct DirectMap sys_mmap_nt(
struct DirectMap dm;

// it's 5x faster
if (IsWindows() && (flags & MAP_ANONYMOUS) &&
(flags & MAP_TYPE) != MAP_SHARED) {
if ((flags & MAP_ANONYMOUS) && (flags & MAP_TYPE) != MAP_SHARED) {
if (!(dm.addr = VirtualAlloc(addr, size, kNtMemReserve | kNtMemCommit,
__prot2nt(prot, false)))) {
dm.addr = MAP_FAILED;
Expand Down Expand Up @@ -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 *map;
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(
&__maps.freed, &tip, ABA(map->freed, TAG(tip) + 1),
memory_order_acquire, memory_order_relaxed))
return map;
pthread_pause_np();
}
// we're creating sudden surprise memory. the user might be in the
// middle of carefully planning a fixed memory structure. we don't
// want the system allocator to put our surprise memory inside it,
Expand All @@ -595,8 +591,6 @@ struct Map *__maps_alloc(void) {
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (sys.addr == MAP_FAILED)
return 0;
if (IsWindows())
CloseHandle(sys.hand);
struct MapSlab *slab = sys.addr;
while (!atomic_compare_exchange_weak(&__maps.slabs, &slab->next, slab)) {
}
Expand Down
1 change: 0 additions & 1 deletion tool/net/redbean.c
Original file line number Diff line number Diff line change
Expand Up @@ -3273,7 +3273,6 @@ static char *ServeIndex(const char *path, size_t pathlen) {
p = RoutePath(q, n);
free(q);
}
__print_maps(30);
return p;
}

Expand Down

0 comments on commit 53c6edf

Please sign in to comment.