tor 0.4.8.4: compilation error on SunOS / OpenIndiana
Compiling tor 0.4.8.4 throws the following error. (Similar to #40843 (closed) => compilation error on NetBSD)
/export/home/svschmel/oi-userland/components/network/tor/tor-0.4.8.4/src/ext/equix/hashx/src/virtual_memory.c: In function 'hashx_vm_alloc_huge':
/export/home/svschmel/oi-userland/components/network/tor/tor-0.4.8.4/src/ext/equix/hashx/src/virtual_memory.c:113:5: error: 'MAP_HUGETLB' undeclared (first use in this function)
113 | | MAP_HUGETLB | MAP_POPULATE, -1, 0);
| ^~~~~~~~~~~
/export/home/svschmel/oi-userland/components/network/tor/tor-0.4.8.4/src/ext/equix/hashx/src/virtual_memory.c:113:5: note: each undeclared identifier is reported only once for each function it appears in
/export/home/svschmel/oi-userland/components/network/tor/tor-0.4.8.4/src/ext/equix/hashx/src/virtual_memory.c:113:19: error: 'MAP_POPULATE' undeclared (first use in this function); did you mean 'MAP_PRIVATE'?
113 | | MAP_HUGETLB | MAP_POPULATE, -1, 0);
| ^~~~~~~~~~~~
| MAP_PRIVATE
make[2]: *** [Makefile:16523: src/ext/equix/hashx/src/libhashx_a-virtual_memory.o] Error 1
make[2]: Leaving directory '/export/home/svschmel/oi-userland/components/network/tor/build/amd64'
make[1]: *** [Makefile:7648: all] Error 2
These defines do not exist on SunOS / OpenIndiana => https://www.illumos.org/man/2/mmap
I suggest handling SunOS like OpenBSD in file "virtual_memory.c" because the default => the "#else"- tree <= assumes that the underlying OS is a Linux-system.
...
#elif defined(__OpenBSD__)
mem = MAP_FAILED; // OpenBSD does not support huge pages
#else
mem = mmap(NULL, bytes, PAGE_READWRITE, MAP_PRIVATE | MAP_ANONYMOUS
| MAP_HUGETLB | MAP_POPULATE, -1, 0);
...
With this modification the code can be compiled on SunOS / Openindiana successful.