Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp7408441rwl; Mon, 9 Jan 2023 23:54:30 -0800 (PST) X-Google-Smtp-Source: AMrXdXuOobPukssqHB8rlKug4H/TX9eIqu7hUWiPL3mKSSVKe7Ne6cS8gHv+O6x10avaR3uiihqO X-Received: by 2002:a05:6a20:b546:b0:a9:167:1788 with SMTP id ev6-20020a056a20b54600b000a901671788mr84479704pzb.19.1673337268825; Mon, 09 Jan 2023 23:54:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673337268; cv=none; d=google.com; s=arc-20160816; b=H6yF/Y2ShmFdEmw1J1FEc8Wiu2ghZWthCGgSFNQubnYmXWYCKfGIYlDQ1aat2AEOwY zaYX3GwzSMWeS9xgbbCwy+vNnEskRloEssZt6t1OAnrp0vpiCDemJIYxpORNBvUz6pm6 Ljtvo9zQAbDtj0w0Vfpy27mGJuLgBNkal/C5KFdADSqIZcry6YtrUn+7eHc6+akJ25ns 90xKCHCQUUixBw1MjxjAE4Mrnp4peJhmxZpIARXQegLMQ5+btg/tbrM/7sMOfdF/4QhO 4TVMrIfg26B0KYvlh4S0U8YTSyW2ABK7+xmc5pF9pC7SRYbuxrqYS3B89IclX2hdCnlI CUUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=FxWEVwfsBcXafKoUNsr5ZCY4kl7bPB4lZ9PVYAcNwgs=; b=vgxJdRHT1VTgX51gpU/UsR1IWzzX7AQVieC3+zLM00PwWAT/mLpW7+mxJkjOY2cIIe ccq+vEAK9YX9+YvRp6IT77hjNHqBTbakqjl1k5dIQAGLkZdk+G3wiN6XlP5ZohdgV4Ta gzqpLSLtNVGZ90wiyRs11tWbUdLsC7RzO+Z6Qes+899sO+r2GeNTCdonEzoyyUVp44Fo T+wVY/aEzt+72TtZHr7L7R17GuhgLsKSbuTMlmransFHIyPufBU66urBO8h03mAstWeP capttab/iOkQcnK9jropFX7vwlGnC9WxxW8+qvqHJT+sRv1plDthD26PhwY7zRYTGAA2 WVAw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c11-20020a631c0b000000b004794e3493f5si10994424pgc.521.2023.01.09.23.54.21; Mon, 09 Jan 2023 23:54:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237896AbjAJH1t (ORCPT + 53 others); Tue, 10 Jan 2023 02:27:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237938AbjAJH1N (ORCPT ); Tue, 10 Jan 2023 02:27:13 -0500 Received: from 1wt.eu (wtarreau.pck.nerim.net [62.212.114.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1CA761001 for ; Mon, 9 Jan 2023 23:25:58 -0800 (PST) Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 30A7OeHk003948; Tue, 10 Jan 2023 08:24:40 +0100 From: Willy Tarreau To: "Paul E. McKenney" Cc: linux-kernel@vger.kernel.org, Ammar Faizi , Willy Tarreau Subject: [PATCH v2 21/22] nolibc/sys: Implement `getpagesize(2)` function Date: Tue, 10 Jan 2023 08:24:33 +0100 Message-Id: <20230110072434.3863-22-w@1wt.eu> X-Mailer: git-send-email 2.17.5 In-Reply-To: <20230110072434.3863-1-w@1wt.eu> References: <20230110072434.3863-1-w@1wt.eu> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ammar Faizi This function returns the page size used by the running kernel. The page size value is taken from the auxiliary vector at 'AT_PAGESZ' key. 'getpagesize(2)' is assumed as a syscall becuase the manpage placement of this function is in entry 2 ('man 2 getpagesize') despite there is no real 'getpagesize(2)' syscall in the Linux syscall table. Define this function in 'sys.h'. Signed-off-by: Ammar Faizi Signed-off-by: Willy Tarreau --- tools/include/nolibc/sys.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 47bf67668860..b5f8cd35c03b 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -19,6 +19,7 @@ #include #include #include +#include #include "arch.h" #include "errno.h" @@ -499,6 +500,26 @@ pid_t gettid(void) return sys_gettid(); } +static unsigned long getauxval(unsigned long key); + +/* + * long getpagesize(void); + */ + +static __attribute__((unused)) +long getpagesize(void) +{ + long ret; + + ret = getauxval(AT_PAGESZ); + if (!ret) { + SET_ERRNO(ENOENT); + return -1; + } + + return ret; +} + /* * int gettimeofday(struct timeval *tv, struct timezone *tz); -- 2.17.5