Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp4908082rwl; Sun, 8 Jan 2023 05:27:12 -0800 (PST) X-Google-Smtp-Source: AMrXdXsRcbJfsoUxV5q+h4JSjukzH8HRECe+fXWQBIjxQ6tb1EtgLuR0/np7JRKYgMuofh6K6B3L X-Received: by 2002:a05:6402:22b2:b0:467:7c73:4805 with SMTP id cx18-20020a05640222b200b004677c734805mr27944377edb.5.1673184432633; Sun, 08 Jan 2023 05:27:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673184432; cv=none; d=google.com; s=arc-20160816; b=mWx9Gb8yaAk+v/eDWO72vAdS0/vSc3n6VDOqOAgtd9CFwo2UYfZ8ONA+OYnp/jQqnP +KMzZL/diNRlePqGj6i5meC7vGnTs3T1PKRDeYTUkTvXEgX5lMVzMoAgNXzooqJqtOSI rN1KwJNe36uizw91w3RkU1vrEqZhGd6wZwvlVHpdbmhb+v181PpVIRoDZX8cA8R60Ott utH7fNPEevqXSW+ygsogX/agbd5pCjaMayp07aZQPvox/PntSslY4UaJNtMdTCEC54rM u9kDTfw1/VizDiVhmXNStWc4iE/RF1paE8dlhZWvpszYx+ElccDrKL7z/GglKWpo2Bvc 8Kow== 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=N2cSHS6n2wqiqf+OEj3JM1FYyvGsjTuYNAJb9nHDuWyZzDM1w5UUAuec8ZkwEZCG8d p1QGunH1PsQ5rBlznCYu6INeSLz7E2cyUzDfCX1znS3vt/eBPjG0TJbMhytsY+tFQK+c AGh5WCz1jWb+jdCdi02fNnuZywuRxeLw5n3kDZRSNZmY3UOzGl7KFwKErc5lBfJE4vi+ 4NHsOR/IZoJjSCcgwbhFoCU5jWJ5u52A8QvxqZjNoC+/imIzMUi+Mn3NPWHeRx6h4uPV OX5ODBRG5lstPqVB2TXXLUIRu/k+Gt5be4LanbhUXkZGCR38NIHhksEOtf31cX821eL2 gPXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gnuweeb.org header.s=default header.b="Mx/Xe7Fh"; 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 f15-20020a50d54f000000b0048fd69cf2absi6767153edj.63.2023.01.08.05.27.00; Sun, 08 Jan 2023 05:27:12 -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="Mx/Xe7Fh"; 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 S234377AbjAHNJR (ORCPT + 53 others); Sun, 8 Jan 2023 08:09:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233743AbjAHNJH (ORCPT ); Sun, 8 Jan 2023 08:09:07 -0500 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98614E0DB; Sun, 8 Jan 2023 05:09:06 -0800 (PST) Received: from localhost.localdomain (unknown [182.253.183.184]) by gnuweeb.org (Postfix) with ESMTPSA id 983C37E628; Sun, 8 Jan 2023 13:09:03 +0000 (UTC) X-GW-Data: lPqxHiMPbJw1wb7CM9QUryAGzr0yq5atzVDdxTR0iA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1673183346; bh=wcpOgJmHUqHilg+MA55c94wnAlyf9zHTIyYePnjiqNM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mx/Xe7FhOkcuArrKQHu6u/K/TjrZoxtV4AR+gBCpIGXKcfnZJHJpd2DmIq9rTkOlJ RqhTS4k4aZBBeX6ADB4YEVp4986EGTbRBSSqqVf4zGpVRd6JNrFytLDDbvzf8qCDg5 8lbpzqw2lUNsIMI/hKKfSAyfBduTAGhvFMehg6y25k9nta+4pjdMFWn1pAWinkhaNv oLY5uBb1AfYrGZ49vWE25Pld8EuTL9wueKlETlwNGDh1i782vFyB/jkJBSK2QAXjZg RrDmba4jpQdT8mT+wg7FgI2aInbMT21yIzldX1kgSJ/jpliABapUBGH3FqLtpLHnTa qb2e5OBnzhJOw== 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: [PATCH v1 2/3] nolibc/sys: Implement `getpagesize(2)` function Date: Sun, 8 Jan 2023 20:08:51 +0700 Message-Id: <20230108130853.840948-3-ammar.faizi@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230108130853.840948-1-ammar.faizi@intel.com> References: <20221222035134.3467659-1-ammar.faizi@intel.com> <20221222043452.GB29086@1wt.eu> <20221222134615.3535422-1-ammar.faizi@intel.com> <20221227062640.GA5337@1wt.eu> <00eee75f-59fa-83b2-c7e1-f0da347b2dde@gnuweeb.org> <20221227184902.GA6287@1wt.eu> <23e84c59-4f2c-01b4-5b8a-80af39a1d761@gnuweeb.org> <20221228133513.GA7457@1wt.eu> <39d68044-2641-75da-929a-f5e852f0a3d0@gnuweeb.org> <20230103035427.GA4474@1wt.eu> <086ff43d-2647-0459-d993-6fc90d7ae779@gnuweeb.org> <20230108130853.840948-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