From f806eb84984b4a64de5ffaba4b931b0dcb2b72a6 Mon Sep 17 00:00:00 2001 From: Daan Leijen Date: Wed, 29 Mar 2023 16:15:20 -0700 Subject: [PATCH] remove redundant OR in mmap flags (pr #675) --- src/prim/unix/prim.c | 1 - src/segment.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/prim/unix/prim.c b/src/prim/unix/prim.c index c12e4c0d..077bf820 100644 --- a/src/prim/unix/prim.c +++ b/src/prim/unix/prim.c @@ -166,7 +166,6 @@ static void* unix_mmap_prim(void* addr, size_t size, size_t try_alignment, int p if (addr == NULL && try_alignment > 1 && (try_alignment % _mi_os_page_size()) == 0) { size_t n = mi_bsr(try_alignment); if (((size_t)1 << n) == try_alignment && n >= 12 && n <= 30) { // alignment is a power of 2 and 4096 <= alignment <= 1GiB - flags |= MAP_ALIGNED(n); p = mmap(addr, size, protect_flags, flags | MAP_ALIGNED(n), fd, 0); if (p==MAP_FAILED || !_mi_is_aligned(p,try_alignment)) { int err = errno; diff --git a/src/segment.c b/src/segment.c index 8a9c8fe1..ae15847c 100644 --- a/src/segment.c +++ b/src/segment.c @@ -771,7 +771,7 @@ We maintain a global list of abandoned segments that are reclaimed on demand. Since this is shared among threads the implementation needs to avoid the A-B-A problem on popping abandoned segments: -We use tagged pointers to avoid accidentially identifying +We use tagged pointers to avoid accidentally identifying reused segments, much like stamped references in Java. Secondly, we maintain a reader counter to avoid resetting or decommitting segments that have a pending read operation.