[PATCH 28/28] alpha: Move implementations to C
Adhemerval Zanella
adhemerval.zanella@linaro.org
Wed Nov 18 19:55:52 GMT 2020
Move alpha specific the feraiseexcept, getegid, geteuid, getppid,
eee_get_fp_control, ieee_set_fp_control, and setcontext to C
implementations.
Checked on alpha-linux-gnu.
---
.../alpha/{fraiseexcpt.S => fraiseexcpt.c} | 37 ++++------------
.../sysv/linux/alpha/{getegid.S => getegid.c} | 15 ++++---
.../sysv/linux/alpha/{geteuid.S => geteuid.c} | 15 ++++---
.../sysv/linux/alpha/{getppid.S => getppid.c} | 15 ++++---
...get_fp_control.S => ieee_get_fp_control.c} | 43 ++++++-------------
...set_fp_control.S => ieee_set_fp_control.c} | 35 ++++-----------
.../alpha/{setcontext.S => setcontext.c} | 27 ++++++------
sysdeps/unix/sysv/linux/alpha/sysdep.h | 21 +++++++++
8 files changed, 87 insertions(+), 121 deletions(-)
rename sysdeps/unix/sysv/linux/alpha/{fraiseexcpt.S => fraiseexcpt.c} (66%)
rename sysdeps/unix/sysv/linux/alpha/{getegid.S => getegid.c} (79%)
rename sysdeps/unix/sysv/linux/alpha/{geteuid.S => geteuid.c} (79%)
rename sysdeps/unix/sysv/linux/alpha/{getppid.S => getppid.c} (79%)
rename sysdeps/unix/sysv/linux/alpha/{ieee_get_fp_control.S => ieee_get_fp_control.c} (61%)
rename sysdeps/unix/sysv/linux/alpha/{ieee_set_fp_control.S => ieee_set_fp_control.c} (62%)
rename sysdeps/unix/sysv/linux/alpha/{setcontext.S => setcontext.c} (62%)
diff --git a/sysdeps/unix/sysv/linux/alpha/fraiseexcpt.S b/sysdeps/unix/sysv/linux/alpha/fraiseexcpt.c
similarity index 66%
rename from sysdeps/unix/sysv/linux/alpha/fraiseexcpt.S
rename to sysdeps/unix/sysv/linux/alpha/fraiseexcpt.c
index 8c4b933749..903eaebb66 100644
--- a/sysdeps/unix/sysv/linux/alpha/fraiseexcpt.S
+++ b/sysdeps/unix/sysv/linux/alpha/fraiseexcpt.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004-2020 Free Software Foundation, Inc.
+/* Copyright (C) 2020 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
@@ -15,37 +15,16 @@
License along with the GNU C Library. If not, see
<https://www.gnu.org/licenses/>. */
+#include <fenv.h>
#include <sysdep.h>
#include "kernel_sysinfo.h"
-
- .text
-
-ENTRY(__feraiseexcept)
- cfi_startproc
- PSEUDO_PROLOGUE
-
- lda sp, -16(sp)
- cfi_adjust_cfa_offset(16)
-
- ldi v0, __NR_osf_setsysinfo
- stq a0, 0(sp)
- mov sp, a1
- ldi a0, SSI_IEEE_RAISE_EXCEPTION
- call_pal PAL_callsys
-
- lda sp, 16(sp)
- cfi_adjust_cfa_offset(-16)
-
- /* Here in libm we can't use SYSCALL_ERROR_LABEL. Nor is it clear
- that we'd want to set errno anyway. All we're required to do is
- return non-zero on error. Which is exactly A3. */
- mov a3, v0
- ret
-
-END(__feraiseexcept)
- cfi_endproc
-
+int
+__feraiseexcept (int excepts)
+{
+ return -INTERNAL_SYSCALL_CALL (osf_setsysinfo, SSI_IEEE_RAISE_EXCEPTION,
+ &excepts, 0, 0, 0);
+}
#if IS_IN (libm)
# include <shlib-compat.h>
# if SHLIB_COMPAT (libm, GLIBC_2_1, GLIBC_2_2)
diff --git a/sysdeps/unix/sysv/linux/alpha/getegid.S b/sysdeps/unix/sysv/linux/alpha/getegid.c
similarity index 79%
rename from sysdeps/unix/sysv/linux/alpha/getegid.S
rename to sysdeps/unix/sysv/linux/alpha/getegid.c
index 72a941210a..9aeccd5ba9 100644
--- a/sysdeps/unix/sysv/linux/alpha/getegid.S
+++ b/sysdeps/unix/sysv/linux/alpha/getegid.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1991-2020 Free Software Foundation, Inc.
+/* Get effective group identity. Linux/Alpha.
+ Copyright (C) 2020 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
@@ -15,12 +16,12 @@
License along with the GNU C Library. If not, see
<https://www.gnu.org/licenses/>. */
+#include <unistd.h>
#include <sysdep.h>
-
-PSEUDO (__getegid, getxgid, 0)
- MOVE (r1, r0)
- ret
-PSEUDO_END (__getegid)
-
+gid_t
+__getegid (void)
+{
+ return __internal_syscall_pair (__NR_getxgid).sc_20;
+}
weak_alias (__getegid, getegid)
diff --git a/sysdeps/unix/sysv/linux/alpha/geteuid.S b/sysdeps/unix/sysv/linux/alpha/geteuid.c
similarity index 79%
rename from sysdeps/unix/sysv/linux/alpha/geteuid.S
rename to sysdeps/unix/sysv/linux/alpha/geteuid.c
index a6db15d55c..63d73ac5d1 100644
--- a/sysdeps/unix/sysv/linux/alpha/geteuid.S
+++ b/sysdeps/unix/sysv/linux/alpha/geteuid.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1991-2020 Free Software Foundation, Inc.
+/* Get effective user identity. Linux/Alpha.
+ Copyright (C) 2020 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
@@ -15,12 +16,12 @@
License along with the GNU C Library. If not, see
<https://www.gnu.org/licenses/>. */
+#include <unistd.h>
#include <sysdep.h>
-
-PSEUDO (__geteuid, getxuid, 0)
- MOVE (r1, r0)
- ret
-PSEUDO_END (__geteuid)
-
+uid_t
+__geteuid (void)
+{
+ return __internal_syscall_pair (__NR_getxuid).sc_20;
+}
weak_alias (__geteuid, geteuid)
diff --git a/sysdeps/unix/sysv/linux/alpha/getppid.S b/sysdeps/unix/sysv/linux/alpha/getppid.c
similarity index 79%
rename from sysdeps/unix/sysv/linux/alpha/getppid.S
rename to sysdeps/unix/sysv/linux/alpha/getppid.c
index ae5cfc03aa..968b2a96a7 100644
--- a/sysdeps/unix/sysv/linux/alpha/getppid.S
+++ b/sysdeps/unix/sysv/linux/alpha/getppid.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1991-2020 Free Software Foundation, Inc.
+/* Get parent process identification. Linux/Alpha.
+ Copyright (C) 2020 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
@@ -15,12 +16,12 @@
License along with the GNU C Library. If not, see
<https://www.gnu.org/licenses/>. */
+#include <unistd.h>
#include <sysdep.h>
-
-PSEUDO (__getppid, getxpid, 0)
- MOVE (r1, r0)
- ret
-PSEUDO_END (__getppid)
-
+pid_t
+__getppid (void)
+{
+ return __internal_syscall_pair (__NR_getxpid).sc_20;
+}
weak_alias (__getppid, getppid)
diff --git a/sysdeps/unix/sysv/linux/alpha/ieee_get_fp_control.S b/sysdeps/unix/sysv/linux/alpha/ieee_get_fp_control.c
similarity index 61%
rename from sysdeps/unix/sysv/linux/alpha/ieee_get_fp_control.S
rename to sysdeps/unix/sysv/linux/alpha/ieee_get_fp_control.c
index 72c2fbfc10..44e467f927 100644
--- a/sysdeps/unix/sysv/linux/alpha/ieee_get_fp_control.S
+++ b/sysdeps/unix/sysv/linux/alpha/ieee_get_fp_control.c
@@ -1,6 +1,5 @@
-/* Copyright (C) 1993-2020 Free Software Foundation, Inc.
+/* Copyright (C) 2020 Free Software Foundation, Inc.
This file is part of the GNU C Library.
- Contributed by David Mosberger <davidm@azstarnet.com>, 1995.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -16,35 +15,19 @@
License along with the GNU C Library. If not, see
<https://www.gnu.org/licenses/>. */
+#include <fenv_libc.h>
#include <sysdep.h>
#include "kernel_sysinfo.h"
-
- .text
-
-ENTRY(__ieee_get_fp_control)
- cfi_startproc
- PSEUDO_PROLOGUE
-
- lda sp, -16(sp)
- cfi_adjust_cfa_offset(16)
-
- mov sp, a1
- ldi a0, GSI_IEEE_FP_CONTROL
- ldi v0, __NR_osf_getsysinfo
- call_pal PAL_callsys
-
- ldq t0, 0(sp)
- lda sp, 16(sp)
- cfi_adjust_cfa_offset(-16)
-
- bne a3, SYSCALL_ERROR_LABEL
-
- mov t0, v0
- ret
-
-PSEUDO_END(__ieee_get_fp_control)
- cfi_endproc
-
-libc_hidden_def(__ieee_get_fp_control)
+unsigned long int
+__ieee_get_fp_control (void)
+{
+ unsigned long int env;
+ int r = INLINE_SYSCALL_CALL (osf_getsysinfo, GSI_IEEE_FP_CONTROL, &env, 0,
+ 0, 0);
+ if (r != 0)
+ return r;
+ return env;
+}
+libc_hidden_def (__ieee_get_fp_control)
weak_alias (__ieee_get_fp_control, ieee_get_fp_control)
diff --git a/sysdeps/unix/sysv/linux/alpha/ieee_set_fp_control.S b/sysdeps/unix/sysv/linux/alpha/ieee_set_fp_control.c
similarity index 62%
rename from sysdeps/unix/sysv/linux/alpha/ieee_set_fp_control.S
rename to sysdeps/unix/sysv/linux/alpha/ieee_set_fp_control.c
index 9e80346b3e..0a85ff1b64 100644
--- a/sysdeps/unix/sysv/linux/alpha/ieee_set_fp_control.S
+++ b/sysdeps/unix/sysv/linux/alpha/ieee_set_fp_control.c
@@ -1,6 +1,5 @@
-/* Copyright (C) 1993-2020 Free Software Foundation, Inc.
+/* Copyright (C) 2020 Free Software Foundation, Inc.
This file is part of the GNU C Library.
- Contributed by David Mosberger <davidm@azstarnet.com>, 1995.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -16,31 +15,15 @@
License along with the GNU C Library. If not, see
<https://www.gnu.org/licenses/>. */
+#include <fenv_libc.h>
#include <sysdep.h>
#include "kernel_sysinfo.h"
-
-ENTRY(__ieee_set_fp_control)
- cfi_startproc
- PSEUDO_PROLOGUE
-
- lda sp, -16(sp)
- cfi_adjust_cfa_offset(16)
-
- ldi v0, __NR_osf_setsysinfo
- stq a0, 0(sp)
- mov sp, a1
- ldi a0, SSI_IEEE_FP_CONTROL
- call_pal PAL_callsys
-
- lda sp, 16(sp)
- cfi_adjust_cfa_offset(-16)
-
- bne a3, SYSCALL_ERROR_LABEL
- ret
-
-PSEUDO_END(__ieee_set_fp_control)
- cfi_endproc
-
-libc_hidden_def(__ieee_set_fp_control)
+void
+__ieee_set_fp_control (unsigned long int env)
+{
+ INLINE_SYSCALL_CALL (osf_setsysinfo, SSI_IEEE_FP_CONTROL, &env, 0,
+ 0, 0);
+}
+libc_hidden_def (__ieee_set_fp_control)
weak_alias (__ieee_set_fp_control, ieee_set_fp_control)
diff --git a/sysdeps/unix/sysv/linux/alpha/setcontext.S b/sysdeps/unix/sysv/linux/alpha/setcontext.c
similarity index 62%
rename from sysdeps/unix/sysv/linux/alpha/setcontext.S
rename to sysdeps/unix/sysv/linux/alpha/setcontext.c
index 734f3d5109..4478bef26b 100644
--- a/sysdeps/unix/sysv/linux/alpha/setcontext.S
+++ b/sysdeps/unix/sysv/linux/alpha/setcontext.c
@@ -1,5 +1,5 @@
-/* Install given context.
- Copyright (C) 2004-2020 Free Software Foundation, Inc.
+/* Set the user context. Linux/Alpha version.
+ Copyright (C) 2020 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
@@ -16,19 +16,16 @@
License along with the GNU C Library. If not, see
<https://www.gnu.org/licenses/>. */
+#include <ucontext.h>
#include <sysdep.h>
-#include <ucontext-offsets.h>
-
-/* In case the user fiddled it, copy the "official" signal mask
- from the ucontext_t into the sigcontext structure. */
-#undef PSEUDO_PREPARE_ARGS
-#define PSEUDO_PREPARE_ARGS \
- ldq $0, UC_SIGMASK($16); \
- stq $0, UC_SIGCTX+SC_MASK($16); \
- lda $16, UC_SIGCTX($16);
-
-PSEUDO(__setcontext, sigreturn, 1)
- ret
-PSEUDO_END(__setcontext)
+int
+__setcontext (const ucontext_t *ucp)
+{
+ /* In case the user fiddled it, copy the "official" signal mask
+ from the ucontext_t into the sigcontext structure. */
+ ucontext_t *ucp_noconst = (ucontext_t *) ucp;
+ ucp_noconst->uc_mcontext.sc_mask = *((long int *)&ucp_noconst->uc_sigmask);
+ return INLINE_SYSCALL_CALL (sigreturn, &ucp->uc_mcontext);
+}
weak_alias (__setcontext, setcontext)
diff --git a/sysdeps/unix/sysv/linux/alpha/sysdep.h b/sysdeps/unix/sysv/linux/alpha/sysdep.h
index 7daf445068..6d5458e2d8 100644
--- a/sysdeps/unix/sysv/linux/alpha/sysdep.h
+++ b/sysdeps/unix/sysv/linux/alpha/sysdep.h
@@ -314,6 +314,27 @@ __LABEL(name) \
: : internal_syscall_clobbers); \
_sc_19 != 0 ? -_sc_0 : _sc_0; \
})
+
+struct pair_t
+{
+ long int sc_0;
+ long int sc_20;
+};
+
+static inline struct pair_t
+__internal_syscall_pair (long int name)
+{
+ register long int sc_19 asm ("$19");
+ register long int sc_20 asm ("$20");
+ register long int sc_0 = name;
+ asm volatile ("callsys # %0 %1 <= %2"
+ : "+v" (sc_0), "=r" (sc_19), "=r" (sc_20)
+ :
+ : internal_syscall_clobbers,
+ "$16", "$17", "$18", "$21");
+ return (struct pair_t) { sc_0, sc_20 };
+}
+
#endif /* ASSEMBLER */
/* Pointer mangling support. Note that tls access is slow enough that
--
2.25.1
More information about the Libc-alpha
mailing list