From nobody Tue Nov 28 17:16:09 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4SfpyL1cwvz52FRl; Tue, 28 Nov 2023 17:16:10 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SfpyK5sQJz3d6Z; Tue, 28 Nov 2023 17:16:09 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1701191769; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=04anU3oFTum3fx2nSt9cXpTC311QUKbB50BD6buXZhc=; b=xYv6MWBA23QFXhm1K4yge9J/99fbVpLp3i2OQZABp5rb2C5rI9LTzNsieHAC8hai5s2k5b KSeFpglXi1+EsOF/2QPdE1pch5uMYtqv2cdzqgLGTq7NQGDPyqkmHzuXz2SI3fKzbwv6X6 UWBzAMyFn1s6DxeOSJXoGJpvs7baInW3YAdhaxY9nGes1awBWPNXJFtue4+GvcfNeibyrr O/FQRrDb6FaI7tjWz7kmqYI2tdoypKqsPGzRxXsm/F3+ioZwUOF5Awc8ZqdarEYXGXPqXv o63SDMn3nJGK8Q4DzGhGQhNyOPfLKLDgruPt/U9WjHQFJLQoQP1bXGJUIAvi9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1701191769; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=04anU3oFTum3fx2nSt9cXpTC311QUKbB50BD6buXZhc=; b=m56PcOfrYXo36FqxhkweNU6rwZq1NL5OtgLqn9/su0Iz8ZuBG0Vdw+yDNZuZ76/OlsoEKL zqbAu1QsB0Osg7t2eoAIi89vV8ae7lJPc7oC7kcp/5n7DCuzHtLtuDOYfXdH5tJwdN7GuW mCwFW0un5NxfYWQ/oisIvcK5NTZb/iLljISaOb+7sgwKafaZ6OvnRAmfPj7hsugkgzBXxn DHcvWxmgClS950OjMOUZIS3S1MmboFlaRApgtg9y9F8U8bnOxi2/xooGQFNG0hra88kpJD 6CcO9EFV7f09H93ju/v0Db44rZxcnzi8CVFDP4KlCR2oEewQnvmF06kM7kT5Mw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1701191769; a=rsa-sha256; cv=none; b=qvtRQggvrumbZY6bSprCFjWY58NO5zwxKtORWTyGmMDH1K+v3vcGwivvh/3SLmn5gwsGEc qZzbDDV1BzbeeRcUtyPFxQybEwrad65jZfmqCS209ptf5ziMh+KKdOAe5AZA9WkyBx1BsX uB39uAaexhymr9Q+eCL7GuyhQk21Pqj0jo9wCFQxqwQ6/KATsepWjgDn0WLmJi1Y8owzyE 9mibsPPzX2hyrTlpLZpwzkRcMUX6/JB6mGCbPOje1Hs2ugPF0ll8HOnHNkWHeVkCX00GNT QwvSywyxTbwir7GtrMkKe2hDLqaG8ToilcnDo/ljRhevIExaT9BTK+dFUKIR7w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4SfpyK4p2RzWKq; Tue, 28 Nov 2023 17:16:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3ASHG9Wj095324; Tue, 28 Nov 2023 17:16:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3ASHG9Dv095321; Tue, 28 Nov 2023 17:16:09 GMT (envelope-from git) Date: Tue, 28 Nov 2023 17:16:09 GMT Message-Id: <202311281716.3ASHG9Dv095321@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Brooks Davis Subject: git: ea180bb3797e - main - getpagesize(3): drop support for non-ELF kernels List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: brooks X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ea180bb3797ed4e976adccfba7d09c154d3244d1 Auto-Submitted: auto-generated The branch main has been updated by brooks: URL: https://cgit.FreeBSD.org/src/commit/?id=ea180bb3797ed4e976adccfba7d09c154d3244d1 commit ea180bb3797ed4e976adccfba7d09c154d3244d1 Author: Brooks Davis AuthorDate: 2023-11-27 17:06:25 +0000 Commit: Brooks Davis CommitDate: 2023-11-28 17:09:26 +0000 getpagesize(3): drop support for non-ELF kernels AT_PAGESZ was introduced with ELF support in 1996 (commit e1743d02cd14069f69a50bb8a6c626c1c6f47ddd) so we can safely count on being able to use it to get our page size via elf_aux_info(). As such we don't need a fallback sysctl query. Save a few bytes of bss by dropping caching as elf_aux_info() runs in constant time for a given query. Reviewed by: kevans, imp, emaste Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D42708 --- lib/libc/gen/getpagesize.c | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/lib/libc/gen/getpagesize.c b/lib/libc/gen/getpagesize.c index 5fe9a965385f..23d2c6ea5eda 100644 --- a/lib/libc/gen/getpagesize.c +++ b/lib/libc/gen/getpagesize.c @@ -30,18 +30,11 @@ */ #include -#include - -#include -#include -#include +#include #include "libc_private.h" /* - * This is unlikely to change over the running time of any - * program, so we cache the result to save some syscalls. - * * NB: This function may be called from malloc(3) at initialization * NB: so must not result in a malloc(3) related call! */ @@ -49,23 +42,10 @@ int getpagesize(void) { - int mib[2]; - static int value; - size_t size; - int error; - - if (value != 0) - return (value); - - error = _elf_aux_info(AT_PAGESZ, &value, sizeof(value)); - if (error == 0 && value != 0) - return (value); + int value; - mib[0] = CTL_HW; - mib[1] = HW_PAGESIZE; - size = sizeof value; - if (sysctl(mib, nitems(mib), &value, &size, NULL, 0) == -1) - return (PAGE_SIZE); + if (_elf_aux_info(AT_PAGESZ, &value, sizeof(value)) != 0) + value = PAGE_SIZE; return (value); }