remove redundant OR in mmap flags (pr #675)

This commit is contained in:
Daan Leijen 2023-03-29 16:15:20 -07:00
parent dd7b99d477
commit f806eb8498
2 changed files with 1 additions and 2 deletions

View file

@ -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) { if (addr == NULL && try_alignment > 1 && (try_alignment % _mi_os_page_size()) == 0) {
size_t n = mi_bsr(try_alignment); 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 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); p = mmap(addr, size, protect_flags, flags | MAP_ALIGNED(n), fd, 0);
if (p==MAP_FAILED || !_mi_is_aligned(p,try_alignment)) { if (p==MAP_FAILED || !_mi_is_aligned(p,try_alignment)) {
int err = errno; int err = errno;

View file

@ -771,7 +771,7 @@ We maintain a global list of abandoned segments that are
reclaimed on demand. Since this is shared among threads reclaimed on demand. Since this is shared among threads
the implementation needs to avoid the A-B-A problem on the implementation needs to avoid the A-B-A problem on
popping abandoned segments: <https://en.wikipedia.org/wiki/ABA_problem> popping abandoned segments: <https://en.wikipedia.org/wiki/ABA_problem>
We use tagged pointers to avoid accidentially identifying We use tagged pointers to avoid accidentally identifying
reused segments, much like stamped references in Java. reused segments, much like stamped references in Java.
Secondly, we maintain a reader counter to avoid resetting Secondly, we maintain a reader counter to avoid resetting
or decommitting segments that have a pending read operation. or decommitting segments that have a pending read operation.