Message ID | 20230110072434.3863-22-w@1wt.eu |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2603041wrt; Mon, 9 Jan 2023 23:29:05 -0800 (PST) X-Google-Smtp-Source: AMrXdXtcSBTkySLKk+hEEXDKMzYfsov2IQd8ScBt4r+hnoNctO7yYVOYWnPqmmehegJXGnilTGju X-Received: by 2002:a05:6a20:8423:b0:b5:f180:56ab with SMTP id c35-20020a056a20842300b000b5f18056abmr5648746pzd.60.1673335744816; Mon, 09 Jan 2023 23:29:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673335744; cv=none; d=google.com; s=arc-20160816; b=JCxUqa6y0gNQ9y1pBwtJOBxxTvkQCmbqmXIoVxGMuE1aCgdiQ2eJGr3wWotthiqD// +E8XtHSZRTvrsc9FyfcHUx56vqXbJwXi3m858woG1629y05PrdR/75D8cteJBfNRIBxf fzt/8Wrt+EEGgqpH00dosU+f/ZMqMCUnE5FMVcwrbWWC1NBejuXrLU/ltNXVfD/KDWkQ TxrJ7FBwZiRuGWpaWoRzIh42u7RM9845PLGkID5H7Xp6+CEblwrV9/Dn6raUQGgw3WDG apJxvE15PxXe/x7zZVOZfnAGcFpk+eLwADa4Bd9xmHZ1Zwmo1YgLLp4rB4xUsmYS+X4c xjEg== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o17-20020a639211000000b0046fef65f738si10841100pgd.793.2023.01.09.23.28.52; Mon, 09 Jan 2023 23:29:04 -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 <rfc822;syz17693488234@gmail.com> + 99 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 <rfc822;linux-kernel@vger.kernel.org>); 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 <linux-kernel@vger.kernel.org>; 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 <w@1wt.eu> To: "Paul E. McKenney" <paulmck@kernel.org> Cc: linux-kernel@vger.kernel.org, Ammar Faizi <ammarfaizi2@gnuweeb.org>, Willy Tarreau <w@1wt.eu> 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754619702034700302?= X-GMAIL-MSGID: =?utf-8?q?1754619702034700302?= |
Series |
nolibc: usability improvements (errno, environ, auxv)
|
|
Commit Message
Willy Tarreau
Jan. 10, 2023, 7:24 a.m. UTC
From: Ammar Faizi <ammarfaizi2@gnuweeb.org> 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 <ammarfaizi2@gnuweeb.org> Signed-off-by: Willy Tarreau <w@1wt.eu> --- 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 <linux/fs.h> #include <linux/loop.h> #include <linux/time.h> +#include <linux/auxvec.h> #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);