]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
equix: Add NetBSD to "huge pages not supported" path
authorMicah Elizabeth Scott <beth@torproject.org>
Fri, 25 Aug 2023 17:08:41 +0000 (10:08 -0700)
committerMicah Elizabeth Scott <beth@torproject.org>
Mon, 28 Aug 2023 17:11:00 +0000 (10:11 -0700)
As suggested by @wiz on #40843, let's add an explicit check to
hashx_vm_alloc_huge() that avoids using a Linux-style default
on NetBSD targets.

This doesn't change the questionable Linux-style default,
but a future patch will disable this code by default so it's not a
portability liability.

(This code is in hashx's VM layer but it's actually only relevant to
equix.)

This addresses bug #40843. Another patch will disable huge pages
by default entirely, but this patch is sufficient to fix the NetBSD
build.

src/ext/equix/hashx/src/virtual_memory.c

index e9df825c9fe0b906e5f827e537c8734cb7936bee..40540a26600cacd465ffece274bc7eca17206ddb 100644 (file)
@@ -106,8 +106,8 @@ void* hashx_vm_alloc_huge(size_t bytes) {
 #elif defined(__FreeBSD__)
        mem = mmap(NULL, bytes, PAGE_READWRITE, MAP_PRIVATE | MAP_ANONYMOUS
                | MAP_ALIGNED_SUPER, -1, 0);
-#elif defined(__OpenBSD__)
-       mem = MAP_FAILED; // OpenBSD does not support huge pages
+#elif defined(__OpenBSD__) || defined(__NetBSD__)
+       mem = MAP_FAILED; // OpenBSD and NetBSD do not support huge pages
 #else
        mem = mmap(NULL, bytes, PAGE_READWRITE, MAP_PRIVATE | MAP_ANONYMOUS
                | MAP_HUGETLB | MAP_POPULATE, -1, 0);