linux-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Zhangjin Wu <falcon@tinylab.org>
To: w@1wt.eu
Cc: falcon@tinylab.org, arnd@arndb.de, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org, linux-riscv@lists.infradead.org,
	thomas@t-8ch.de
Subject: [PATCH 2/4] tools/nolibc: unistd.h: apply __syscall_ret() helper
Date: Sun,  4 Jun 2023 13:36:20 +0800	[thread overview]
Message-ID: <b3e791c9c2cd564e1b9b94d61104aa7d69b603c1.1685856497.git.falcon@tinylab.org> (raw)
In-Reply-To: <cover.1685856497.git.falcon@tinylab.org>

get the return type automatically and use __syscall_ret() to shrink 4
code lines.

Signed-off-by: Zhangjin Wu <falcon@tinylab.org>
---
 tools/include/nolibc/unistd.h | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/tools/include/nolibc/unistd.h b/tools/include/nolibc/unistd.h
index 6773e83c16a0..e4e2b4c09771 100644
--- a/tools/include/nolibc/unistd.h
+++ b/tools/include/nolibc/unistd.h
@@ -56,14 +56,10 @@ int tcsetpgrp(int fd, pid_t pid)
 	return ioctl(fd, TIOCSPGRP, &pid);
 }
 
-#define _syscall(N, ...)                                                      \
-({                                                                            \
-	int _ret = my_syscall##N(__VA_ARGS__);                                \
-	if (_ret < 0) {                                                       \
-		SET_ERRNO(-_ret);                                             \
-		_ret = -1;                                                    \
-	}                                                                     \
-	_ret;                                                                 \
+#define _syscall(N, ...)							\
+({										\
+	typeof(my_syscall##N(__VA_ARGS__)) _ret = my_syscall##N(__VA_ARGS__);	\
+	__syscall_ret(_ret);							\
 })
 
 #define _sycall_narg(...) __syscall_narg(__VA_ARGS__, 6, 5, 4, 3, 2, 1, 0)
-- 
2.25.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

  parent reply	other threads:[~2023-06-04  5:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-04  5:33 [PATCH 0/4] tools/nolibc: add two new syscall helpers Zhangjin Wu
2023-06-04  5:34 ` [PATCH 1/4] tools/nolibc: unistd.h: add __syscall() and __syscall_ret() helpers Zhangjin Wu
2023-06-04 12:59   ` Willy Tarreau
2023-06-04 19:21     ` Thomas Weißschuh
2023-06-05  5:58       ` Zhangjin Wu
2023-06-05  6:19         ` Willy Tarreau
2023-06-05  9:33           ` Zhangjin Wu
2023-06-04  5:36 ` Zhangjin Wu [this message]
2023-06-04  5:39 ` [PATCH 3/4] tools/nolibc: sys.h: apply __syscall_ret() helper Zhangjin Wu
2023-06-04  5:43 ` [PATCH 4/4] tools/nolibc: sys.h: apply __syscall() helper Zhangjin Wu

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=b3e791c9c2cd564e1b9b94d61104aa7d69b603c1.1685856497.git.falcon@tinylab.org \
    --to=falcon@tinylab.org \
    --cc=arnd@arndb.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=thomas@t-8ch.de \
    --cc=w@1wt.eu \
    /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;
as well as URLs for NNTP newsgroup(s).