The branch main has been updated by chs:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=d5cfca008d63b3b9220ecbb152a36efa80423c31

commit d5cfca008d63b3b9220ecbb152a36efa80423c31
Author:     Chuck Silvers <[email protected]>
AuthorDate: 2025-10-13 16:13:22 +0000
Commit:     Chuck Silvers <[email protected]>
CommitDate: 2025-10-13 16:13:22 +0000

    mmap_test: determine page size at run time rather than compile time
    
    Sponsored by:   Netflix
    Reviewed by:    imp
    Differential Revision:  https://reviews.freebsd.org/D52735
---
 tests/sys/vm/mmap_test.c | 31 ++++++++++++++++---------------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/tests/sys/vm/mmap_test.c b/tests/sys/vm/mmap_test.c
index 6bc30f73ca95..27d02ae667fb 100644
--- a/tests/sys/vm/mmap_test.c
+++ b/tests/sys/vm/mmap_test.c
@@ -36,21 +36,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-static const struct {
-       void    *addr;
-       int     ok[2];  /* Depending on security.bsd.map_at_zero {0, !=0}. */
-} map_at_zero_tests[] = {
-       { (void *)0,                    { 0, 1 } }, /* Test sysctl. */
-       { (void *)1,                    { 0, 0 } },
-       { (void *)(PAGE_SIZE - 1),      { 0, 0 } },
-       { (void *)PAGE_SIZE,            { 1, 1 } },
-       { (void *)-1,                   { 0, 0 } },
-       { (void *)(-PAGE_SIZE),         { 0, 0 } },
-       { (void *)(-1 - PAGE_SIZE),     { 0, 0 } },
-       { (void *)(-1 - PAGE_SIZE - 1), { 0, 0 } },
-       { (void *)(0x1000 * PAGE_SIZE), { 1, 1 } },
-};
-
 #define        MAP_AT_ZERO     "security.bsd.map_at_zero"
 
 #ifdef __LP64__
@@ -68,6 +53,22 @@ ATF_TC_BODY(mmap__map_at_zero, tc)
        int map_at_zero;
        bool allow_wx;
        int prot_flags;
+       size_t pgsz = getpagesize();
+
+       const struct {
+               void    *addr;
+               int     ok[2];  /* Depending on security.bsd.map_at_zero {0, 
!=0}. */
+       } map_at_zero_tests[] = {
+               { (void *)0,                    { 0, 1 } }, /* Test sysctl. */
+               { (void *)1,                    { 0, 0 } },
+               { (void *)(pgsz - 1),           { 0, 0 } },
+               { (void *)pgsz,                 { 1, 1 } },
+               { (void *)-1,                   { 0, 0 } },
+               { (void *)(-pgsz),              { 0, 0 } },
+               { (void *)(-1 - pgsz),          { 0, 0 } },
+               { (void *)(-1 - pgsz - 1),      { 0, 0 } },
+               { (void *)(0x1000 * pgsz),      { 1, 1 } },
+       };
 
        len = sizeof(map_at_zero);
        if (sysctlbyname(MAP_AT_ZERO, &map_at_zero, &len, NULL, 0) == -1) {

Reply via email to