public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Willy Tarreau <w@1wt.eu>
To: "Paul E. McKenney" <paulmck@kernel.org>
Cc: linux@weissschuh.net, linux-kernel@vger.kernel.org,
	Willy Tarreau <w@1wt.eu>
Subject: [PATCH 2/4] tools/nolibc: add wrapper for memfd_create
Date: Sun,  2 Apr 2023 20:48:04 +0200	[thread overview]
Message-ID: <20230402184806.12440-3-w@1wt.eu> (raw)
In-Reply-To: <20230402184806.12440-1-w@1wt.eu>

From: Thomas Weißschuh <linux@weissschuh.net>

This is useful for users and will also be used by a future testcase.

Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Signed-off-by: Willy Tarreau <w@1wt.eu>
---
 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.17.5


  parent reply	other threads:[~2023-04-02 18:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-02 18:48 [PATCH 0/4] tools/nolibc: add testcases for vfprintf Willy Tarreau
2023-04-02 18:48 ` [PATCH 1/4] tools/nolibc: add libc-test binary Willy Tarreau
2023-04-02 18:48 ` Willy Tarreau [this message]
2023-04-02 18:48 ` [PATCH 3/4] tools/nolibc: implement fd-based FILE streams Willy Tarreau
2023-04-02 18:48 ` [PATCH 4/4] tools/nolibc: add testcases for vfprintf Willy Tarreau
2023-04-02 21:24 ` [PATCH 0/4] " Paul E. McKenney
2023-04-04 20:40   ` Paul E. McKenney
2023-04-04 20:46     ` Willy Tarreau
2023-04-04 20:48       ` Paul E. McKenney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230402184806.12440-3-w@1wt.eu \
    --to=w@1wt.eu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@weissschuh.net \
    --cc=paulmck@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox