public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Xi Ruoyao <xry111@xry111.site>
To: libc-alpha@sourceware.org
Cc: caiyinyu <caiyinyu@loongson.cn>, Wang Xuerui <i@xen0n.name>,
	Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>,
	Andreas Schwab <schwab@suse.de>,
	Florian Weimer <fw@deneb.enyo.de>, Xi Ruoyao <xry111@xry111.site>
Subject: [PATCH v2 3/5] LoongArch: Define __ASSUME_SYSCALL_NAMED_WORKS for Linux
Date: Sat, 25 Mar 2023 22:08:13 +0800	[thread overview]
Message-ID: <20230325140815.4170296-4-xry111@xry111.site> (raw)
In-Reply-To: <20230325140815.4170296-1-xry111@xry111.site>

LoongArch calling convention treats the non-floating-point variable
arguments same as named ones, and when each argument is an integer
not wider than long or a pointer, the ith argument is in register $ai
(0 <= i < 8) or the stack slot at ($sp + sizeof(long) * (i - 8))
(i >= 8) no matter how many arguments are passed. So we can define
__ASSUME_SYSCALL_NAMED_WORKS to avoid unnecessary stack stores in the
syscall wrappers caused by va_start.
---
 .../sysv/linux/loongarch/kernel-features.h    | 29 +++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 sysdeps/unix/sysv/linux/loongarch/kernel-features.h

diff --git a/sysdeps/unix/sysv/linux/loongarch/kernel-features.h b/sysdeps/unix/sysv/linux/loongarch/kernel-features.h
new file mode 100644
index 0000000000..f862d0623f
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/loongarch/kernel-features.h
@@ -0,0 +1,29 @@
+/* Set flags signalling availability of kernel features based on given
+   kernel version number.
+   Copyright (C) 2023 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include_next <kernel-features.h>
+
+/* Define this if the calling convention for passing x named arguments and y
+   variable arguments is same as passing (x + y) named arguments, while each
+   argument is either an integer of which the width is less than or equal to
+   "long", or a pointer; and an argument can be fetched from the same register
+   or the same offset from the stack pointer no matter how many (maybe zero)
+   arguments are passed after it.  It avoids useless stack stores caused by
+   usage of va_start.  */
+#define __ASSUME_SYSCALL_NAMED_WORKS	1
-- 
2.40.0


  parent reply	other threads:[~2023-03-25 14:08 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-25 14:08 [PATCH v2 0/5] linux: Avoid va_list for generic syscall wrappers if possible Xi Ruoyao
2023-03-25 14:08 ` [PATCH v2 1/5] linux: Add __ASSUME_SYSCALL_NAMED_WORKS to allow avoiding va_list for generic syscall Xi Ruoyao
2023-03-25 14:08 ` [PATCH v2 2/5] linux: [__ASSUME_SYSCALL_NAMED_WORKS] Avoid using va_list for various syscall wrappers Xi Ruoyao
2023-03-25 14:08 ` Xi Ruoyao [this message]
2023-03-25 14:08 ` [PATCH v2 4/5] x86_64: Define __ASSUME_SYSCALL_NAMED_WORKS for Linux Xi Ruoyao
2023-03-25 14:08 ` [PATCH v2 5/5] aarch64: " Xi Ruoyao
2023-03-27 13:06   ` Adhemerval Zanella Netto
2023-03-27 13:32     ` Xi Ruoyao
2023-03-27 14:04 ` [PATCH v2 0/5] linux: Avoid va_list for generic syscall wrappers if possible Carlos O'Donell
2023-03-27 14:44   ` Xi Ruoyao
2023-03-27 14:45   ` Xi Ruoyao
2023-03-27 14:51     ` Xi Ruoyao
2023-04-04  1:25     ` caiyinyu
2023-04-04 12:12       ` Xi Ruoyao

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=20230325140815.4170296-4-xry111@xry111.site \
    --to=xry111@xry111.site \
    --cc=adhemerval.zanella@linaro.org \
    --cc=caiyinyu@loongson.cn \
    --cc=fw@deneb.enyo.de \
    --cc=i@xen0n.name \
    --cc=libc-alpha@sourceware.org \
    --cc=schwab@suse.de \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).