Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp3607993rwl; Sun, 2 Apr 2023 11:05:02 -0700 (PDT) X-Google-Smtp-Source: AKy350Zi1gdotJ+hWxCzU23xp44ruVFlDTklA0m/w7kPi3LlBpib+c+ZDxCmpr0JelVTqpOBFKVf X-Received: by 2002:a17:903:27ce:b0:19c:da7f:a234 with SMTP id km14-20020a17090327ce00b0019cda7fa234mr27436631plb.67.1680458702569; Sun, 02 Apr 2023 11:05:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680458702; cv=none; d=google.com; s=arc-20160816; b=yz83FIoTE8iUSo9kt/8Yy2jHq+LvhGB7W+6Nt4+ImGYc90tOrFFoRAgcEUDADlIFLh H2k9vPjZmeFL5JgClSBEOx73SKViWqVtY+7jdnzjiz0721ZhfqfBkWCYbRqrEKtAYu1u YEwxcZYj4II8HpLMXM6ib+EYMGDU9oUSQfwtWG8MADRuAl5Re7GuaQ6y5t15Px004BXU FMJguf6XsPAlR4shIKQcJPkUPmowLf0BmPUik6e7qAtFn1yJeVk4t/XxGwBOjGmvUmYY D31k/IsLkRfsSn2wLQS17gno1kxnzwPULrlyk+A9tBEgfmF4hvj+0DTEon1VpObsmUDj BpAg== 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=cHCABVvFxjVMVU8j05MbiK0xguJ6RYhdXYrHRZQG96oWTRG++CPjww7zLcmmLY2WYp 5vwZlQZuRHoVv/J4ghMxKleBgfo3FJqUXhZCJ5mCZi0bvgFhbtSjPDC1aPJQo3T0R2zX MUZXv4ORo4LwVINFAhqQO0+OyTERdzBTliYC+1HndWmJ2S44YXQEDEdAnHqIvBqtTNol fN7dsA9FFU4qDffjgI+Pm9EUduBzxMOtB838zD1y0ZA1q2byB6GqUHE6nqG/xKt8xAKx v6RZhHlqz73rf6Sfo02+pJYyJ1vERidxz5SegR53PRAjgLvqot0sNHnxcrvE+Xpute/O 7fIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@weissschuh.net header.s=mail header.b=t29kOege; 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 w8-20020a1709027b8800b001a183ade8f7si6257957pll.433.2023.04.02.11.04.50; Sun, 02 Apr 2023 11:05:02 -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=t29kOege; 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 S231315AbjDBSEr (ORCPT + 99 others); Sun, 2 Apr 2023 14:04:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230478AbjDBSEq (ORCPT ); Sun, 2 Apr 2023 14:04:46 -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 623EF4EFD; Sun, 2 Apr 2023 11:04:45 -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=1680458683; bh=WpL7AHZ/RVZDepQeqXUZNCLzamt9+Jfw6eToN9dbdkk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=t29kOegeu0yrjhaRhphXka1AJv8dp1R6T2UEglYfOBN5JIXWo3Q9SJmFcsDsQDEuF ooA+XcAvMvDprzbZF2KpELe5PRjtm3CXdd5KEvRW7A5cA7YGmbXm7Zabfr/Q7DeTSE PtrRZlfDJhJVKYc1GLhbgqLHm44AkBndUkXM/ots= Date: Sun, 02 Apr 2023 18:04:35 +0000 Subject: [PATCH v3 2/4] 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-v3-2-ddc79f92efd5@weissschuh.net> References: <20230328-nolibc-printf-test-v3-0-ddc79f92efd5@weissschuh.net> In-Reply-To: <20230328-nolibc-printf-test-v3-0-ddc79f92efd5@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=1680458682; l=1058; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=WpL7AHZ/RVZDepQeqXUZNCLzamt9+Jfw6eToN9dbdkk=; b=SWX0F2lLJt4IidEUS718+TFzjJz9Pt8aypgXLOk79aZ2l1abVew2uqgb+bV2rFVC2NcVhXha6 dIhXOgzygv9DKZ6qqz/3ByATgmcR1k5WdkEEHId4zEFV6yOHIK3/v3H 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