From patchwork Sun Sep 29 16:45:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 1990626 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=B/M/A4tU; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XGqp62wmdz1xt8 for ; Mon, 30 Sep 2024 02:45:50 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3F92F385EC3A for ; Sun, 29 Sep 2024 16:45:48 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id E4E2A385DDDB for ; Sun, 29 Sep 2024 16:45:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E4E2A385DDDB Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E4E2A385DDDB Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1727628333; cv=none; b=SnbSjI1ito0hKzNafn3rlFu/P0dQJ7VPK3/fw7PJTd+trgw2qoRV1eIs1k71kXseWEdH4vxezK8onw6vXDJnTEK5QoUtzT97UOwZu9riqqVPldvJUjKV5Uk6+Qr8i9POwkHIeA462lpr5JOGu+x5dNBPGVXxCKOSTxyCTraaS2M= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1727628333; c=relaxed/simple; bh=iv34/f2yxfI+Km1MBxL06wXaC9qfN6vT7J200QaG/q0=; h=DKIM-Signature:From:To:Subject:Message-ID:Date:MIME-Version; b=klkfXaaPo34cftbDbvRwDjRvIfI/m/DDNWu7PZ46D2ncd/kcVWAjEdZ/5pFJh0Oq+sEAwjAtYXhrxU45Q3hNSXmD74YcGAgaxz9DazydSmtnEVF7u5WJL3WnDGOEh2QsCEejT8g6wkFsbmEBu5J5XU4B7JFe1yOsVl7dh1QxD1Y= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727628330; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ohYgmgQHHdBZ078yApEDor1N09SqkeccTi/vR74Jb0g=; b=B/M/A4tUQg5vSb2Ewdn/W6Pw0L4utUIhHIgFUF8NLofxqhEy8C3k55LIwV/w871JM4pTHH MxQUv267feh6EK0cYewIcM3SV8G3/bFov/II7Qab3vIXM9xLso6i1HF8pHx0H5AGqpaHj+ YVZ6Sl4sVB4HQJx6wQZygb88YwuO64A= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-191-8GduJZtdOOCrL-8wOkqScA-1; Sun, 29 Sep 2024 12:45:29 -0400 X-MC-Unique: 8GduJZtdOOCrL-8wOkqScA-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (unknown [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9AE321953940 for ; Sun, 29 Sep 2024 16:45:28 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.45.224.151]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C2A2E1955DCB for ; Sun, 29 Sep 2024 16:45:27 +0000 (UTC) From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH v3 29/29] Optimize various ways to obtain the page size using In-Reply-To: Message-ID: <52aa57f9ba1971262b8aaa5c705b2a260e6c09eb.1727624528.git.fweimer@redhat.com> References: X-From-Line: 52aa57f9ba1971262b8aaa5c705b2a260e6c09eb Mon Sep 17 00:00:00 2001 Date: Sun, 29 Sep 2024 18:45:24 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces~incoming=patchwork.ozlabs.org@sourceware.org Create inline definitions of getpagesize and __getpagesize if they are constant. Expand sysconf (_SC_PAGE_SIZE) inline if possible. --- bits/shm.h | 9 +++++++++ posix/unistd.h | 21 +++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/bits/shm.h b/bits/shm.h index ab0864cb9c..c6a235e33d 100644 --- a/bits/shm.h +++ b/bits/shm.h @@ -20,6 +20,7 @@ #endif #include +#include /* Flags for `shmat'. */ #define SHM_RDONLY 010000 /* attach read-only else read-write */ @@ -35,6 +36,14 @@ __BEGIN_DECLS /* Segment low boundary address multiple. */ #define SHMLBA (__getpagesize ()) extern int __getpagesize (void) __THROW __attribute__ ((__const__)); +#if defined __USE_EXTERN_INLINES && defined __REDIRECT_NTH \ + && __GLIBC_PAGE_SHIFT_MIN == __GLIBC_PAGE_SHIFT_MAX +__extern_inline int +__NTH (__getpagesize (void)) +{ + return 1 << __GLIBC_PAGE_SHIFT_MIN; +} +#endif /* Type to count number of attaches. */ diff --git a/posix/unistd.h b/posix/unistd.h index 54d7d7527e..a5fa6768c9 100644 --- a/posix/unistd.h +++ b/posix/unistd.h @@ -639,6 +639,19 @@ extern long int fpathconf (int __fd, int __name) __THROW; /* Get the value of the system variable NAME. */ extern long int sysconf (int __name) __THROW; +#include +#if defined __USE_EXTERN_INLINES && defined __REDIRECT_NTH \ + && __GLIBC_PAGE_SHIFT_MIN == __GLIBC_PAGE_SHIFT_MAX +__extern_inline long int +__NTH (sysconf (int __name)) +{ + if (__builtin_constant_p (__name) && __name == _SC_PAGESIZE) + return 1L << __GLIBC_PAGE_SHIFT_MIN; + extern long int __REDIRECT_NTH (__sysconf_alias, (int), sysconf); + return __sysconf_alias (__name); +} +#endif /* __USE_EXTERN_INLINES */ + #ifdef __USE_POSIX2 /* Get the value of the string-valued system variable NAME. */ extern size_t confstr (int __name, char *__buf, size_t __len) __THROW @@ -1010,6 +1023,14 @@ extern void sync (void) __THROW; which is not necessarily the same as the hardware page size. */ extern int getpagesize (void) __THROW __attribute__ ((__const__)); +# if defined __USE_EXTERN_INLINES && defined __REDIRECT_NTH \ + && __GLIBC_PAGE_SHIFT_MIN == __GLIBC_PAGE_SHIFT_MAX +__extern_inline int +__NTH (getpagesize (void)) +{ + return 1 << __GLIBC_PAGE_SHIFT_MIN; +} +# endif /* Return the maximum number of file descriptors the current process could possibly have. */