Message ID | 20230109084208.27355-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 p1csp2043001wrt; Mon, 9 Jan 2023 00:44:19 -0800 (PST) X-Google-Smtp-Source: AMrXdXthJ2SxHtLDYkMKO9sAZODk6tGzlHBXlpauz0m/3yx1aJlAYeYppHUbBPpsCz7XxUcUAtoQ X-Received: by 2002:a17:907:a641:b0:7c1:4e8f:df2f with SMTP id vu1-20020a170907a64100b007c14e8fdf2fmr63857777ejc.17.1673253859738; Mon, 09 Jan 2023 00:44:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673253859; cv=none; d=google.com; s=arc-20160816; b=b/otCWGLinSzaRAvGq4wRG2Lq32vLCgZiUQfwEjZ+Xwzd/mYrUltmQtgc7+0MJa9SJ 7lSV8yWxFYF6oTZvKIFbfC8gN4P4dLfN5M2ZgqNyhcZQtPktRVGxZGv4IbV5u3a8LVQs 1ssfLAlgOyA/hizniQWVSFRy85a6+8CIOeo1cD+KyAxAwBOVPWDbjVpQUZicy2zhvrfN GFUNL17jHhCCtcxFwNjjG66V7er5/XfUWw4oULgNH/01RMvpi6Qj24rzF3WkO4dMX3gg eGaiPEaOoaxs9kt66nhfvCjo2jJQTJTqn7moXZXk/xZ7G6chKrYQZDigCDuOwQZ/3PgQ b/bQ== 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=ZUF/QoTn+cHwHk8j21lkk41xXgj4bEt+6fOluHfk9Eo=; b=MszTlYhMezjg2TzX0zJ+g6yZ0gpMR3pGG51CvFbcIjaGmn1IpQw+sE6qsxAtZ1xpSp DbMpCoT+SrwY2o70PWC3GK4YS0sxUZWdEvNH0Zw8G/ET+CbLSbAyJ7A8VEuiIjw9Mfoz IB0Cp1rTJNKvveHLh2M3nYvURkIyOSfT4UPgfmdWbm/fdR29Ls+2qpTLLdH/wM9KbfBh BXGtPM2mC3X2Awej5zw59SGTIu5FUHdOesrovNqcTdVRBQhSt1ZZmEEwr12djw7UFTwt qVfoPn1eFKS82Mjt1Uf/oZqTBL6i+b8GHJe6Zby5vHwOypCM6BelXCNSxeeIjW7Xv7Qz luHw== 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 sa4-20020a1709076d0400b0078fcfc5d24esi9534097ejc.618.2023.01.09.00.43.55; Mon, 09 Jan 2023 00:44:19 -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 S236869AbjAIInE (ORCPT <rfc822;zhanglyra.2023@gmail.com> + 99 others); Mon, 9 Jan 2023 03:43:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236836AbjAIImX (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 9 Jan 2023 03:42:23 -0500 Received: from 1wt.eu (wtarreau.pck.nerim.net [62.212.114.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 803A112D2B for <linux-kernel@vger.kernel.org>; Mon, 9 Jan 2023 00:42:22 -0800 (PST) Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 3098gGfR027440; Mon, 9 Jan 2023 09:42:16 +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> Subject: [PATCH 21/22] nolibc/sys: Implement `getpagesize(2)` function Date: Mon, 9 Jan 2023 09:42:07 +0100 Message-Id: <20230109084208.27355-22-w@1wt.eu> X-Mailer: git-send-email 2.17.5 In-Reply-To: <20230109084208.27355-1-w@1wt.eu> References: <20230109084208.27355-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?1754533838809975433?= X-GMAIL-MSGID: =?utf-8?q?1754533838809975433?= |
Series |
nolibc: usability improvements (errno, environ, auxv)
|
|
Commit Message
Willy Tarreau
Jan. 9, 2023, 8:42 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> --- 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);