public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/azanella/syscall-refactor] hppa: Add internal_syscall
@ 2020-06-29 21:45 Adhemerval Zanella
0 siblings, 0 replies; only message in thread
From: Adhemerval Zanella @ 2020-06-29 21:45 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=2908890f778650fa1548a28b0430e47b576c3f53
commit 2908890f778650fa1548a28b0430e47b576c3f53
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Fri May 22 18:22:47 2020 -0300
hppa: Add internal_syscall
Diff:
---
sysdeps/unix/sysv/linux/hppa/____longjmp_chk.c | 4 +-
sysdeps/unix/sysv/linux/hppa/brk.c | 2 +-
sysdeps/unix/sysv/linux/hppa/syscall.c | 27 +----
sysdeps/unix/sysv/linux/hppa/sysdep.h | 155 +++++++++++++++++++++++++
4 files changed, 160 insertions(+), 28 deletions(-)
diff --git a/sysdeps/unix/sysv/linux/hppa/____longjmp_chk.c b/sysdeps/unix/sysv/linux/hppa/____longjmp_chk.c
index eae0a7fe31..4880f45c21 100644
--- a/sysdeps/unix/sysv/linux/hppa/____longjmp_chk.c
+++ b/sysdeps/unix/sysv/linux/hppa/____longjmp_chk.c
@@ -28,14 +28,14 @@
if ((unsigned long) (sp) > this_sp) \
{ \
stack_t oss; \
- int result = INTERNAL_SYSCALL_CALL (sigaltstack, NULL, &oss);\
+ int result = internal_syscall (__NR_sigaltstack, NULL, &oss); \
/* If we aren't using an alternate stack then we have already \
shown that we are jumping to a frame that doesn't exist so \
error out. If we are using an alternate stack we must prove \
that we are jumping *out* of the alternate stack. Note that \
the check for that is the same as that for _STACK_GROWS_UP \
as for _STACK_GROWS_DOWN. */ \
- if (!INTERNAL_SYSCALL_ERROR_P (result) \
+ if (! __syscall_ret (result) \
&& ((oss.ss_flags & SS_ONSTACK) == 0 \
|| ((unsigned long) oss.ss_sp + oss.ss_size \
- (unsigned long) (sp)) < oss.ss_size)) \
diff --git a/sysdeps/unix/sysv/linux/hppa/brk.c b/sysdeps/unix/sysv/linux/hppa/brk.c
index 89d1fd1835..d31d7c8281 100644
--- a/sysdeps/unix/sysv/linux/hppa/brk.c
+++ b/sysdeps/unix/sysv/linux/hppa/brk.c
@@ -28,7 +28,7 @@ __brk (void *addr)
{
void *newbrk;
- __curbrk = newbrk = (void *) INLINE_SYSCALL (brk, 1, addr);
+ __curbrk = newbrk = (void *) internal_syscall (__NR_brk, addr);
if (newbrk < addr)
{
diff --git a/sysdeps/unix/sysv/linux/hppa/syscall.c b/sysdeps/unix/sysv/linux/hppa/syscall.c
index 7f6794b09f..2190dcf03a 100644
--- a/sysdeps/unix/sysv/linux/hppa/syscall.c
+++ b/sysdeps/unix/sysv/linux/hppa/syscall.c
@@ -20,17 +20,13 @@
#include <errno.h>
/* HPPA implements syscall() in 'C'; the assembler version would
- typically be in syscall.S. Also note that we have INLINE_SYSCALL,
- INTERNAL_SYSCALL, and all the generated pure assembly syscall wrappers.
- How often the function is used is unknown. */
+ typically be in syscall.S. How often the function is used is unknown. */
long int
syscall (long int __sysno, ...)
{
- /* FIXME: Keep this matching INLINE_SYSCALL for hppa */
va_list args;
long int arg0, arg1, arg2, arg3, arg4, arg5;
- long int __sys_res;
/* Load varargs */
va_start (args, __sysno);
@@ -42,24 +38,5 @@ syscall (long int __sysno, ...)
arg5 = va_arg (args, long int);
va_end (args);
- {
- LOAD_ARGS_6 (arg0, arg1, arg2, arg3, arg4, arg5)
- register unsigned long int __res asm("r28");
- PIC_REG_DEF
- LOAD_REGS_6
- asm volatile (SAVE_ASM_PIC
- " ble 0x100(%%sr2, %%r0) \n"
- " copy %1, %%r20 \n"
- LOAD_ASM_PIC
- : "=r" (__res)
- : "r" (__sysno) PIC_REG_USE ASM_ARGS_6
- : "memory", CALL_CLOB_REGS CLOB_ARGS_6);
- __sys_res = __res;
- }
- if ((unsigned long int) __sys_res >= (unsigned long int) -4095)
- {
- __set_errno (-__sys_res);
- __sys_res = -1;
- }
- return __sys_res;
+ return inline_syscall (__sysno, arg0, arg1, arg2, arg3, arg4, arg5);
}
diff --git a/sysdeps/unix/sysv/linux/hppa/sysdep.h b/sysdeps/unix/sysv/linux/hppa/sysdep.h
index 7f8da30d23..f0640ea22d 100644
--- a/sysdeps/unix/sysv/linux/hppa/sysdep.h
+++ b/sysdeps/unix/sysv/linux/hppa/sysdep.h
@@ -468,6 +468,161 @@ L(pre_end): ASM_LINE_SEP \
#define CLOB_ARGS_1 CLOB_ARGS_2, "%r25"
#define CLOB_ARGS_0 CLOB_ARGS_1, "%r26"
+static inline long int
+__internal_syscall0 (long int name)
+{
+ register unsigned long res asm ("r28");
+ PIC_REG_DEF
+ /* FIXME: HACK save/load r19 around syscall */
+ asm volatile (SAVE_ASM_PIC
+ "ble 0x100(%%sr2, %%r0)\n"
+ "copy %1, %%r20\n"
+ LOAD_ASM_PIC
+ : "=r" (res)
+ : "r" (name) PIC_REG_USE
+ : "memory", CALL_CLOB_REGS,
+ "%r21", "%r22", "%r22", "%r23", "%r24", "%r25", "%r26");
+ return res;
+}
+
+static inline long int
+__internal_syscall1 (long int name, __syscall_arg_t arg1)
+{
+ register unsigned long res asm ("r28");
+ PIC_REG_DEF
+ register unsigned long r26 asm ("r26") = arg1;
+ /* FIXME: HACK save/load r19 around syscall */
+ asm volatile (SAVE_ASM_PIC
+ "ble 0x100(%%sr2, %%r0)\n"
+ "copy %1, %%r20\n"
+ LOAD_ASM_PIC
+ : "=r" (res)
+ : "r" (name) PIC_REG_USE,
+ "r" (r26)
+ : "memory", CALL_CLOB_REGS,
+ "%r21", "%r22", "%r22", "%r23", "%r24", "%r25");
+ return res;
+}
+
+static inline long int
+__internal_syscall2 (long int name, __syscall_arg_t arg1,
+ __syscall_arg_t arg2)
+{
+ register unsigned long res asm ("r28");
+ PIC_REG_DEF
+ register unsigned long r26 asm ("r26") = arg1;
+ register unsigned long r25 asm ("r25") = arg2;
+ /* FIXME: HACK save/load r19 around syscall */
+ asm volatile (SAVE_ASM_PIC
+ "ble 0x100(%%sr2, %%r0)\n"
+ "copy %1, %%r20\n"
+ LOAD_ASM_PIC
+ : "=r" (res)
+ : "r" (name) PIC_REG_USE,
+ "r" (r26), "r" (r25)
+ : "memory", CALL_CLOB_REGS,
+ "%r21", "%r22", "%r22", "%r23", "%r24");
+ return res;
+}
+
+static inline long int
+__internal_syscall3 (long int name, __syscall_arg_t arg1,
+ __syscall_arg_t arg2, __syscall_arg_t arg3)
+{
+ register unsigned long res asm ("r28");
+ PIC_REG_DEF
+ register unsigned long r26 asm ("r26") = arg1;
+ register unsigned long r25 asm ("r25") = arg2;
+ register unsigned long r24 asm ("r24") = arg3;
+ /* FIXME: HACK save/load r19 around syscall */
+ asm volatile (SAVE_ASM_PIC
+ "ble 0x100(%%sr2, %%r0)\n"
+ "copy %1, %%r20\n"
+ LOAD_ASM_PIC
+ : "=r" (res)
+ : "r" (name) PIC_REG_USE,
+ "r" (r26), "r" (r25), "r" (r24)
+ : "memory", CALL_CLOB_REGS,
+ "%r21", "%r22", "%r22", "%r23");
+ return res;
+}
+
+static inline long int
+__internal_syscall4 (long int name, __syscall_arg_t arg1,
+ __syscall_arg_t arg2, __syscall_arg_t arg3,
+ __syscall_arg_t arg4)
+{
+ register unsigned long res asm ("r28");
+ PIC_REG_DEF
+ register unsigned long r26 asm ("r26") = arg1;
+ register unsigned long r25 asm ("r25") = arg2;
+ register unsigned long r24 asm ("r24") = arg3;
+ register unsigned long r23 asm ("r23") = arg4;
+ /* FIXME: HACK save/load r19 around syscall */
+ asm volatile (SAVE_ASM_PIC
+ "ble 0x100(%%sr2, %%r0)\n"
+ "copy %1, %%r20\n"
+ LOAD_ASM_PIC
+ : "=r" (res)
+ : "r" (name) PIC_REG_USE,
+ "r" (r26), "r" (r25), "r" (r24), "r" (r23)
+ : "memory", CALL_CLOB_REGS,
+ "%r21", "%r22");
+ return res;
+}
+
+static inline long int
+__internal_syscall5 (long int name, __syscall_arg_t arg1,
+ __syscall_arg_t arg2, __syscall_arg_t arg3,
+ __syscall_arg_t arg4, __syscall_arg_t arg5)
+{
+ register unsigned long res asm ("r28");
+ PIC_REG_DEF
+ register unsigned long r26 asm ("r26") = arg1;
+ register unsigned long r25 asm ("r25") = arg2;
+ register unsigned long r24 asm ("r24") = arg3;
+ register unsigned long r23 asm ("r23") = arg4;
+ register unsigned long r22 asm ("r22") = arg5;
+ /* FIXME: HACK save/load r19 around syscall */
+ asm volatile (SAVE_ASM_PIC
+ "ble 0x100(%%sr2, %%r0)\n"
+ "copy %1, %%r20\n"
+ LOAD_ASM_PIC
+ : "=r" (res)
+ : "r" (name) PIC_REG_USE,
+ "r" (r26), "r" (r25), "r" (r24), "r" (r23), "r" (r22)
+ : "memory", CALL_CLOB_REGS,
+ "%r21");
+ return res;
+}
+
+static inline long int
+__internal_syscall6 (long int name, __syscall_arg_t arg1,
+ __syscall_arg_t arg2, __syscall_arg_t arg3,
+ __syscall_arg_t arg4, __syscall_arg_t arg5,
+ __syscall_arg_t arg6)
+{
+ register unsigned long res asm ("r28");
+ PIC_REG_DEF
+ register unsigned long r26 asm ("r26") = arg1;
+ register unsigned long r25 asm ("r25") = arg2;
+ register unsigned long r24 asm ("r24") = arg3;
+ register unsigned long r23 asm ("r23") = arg4;
+ register unsigned long r22 asm ("r22") = arg5;
+ register unsigned long r21 asm ("r21") = arg6;
+ /* FIXME: HACK save/load r19 around syscall */
+ asm volatile (SAVE_ASM_PIC
+ "ble 0x100(%%sr2, %%r0)\n"
+ "copy %1, %%r20\n"
+ LOAD_ASM_PIC
+ : "=r" (res)
+ : "r" (name) PIC_REG_USE,
+ "r" (r26), "r" (r25), "r" (r24), "r" (r23), "r" (r22),
+ "r" (r21)
+ : "memory", CALL_CLOB_REGS);
+ return res;
+}
+
#endif /* __ASSEMBLER__ */
/* Pointer mangling is not yet supported for HPPA. */
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-06-29 21:45 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-29 21:45 [glibc/azanella/syscall-refactor] hppa: Add internal_syscall Adhemerval Zanella
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).