Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/sparc/include Improve _UC_MACHINE_FP() for SPARC/SP...
details: https://anonhg.NetBSD.org/src/rev/4859d6897341
branches: trunk
changeset: 359614:4859d6897341
user: kamil <kamil%NetBSD.org@localhost>
date: Sat Feb 17 15:22:22 2018 +0000
description:
Improve _UC_MACHINE_FP() for SPARC/SPARC64
Introduce a static inline function _uc_machine_fp() that contains improved
caluclation of a frame pointer.
Algorithm:
uptr *stk_ptr;
# if defined (__arch64__)
stk_ptr = (uptr *) (*sp + 2047);
# else
stk_ptr = (uptr *) *sp;
# endif
*bp = stk_ptr[15];
Noted by <mrg>
diffstat:
sys/arch/sparc/include/mcontext.h | 22 ++++++++++++++++++----
1 files changed, 18 insertions(+), 4 deletions(-)
diffs (45 lines):
diff -r 06e2c04b19f8 -r 4859d6897341 sys/arch/sparc/include/mcontext.h
--- a/sys/arch/sparc/include/mcontext.h Sat Feb 17 13:54:52 2018 +0000
+++ b/sys/arch/sparc/include/mcontext.h Sat Feb 17 15:22:22 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mcontext.h,v 1.14 2018/02/15 15:53:57 kamil Exp $ */
+/* $NetBSD: mcontext.h,v 1.15 2018/02/17 15:22:22 kamil Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -146,18 +146,32 @@
#ifdef __arch64__
#define _UC_MACHINE_PAD 8 /* Padding appended to ucontext_t */
#define _UC_MACHINE_SP(uc) (((uc)->uc_mcontext.__gregs[_REG_O6])+0x7ff)
-#define _UC_MACHINE_FP(uc) (((uc)->uc_mcontext.__gregs[_REG_O6])+0x80e)
+#define _UC_MACHINE_FP(uc) (_uc_machine_fp((uc), 2047))
#define _UC_MACHINE32_PAD 43 /* compat_netbsd32 variant */
#define _UC_MACHINE32_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_O6])
-#define _UC_MACHINE32_FP(uc) (((uc)->uc_mcontext.__gregs[_REG_O6])+0xf)
+#define _UC_MACHINE32_FP(uc) (_uc_machine_fp((uc), 0))
#else
#define _UC_MACHINE_PAD 43 /* Padding appended to ucontext_t */
#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_O6])
-#define _UC_MACHINE_FP(uc) (((uc)->uc_mcontext.__gregs[_REG_O6])+0xf)
+#define _UC_MACHINE_FP(uc) (_uc_machine_fp((uc), 0))
#endif
#define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_PC])
#define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_O0])
+static inline long
+_uc_machine_fp(ucontext_t *ucontext, long shift)
+{
+ long *sptr;
+ long *sp;
+ long fp;
+
+ sp = (long *)_UC_MACHINE_SP(ucontext);
+ sptr = (long *)(*sp + shift);
+ fp = sptr[15];
+
+ return fp;
+}
+
#define _UC_MACHINE_SET_PC(uc, pc) \
do { \
(uc)->uc_mcontext.__gregs[_REG_PC] = (pc); \
Home |
Main Index |
Thread Index |
Old Index