Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp4965658rwl; Tue, 28 Mar 2023 14:02:55 -0700 (PDT) X-Google-Smtp-Source: AKy350ZNueal2YjPNKPzXVhCyO5IfJ6+2xeWVvVnGUcXNSlHO9Io90RT4FuuB+jsscwdiC2O/JkX X-Received: by 2002:a17:906:a15a:b0:933:1967:a98a with SMTP id bu26-20020a170906a15a00b009331967a98amr16974312ejb.17.1680037374914; Tue, 28 Mar 2023 14:02:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680037374; cv=none; d=google.com; s=arc-20160816; b=RU3if0S1z75NsUtqb4zRlaaYMbogUx7TE0MZmcHI+8eCevpBNvs6yNjpZGRbbnKyhT BkN6s4pQNIq9F2gmgBhdKaIGEVUTfq/4igRbYBMukwC69lRkmvnitw6sGZTGYAYCtE/Y CflaX3kY+NHVske2m379bbQCJlgr+Xf4M5CQrhOS7VnIeNGsi4oom6lD48UTXBPxwfHD /onLw++N8EFxTRj7g6r0dRTq4I9b4U2cV5sv0YVzX2o88NFPtAwb7EJOzFNQFH8LI4s9 j4HWDeZBwyUJ6RZdAwwzHZXzb/RS4QWNC4tE4HESrBp/PnL4FgHaARcPhybDyeVzbGqE 4wKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:dkim-signature :from; bh=Tn92QrYrO30FJIGvcj7KKlVx9kMcoU0T+e1tbWXUs+A=; b=oWC6gkUgncGyaqb4ucj5YiZKF2IU4q3xwhuTl2XvCsf0dQ19m32MfDpiH5DBvWCF3t keRDcvO+13e8xuc5lBVGZi/eScybOHie3ugulR49lDqH2YEiwW1fa1BX3CQIz0h4uVZB z1C34IEJSWL98S+Gp5U3qEPUgn/8unhe1Amk8bmEmOWtlO2lJe99aQRKO+HssiFNLteg XsNQKw5fxlYv4a6cxV4U2oMi86BUtCeIzUxEE4ylicsvzXOpTHNorwCO39E+UWlRAx73 QG2aiRAOu4RiCwR4STCRbvgq9ObpuWKDHjHVXV39UjCpBS02ShLvcAapG863elXmgWYd V8Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b=qZPhWCAQ; 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 s1-20020aa7c541000000b005024a94026dsi4184905edr.338.2023.03.28.14.02.29; Tue, 28 Mar 2023 14:02:54 -0700 (PDT) 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=@weissschuh.net header.s=mail header.b=qZPhWCAQ; 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 S229740AbjC1VBs (ORCPT + 99 others); Tue, 28 Mar 2023 17:01:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229601AbjC1VBh (ORCPT ); Tue, 28 Mar 2023 17:01:37 -0400 Received: from todd.t-8ch.de (todd.t-8ch.de [IPv6:2a01:4f8:c010:41de::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B75841716; Tue, 28 Mar 2023 14:01:36 -0700 (PDT) From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=weissschuh.net; s=mail; t=1680037294; bh=WpL7AHZ/RVZDepQeqXUZNCLzamt9+Jfw6eToN9dbdkk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=qZPhWCAQ9mtX5UcSjcGvLyKkKjhiFzgMte5Vjg6gqQl1RcW2iPGKrnzfc4GnJVj6C otaonLDTMl6al5TaZvKq0qGD+93+YqIWGndU7V0VfGhew6tioj8XEpCHWMvlknqcQk tnBtmN8qgUHwVBhs2FQI62qykfFvs3RBYSWN3fq4= Date: Tue, 28 Mar 2023 21:01:29 +0000 Subject: [PATCH 1/3] tools/nolibc: add wrapper for memfd_create MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Message-Id: <20230328-nolibc-printf-test-v1-1-d7290ec893dd@weissschuh.net> References: <20230328-nolibc-printf-test-v1-0-d7290ec893dd@weissschuh.net> In-Reply-To: <20230328-nolibc-printf-test-v1-0-d7290ec893dd@weissschuh.net> To: Willy Tarreau , Shuah Khan Cc: linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1680037292; l=1058; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=WpL7AHZ/RVZDepQeqXUZNCLzamt9+Jfw6eToN9dbdkk=; b=hxBrlQLFrwwDVd42h6UbrnnXBWKCutgcco3Nq/SMyjiRMzJ3HK4yzYu5PEOfWL0E8UFWSQxGz /ooa/8xHDRiDpwNiHshJJA0TawDG/PFtrF+dRBinwEkoHrWIvaaLRG1 X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 This is useful for users and will also be used by a future testcase. Signed-off-by: Thomas Weißschuh --- tools/include/nolibc/sys.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tools/include/nolibc/sys.h b/tools/include/nolibc/sys.h index 5d624dc63a42..bea9760dbd16 100644 --- a/tools/include/nolibc/sys.h +++ b/tools/include/nolibc/sys.h @@ -1365,6 +1365,29 @@ ssize_t write(int fd, const void *buf, size_t count) return ret; } + +/* + * int memfd_create(const char *name, unsigned int flags); + */ + +static __attribute__((unused)) +int sys_memfd_create(const char *name, unsigned int flags) +{ + return my_syscall2(__NR_memfd_create, name, flags); +} + +static __attribute__((unused)) +int memfd_create(const char *name, unsigned int flags) +{ + ssize_t ret = sys_memfd_create(name, flags); + + if (ret < 0) { + SET_ERRNO(-ret); + ret = -1; + } + return ret; +} + /* make sure to include all global symbols */ #include "nolibc.h" -- 2.40.0