Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp4937549rwl; Sun, 8 Jan 2023 06:00:05 -0800 (PST) X-Google-Smtp-Source: AMrXdXtKqz+Wia99N5/XCIYpZMjgB7UYGmbJkosUo3UQheR9v4PhMPjSqk7bbu45GeN1NBOIPJ0M X-Received: by 2002:a17:902:fe0c:b0:192:5c3e:8939 with SMTP id g12-20020a170902fe0c00b001925c3e8939mr53450585plj.0.1673186405029; Sun, 08 Jan 2023 06:00:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673186405; cv=none; d=google.com; s=arc-20160816; b=wmst+uiWZfjlvZIrKAAQflg+EkmTIbz/0OGXhyu76iNPfW/dbTKh5bk6SlSE11uO/p ZVMRuEjUrgOjVfh2Ig8wOzPPmRhVala3nRfTSx0M5qGCOGGb2ruq80OG7xf1rKcTDGhc xrfjHxCSI9UolPiz8K3DT9TepzzwFDenIEsQ6LMyteDU4OB77uw3rMFJiS3UxfneAweo Kb03fJG0wsjQueFvecZlV7y9LrThhfnRZtPHsL8B7dtEIlejc2fAQhY/qtJ72/O/eHg2 3aLJqQdZlDPRmN/VDm9DZkyRpXliaU4744UvwsqXpZBtin1iFDtOyMfl33MYJk6YOoeZ Yx+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YjCFB37C0uzIOrNIl2jIsv9/B9o5ZqsNOP8FG6G4TDI=; b=c4rp8rzEfMbBoFdBVMKTIa2pKMD1DCcjfhtRUriZojOfSDz8ehhtdk3oHSQfZvHag/ TnPgbnON5/eIXoK5yoOjrH3cgds+H00yA05UnuTEKIzLThf23Adv0ub7soIzf+175xSR M/c2yRxtLq8EG0XDpSVjWQOhzjxRje86Zw/2lg76v848Fbonmm7NSoUm+2/CLjkoQ0x3 lxATjzCcK1olEvR+3pKWPZCsMDa/FBQKcAh+/WNGz6KDRF8jXBb7wJT/iG9xRM1cexTG FHEJ1N6XQRSoPd5al/WPMjRK6d92PXVq4pAC9IG4DYHwjDiF/yf9VypVLbegJUXRMf5G 39Ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gnuweeb.org header.s=default header.b="EFXZkn/3"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnuweeb.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c7-20020a170903234700b001933171a4eesi665099plh.113.2023.01.08.05.59.57; Sun, 08 Jan 2023 06:00: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; dkim=pass header.i=@gnuweeb.org header.s=default header.b="EFXZkn/3"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnuweeb.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232900AbjAHN6a (ORCPT + 52 others); Sun, 8 Jan 2023 08:58:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232939AbjAHN6Z (ORCPT ); Sun, 8 Jan 2023 08:58:25 -0500 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5935D2FF; Sun, 8 Jan 2023 05:58:24 -0800 (PST) Received: from localhost.localdomain (unknown [182.253.183.184]) by gnuweeb.org (Postfix) with ESMTPSA id AF84E7E6D5; Sun, 8 Jan 2023 13:58:21 +0000 (UTC) X-GW-Data: lPqxHiMPbJw1wb7CM9QUryAGzr0yq5atzVDdxTR0iA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1673186304; bh=wcpOgJmHUqHilg+MA55c94wnAlyf9zHTIyYePnjiqNM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EFXZkn/3XD4yXC9/kl1H5fo6KHZ5WXwvEzPwVJRY+oy6THg+LUcgqGZqjedoPNQVP TPFcc8x8q2Om7FZ24wCiusqC9yie+y+0U8H9vZ/vsup2nKBvP1DG7gaAwnM7/K8vXO ij5BA5kXIugK5sfb40wRTi6DImcbv+1WPBXy2QtfItgEH+JVpnl8xHqYpUay7jldol AiTfAO63d2oM311mt9jRi3n9kqlvtGJTMC5s7p5KZBYtgw6HbN6MEMg+LG8V9Ot9jV qmyuorbPFE/2C+bFOJz84vybWBitXC3OjpMOwi2TQgx7RHWePH0HxxXEmG/m6BQbQS 5zs909NZv8c8w== From: Ammar Faizi To: Willy Tarreau Cc: Ammar Faizi , Shuah Khan , "Paul E. McKenney" , Sven Schnelle , Alviro Iskandar Setiawan , GNU/Weeb Mailing List , Linux Kernel Mailing List , Linux Kselftest Mailing List Subject: [RESEND PATCH v1 2/3] nolibc/sys: Implement `getpagesize(2)` function Date: Sun, 8 Jan 2023 20:58:08 +0700 Message-Id: <20230108135809.850210-3-ammar.faizi@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230108135809.850210-1-ammar.faizi@intel.com> References: <20230108135809.850210-1-ammar.faizi@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 --- Side note: This function calls 'getauxval(3)' function that's defined in 'stdlib.h', but since most functions in 'stdlib.h' needs 'sys.h', the 'sys.h' is always included first. Therefore, we need a forward declaration of 'getauxval(3)' in sys.h. 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 3db1dd8c74ee..acf7cf438010 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -18,6 +18,7 @@ #include #include #include +#include #include "arch.h" #include "errno.h" @@ -498,6 +499,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); -- Ammar Faizi