Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 28 Nov 2023 17:16:08 GMT
From:      Brooks Davis <brooks@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: df65c89375e2 - main - getpagesizes(3): drop support for kernels before 9.0
Message-ID:  <202311281716.3ASHG8eR095276@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by brooks:

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

commit df65c89375e242bf53e6c5b7614ab898104f71b7
Author:     Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2023-11-27 17:06:01 +0000
Commit:     Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2023-11-28 17:09:26 +0000

    getpagesizes(3): drop support for kernels before 9.0
    
    AT_PAGESIZES and elf_aux_info where added prior to FreeBSD 9.0 in commit
    ee235befcb8253fab9beea27b916f1bc46b33147.  It's safe to say that a
    FreeBSD 15 libc won't work on a 8.x kernel so drop sysctl fallback.
    
    Reviewed by:    kevans, imp, emaste
    Sponsored by:   DARPA
    Differential Revision:  https://reviews.freebsd.org/D42707
---
 lib/libc/gen/getpagesizes.c | 23 +++++++----------------
 1 file changed, 7 insertions(+), 16 deletions(-)

diff --git a/lib/libc/gen/getpagesizes.c b/lib/libc/gen/getpagesizes.c
index c9f7f2f29e16..7f481f84177a 100644
--- a/lib/libc/gen/getpagesizes.c
+++ b/lib/libc/gen/getpagesizes.c
@@ -27,11 +27,8 @@
  */
 
 #include <sys/param.h>
-#include <sys/mman.h>
-#include <sys/sysctl.h>
-
-#include <errno.h>
-#include <link.h>
+#include <sys/auxv.h>
+#include <sys/errno.h>
 
 #include "libc_private.h"
 
@@ -52,24 +49,18 @@ getpagesizes(size_t pagesize[], int nelem)
 {
 	static u_long ps[MAXPAGESIZES];
 	static int nops;
-	size_t size;
-	int error, i;
+	int i;
 
 	if (nelem < 0 || (nelem > 0 && pagesize == NULL)) {
 		errno = EINVAL;
 		return (-1);
 	}
-	/* Cache the result of the sysctl(2). */
+	/* Cache the result */
 	if (nops == 0) {
-		error = _elf_aux_info(AT_PAGESIZES, ps, sizeof(ps));
-		size = sizeof(ps);
-		if (error != 0 || ps[0] == 0) {
-			if (sysctlbyname("hw.pagesizes", ps, &size, NULL, 0)
-			    == -1)
-				return (-1);
-		}
+		if (_elf_aux_info(AT_PAGESIZES, ps, sizeof(ps)) != 0)
+			ps[0] = PAGE_SIZE;
 		/* Count the number of page sizes that are supported. */
-		nops = size / sizeof(ps[0]);
+		nops = nitems(ps);
 		while (nops > 0 && ps[nops - 1] == 0)
 			nops--;
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202311281716.3ASHG8eR095276>