Module Name: src
Committed By: kamil
Date: Sat Feb 17 15:22:22 UTC 2018
Modified Files:
src/sys/arch/sparc/include: mcontext.h
Log Message:
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>
To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/sparc/include/mcontext.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/sparc/include/mcontext.h
diff -u src/sys/arch/sparc/include/mcontext.h:1.14 src/sys/arch/sparc/include/mcontext.h:1.15
--- src/sys/arch/sparc/include/mcontext.h:1.14 Thu Feb 15 15:53:57 2018
+++ src/sys/arch/sparc/include/mcontext.h Sat Feb 17 15:22:22 2018
@@ -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 @@ typedef struct {
#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); \