From c5d757340e353d463edd2775451c6b75cf243593 Mon Sep 17 00:00:00 2001 From: snj Date: Sun, 25 Feb 2018 23:50:22 +0000 Subject: [PATCH] Pull up following revision(s) (requested by kamil in ticket #552): sys/arch/aarch64/include/mcontext.h: 1.2 sys/arch/alpha/include/mcontext.h: 1.9 sys/arch/amd64/include/mcontext.h: 1.19 sys/arch/arm/include/mcontext.h: 1.19 sys/arch/hppa/include/mcontext.h: 1.9 sys/arch/i386/include/mcontext.h: 1.14 sys/arch/ia64/include/mcontext.h: 1.6 sys/arch/m68k/include/mcontext.h: 1.10 sys/arch/mips/include/mcontext.h: 1.22 sys/arch/or1k/include/mcontext.h: 1.2 sys/arch/powerpc/include/mcontext.h: 1.18 sys/arch/riscv/include/mcontext.h: 1.5 sys/arch/sh3/include/mcontext.h: 1.11 sys/arch/sparc/include/mcontext.h: 1.14-1.17 sys/arch/sparc64/include/mcontext.h: 1.10 sys/arch/vax/include/mcontext.h: 1.9 tests/lib/libc/sys/Makefile: 1.50 tests/lib/libc/sys/t_ucontext.c: 1.2 Introduce _UC_MACHINE_FP() as a macro _UC_MACHINE_FP() is a helper macro to extract from mcontext a frame pointer. Don't rely on this interface as a compiler might strip frame pointer or optimize it making this interface unreliable. For hppa assume a small frame context, for larger frames FP might be located in a different register (4 instead of 3). For ia64 there is no strict frame pointer, and registers might rotate. Reuse 79 following: ./gcc/config/ia64/ia64.h:#define HARD_FRAME_POINTER_REGNUM LOC_REG (79) Once ia64 will mature, this should be revisited. A macro can encapsulate a real function for extracting Frame Pointer on more complex CPUs / ABIs. For the remaining CPUs, reuse standard register as defined in appropriate ABI. The direct users of this macro are LLVM and GCC with Sanitizers. Proposed on tech-userlevel@. Sponsored by -- 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 -- Make _UC_MACHINE_FP() compile again and fix it so that it does not add the offset twice. -- fix _UC_MACHINE32_FP() -- use 32 bit pointer value so that [15] is the right offset. do this by using __greg32_t, which is only in the sparc64 version, and these are only useful there, so move them. -- Add new tests in lib/libc/sys/t_ucontext New tests: - ucontext_sp - ucontext_fp - ucontext_pc - ucontext_intrv They test respectively: - _UC_MACHINE_SP - _UC_MACHINE_FP - _UC_MACHINE_PC - _UC_MACHINE_INTRV These tests attempt to access and print the values from ucontext, without interpreting the values. This is a follow up of the _UC_MACHINE_FP() introduction. These tests use PRIxREGISTER, and require to be built with -D_KERNTYPES. Sponsored by --- sys/arch/aarch64/include/mcontext.h | 3 +- sys/arch/alpha/include/mcontext.h | 3 +- sys/arch/amd64/include/mcontext.h | 3 +- sys/arch/arm/include/mcontext.h | 3 +- sys/arch/hppa/include/mcontext.h | 3 +- sys/arch/i386/include/mcontext.h | 3 +- sys/arch/ia64/include/mcontext.h | 3 +- sys/arch/m68k/include/mcontext.h | 3 +- sys/arch/mips/include/mcontext.h | 3 +- sys/arch/or1k/include/mcontext.h | 3 +- sys/arch/powerpc/include/mcontext.h | 3 +- sys/arch/riscv/include/mcontext.h | 3 +- sys/arch/sh3/include/mcontext.h | 3 +- sys/arch/sparc/include/mcontext.h | 20 ++++----- sys/arch/sparc64/include/mcontext.h | 10 +++-- sys/arch/vax/include/mcontext.h | 3 +- tests/lib/libc/sys/Makefile | 3 +- tests/lib/libc/sys/t_ucontext.c | 68 ++++++++++++++++++++++++++++- 18 files changed, 113 insertions(+), 30 deletions(-) diff --git a/sys/arch/aarch64/include/mcontext.h b/sys/arch/aarch64/include/mcontext.h index 2af2b1e5d7fc..61bf283cf068 100644 --- a/sys/arch/aarch64/include/mcontext.h +++ b/sys/arch/aarch64/include/mcontext.h @@ -1,4 +1,4 @@ -/* $NetBSD: mcontext.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */ +/* $NetBSD: mcontext.h,v 1.1.22.1 2018/02/25 23:50:22 snj Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -106,6 +106,7 @@ typedef struct { #define _UC_TLSBASE 0x00080000 /* see */ #define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_SP]) +#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_X29]) #define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_PC]) #define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_X0]) diff --git a/sys/arch/alpha/include/mcontext.h b/sys/arch/alpha/include/mcontext.h index 13ca3fd2cd7c..c0420bafc627 100644 --- a/sys/arch/alpha/include/mcontext.h +++ b/sys/arch/alpha/include/mcontext.h @@ -1,4 +1,4 @@ -/* $NetBSD: mcontext.h,v 1.8 2012/09/12 02:00:54 manu Exp $ */ +/* $NetBSD: mcontext.h,v 1.8.32.1 2018/02/25 23:50:22 snj Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -96,6 +96,7 @@ typedef struct { #define _UC_TLSBASE 0x20 /* valid process-unique value in _REG_UNIQUE */ #define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_SP]) +#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_S6]) #define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_PC]) #define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_V0]) diff --git a/sys/arch/amd64/include/mcontext.h b/sys/arch/amd64/include/mcontext.h index bed3a79e965f..6384529c66a0 100644 --- a/sys/arch/amd64/include/mcontext.h +++ b/sys/arch/amd64/include/mcontext.h @@ -1,4 +1,4 @@ -/* $NetBSD: mcontext.h,v 1.18 2014/05/12 22:50:03 uebayasi Exp $ */ +/* $NetBSD: mcontext.h,v 1.18.20.1 2018/02/25 23:50:22 snj Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -68,6 +68,7 @@ typedef struct { /* AMD64 ABI 128-bytes "red zone". */ #define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_RSP] - 128) +#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_RBP]) #define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_RIP]) #define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_RAX]) diff --git a/sys/arch/arm/include/mcontext.h b/sys/arch/arm/include/mcontext.h index d0d0cc1cd3b8..39929cb04374 100644 --- a/sys/arch/arm/include/mcontext.h +++ b/sys/arch/arm/include/mcontext.h @@ -1,4 +1,4 @@ -/* $NetBSD: mcontext.h,v 1.18 2015/03/24 08:38:29 matt Exp $ */ +/* $NetBSD: mcontext.h,v 1.18.10.1 2018/02/25 23:50:22 snj Exp $ */ /*- * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc. @@ -110,6 +110,7 @@ typedef struct { #define _UC_MACHINE_PAD 1 /* Padding appended to ucontext_t */ #define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_SP]) +#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_R11]) #define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_PC]) #define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_R0]) diff --git a/sys/arch/hppa/include/mcontext.h b/sys/arch/hppa/include/mcontext.h index a0618cebce48..623027e997a2 100644 --- a/sys/arch/hppa/include/mcontext.h +++ b/sys/arch/hppa/include/mcontext.h @@ -1,4 +1,4 @@ -/* $NetBSD: mcontext.h,v 1.8 2014/02/19 13:01:51 skrll Exp $ */ +/* $NetBSD: mcontext.h,v 1.8.22.1 2018/02/25 23:50:22 snj Exp $ */ #ifndef _HPPA_MCONTEXT_H_ #define _HPPA_MCONTEXT_H_ @@ -50,6 +50,7 @@ typedef struct { } mcontext_t; #define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_SP]) +#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[3]) #define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_PCOQH]) #define _UC_MACHINE_SET_PC(uc, pc) \ do { \ diff --git a/sys/arch/i386/include/mcontext.h b/sys/arch/i386/include/mcontext.h index 3056c9949d80..59a038891810 100644 --- a/sys/arch/i386/include/mcontext.h +++ b/sys/arch/i386/include/mcontext.h @@ -1,4 +1,4 @@ -/* $NetBSD: mcontext.h,v 1.12 2014/02/15 22:20:42 dsl Exp $ */ +/* $NetBSD: mcontext.h,v 1.12.22.1 2018/02/25 23:50:22 snj Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -116,6 +116,7 @@ typedef struct { #ifndef _UC_MACHINE_SP #define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_UESP]) #endif +#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_EBP]) #define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_EIP]) #define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_EAX]) diff --git a/sys/arch/ia64/include/mcontext.h b/sys/arch/ia64/include/mcontext.h index b9523d882e1a..ff218034cd5e 100644 --- a/sys/arch/ia64/include/mcontext.h +++ b/sys/arch/ia64/include/mcontext.h @@ -1,4 +1,4 @@ -/* $NetBSD: mcontext.h,v 1.5 2016/08/05 17:01:13 scole Exp $ */ +/* $NetBSD: mcontext.h,v 1.5.8.1 2018/02/25 23:50:23 snj Exp $ */ /*- * Copyright (c) 1999 The NetBSD Foundation, Inc. @@ -112,6 +112,7 @@ typedef struct __mcontext { } mcontext_t; #define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.mc_special.sp) +#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[79]) /* XXX or assembly "mov Rn = ip" or ...? */ #define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.mc_special.iip) diff --git a/sys/arch/m68k/include/mcontext.h b/sys/arch/m68k/include/mcontext.h index 65e3adaa7eaf..fd223c41acbd 100644 --- a/sys/arch/m68k/include/mcontext.h +++ b/sys/arch/m68k/include/mcontext.h @@ -1,4 +1,4 @@ -/* $NetBSD: mcontext.h,v 1.9 2011/11/22 15:25:28 joerg Exp $ */ +/* $NetBSD: mcontext.h,v 1.9.42.1 2018/02/25 23:50:23 snj Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -102,6 +102,7 @@ typedef struct { #define _UC_TLSBASE 0x00080000 #define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_A7]) +#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_A6]) #define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_PC]) #define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_D0]) diff --git a/sys/arch/mips/include/mcontext.h b/sys/arch/mips/include/mcontext.h index 96033d7cba24..255e3db6ce70 100644 --- a/sys/arch/mips/include/mcontext.h +++ b/sys/arch/mips/include/mcontext.h @@ -1,4 +1,4 @@ -/* $NetBSD: mcontext.h,v 1.21 2015/05/26 02:16:38 matt Exp $ */ +/* $NetBSD: mcontext.h,v 1.21.10.1 2018/02/25 23:50:23 snj Exp $ */ /*- * Copyright (c) 1999, 2002 The NetBSD Foundation, Inc. @@ -159,6 +159,7 @@ typedef struct { #define _UC_TLSBASE 0x00040000 #define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_SP]) +#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_S8]) #define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_EPC]) #define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_V0]) diff --git a/sys/arch/or1k/include/mcontext.h b/sys/arch/or1k/include/mcontext.h index 7cee7ee98af3..f3810b4ef9c1 100644 --- a/sys/arch/or1k/include/mcontext.h +++ b/sys/arch/or1k/include/mcontext.h @@ -1,4 +1,4 @@ -/* $NetBSD: mcontext.h,v 1.1 2014/09/03 19:34:26 matt Exp $ */ +/* $NetBSD: mcontext.h,v 1.1.12.1 2018/02/25 23:50:23 snj Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -88,6 +88,7 @@ typedef struct { #define _UC_TLSBASE 0x00080000 /* see */ #define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_SP]) +#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_R2]) #define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_PC]) #define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_RV]) diff --git a/sys/arch/powerpc/include/mcontext.h b/sys/arch/powerpc/include/mcontext.h index 5057afc06ce3..b94383936592 100644 --- a/sys/arch/powerpc/include/mcontext.h +++ b/sys/arch/powerpc/include/mcontext.h @@ -1,4 +1,4 @@ -/* $NetBSD: mcontext.h,v 1.17 2014/08/12 20:27:10 joerg Exp $ */ +/* $NetBSD: mcontext.h,v 1.17.12.1 2018/02/25 23:50:23 snj Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -133,6 +133,7 @@ typedef struct { #define _UC_TLSBASE 0x00080000 /* thread context valid in R2 */ #define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_R1]) +#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_R31]) #define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_PC]) #define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_R3]) diff --git a/sys/arch/riscv/include/mcontext.h b/sys/arch/riscv/include/mcontext.h index f72301fd47e8..f8ba5b2dbe86 100644 --- a/sys/arch/riscv/include/mcontext.h +++ b/sys/arch/riscv/include/mcontext.h @@ -1,4 +1,4 @@ -/* $NetBSD: mcontext.h,v 1.4 2015/04/01 21:55:33 matt Exp $ */ +/* $NetBSD: mcontext.h,v 1.4.10.1 2018/02/25 23:50:23 snj Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -118,6 +118,7 @@ typedef struct { #define _UC_TLSBASE 0x00080000 /* see */ #define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_SP]) +#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_S0]) #define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_PC]) #define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_RV]) diff --git a/sys/arch/sh3/include/mcontext.h b/sys/arch/sh3/include/mcontext.h index b0220b27dfbb..911b1753e8c7 100644 --- a/sys/arch/sh3/include/mcontext.h +++ b/sys/arch/sh3/include/mcontext.h @@ -1,4 +1,4 @@ -/* $NetBSD: mcontext.h,v 1.10 2012/09/12 02:00:54 manu Exp $ */ +/* $NetBSD: mcontext.h,v 1.10.32.1 2018/02/25 23:50:23 snj Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -82,6 +82,7 @@ typedef struct { } mcontext_t; #define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_SP]) +#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_R14]) #define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_PC]) #define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_R0]) diff --git a/sys/arch/sparc/include/mcontext.h b/sys/arch/sparc/include/mcontext.h index 25cb07eae0f9..5aa88ccd27da 100644 --- a/sys/arch/sparc/include/mcontext.h +++ b/sys/arch/sparc/include/mcontext.h @@ -1,4 +1,4 @@ -/* $NetBSD: mcontext.h,v 1.13 2012/09/12 02:00:54 manu Exp $ */ +/* $NetBSD: mcontext.h,v 1.13.32.1 2018/02/25 23:50:23 snj Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -30,11 +30,11 @@ */ #ifndef _SPARC_MCONTEXT_H_ -#define _SPARC_MCONTEXT_H_ +#define _SPARC_MCONTEXT_H_ -#define _UC_SETSTACK 0x00010000 -#define _UC_CLRSTACK 0x00020000 -#define _UC_TLSBASE 0x00080000 +#define _UC_SETSTACK 0x00010000 +#define _UC_CLRSTACK 0x00020000 +#define _UC_TLSBASE 0x00080000 /* * Layout of mcontext_t according the System V Application Binary Interface, @@ -144,13 +144,13 @@ typedef struct { } mcontext_t; #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_MACHINE32_PAD 43 /* compat_netbsd32 variant */ -#define _UC_MACHINE32_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_O6]) +#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) (((__greg_t *)_UC_MACHINE_SP(uc))[15]) #else -#define _UC_MACHINE_PAD 43 /* Padding appended to ucontext_t */ +#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) (((__greg_t *)_UC_MACHINE_SP(uc))[15]) #endif #define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_PC]) #define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_O0]) diff --git a/sys/arch/sparc64/include/mcontext.h b/sys/arch/sparc64/include/mcontext.h index 11fd49c76c18..81f4209d9fb6 100644 --- a/sys/arch/sparc64/include/mcontext.h +++ b/sys/arch/sparc64/include/mcontext.h @@ -1,11 +1,11 @@ -/* $NetBSD: mcontext.h,v 1.9 2012/09/12 02:00:54 manu Exp $ */ +/* $NetBSD: mcontext.h,v 1.9.32.1 2018/02/25 23:50:23 snj Exp $ */ #ifndef _SPARC64_MCONTEXT_H_ -#define _SPARC64_MCONTEXT_H_ +#define _SPARC64_MCONTEXT_H_ #include -#define _NGREG32 19 /* %psr, pc, npc, %g1-7, %o0-7 */ +#define _NGREG32 19 /* %psr, pc, npc, %g1-7, %o0-7 */ typedef int __greg32_t; typedef __greg32_t __gregset32_t[_NGREG32]; @@ -76,4 +76,8 @@ typedef struct { #define _UC_CLRSTACK 0x00020000 #define _UC_TLSBASE 0x00080000 +#define _UC_MACHINE32_PAD 43 /* compat_netbsd32 variant */ +#define _UC_MACHINE32_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_O6]) +#define _UC_MACHINE32_FP(uc) (((__greg32_t *)_UC_MACHINE32_SP(uc))[15]) + #endif /* _SPARC64_MCONTEXT_H_ */ diff --git a/sys/arch/vax/include/mcontext.h b/sys/arch/vax/include/mcontext.h index 5986841de7e7..ee30d60ab8f6 100644 --- a/sys/arch/vax/include/mcontext.h +++ b/sys/arch/vax/include/mcontext.h @@ -1,4 +1,4 @@ -/* $NetBSD: mcontext.h,v 1.8 2012/02/02 18:32:16 matt Exp $ */ +/* $NetBSD: mcontext.h,v 1.8.40.1 2018/02/25 23:50:23 snj Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -68,6 +68,7 @@ typedef struct { #define _UC_TLSBASE 0x00080000 #define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_SP]) +#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_FP]) #define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_PC]) #define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_R0]) diff --git a/tests/lib/libc/sys/Makefile b/tests/lib/libc/sys/Makefile index e3f21b898da1..f09197669e56 100644 --- a/tests/lib/libc/sys/Makefile +++ b/tests/lib/libc/sys/Makefile @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.49 2017/04/02 21:44:00 kamil Exp $ +# $NetBSD: Makefile,v 1.49.4.1 2018/02/25 23:50:23 snj Exp $ MKMAN= no @@ -96,6 +96,7 @@ CPPFLAGS.t_ptrace_wait4.c += -D_KERNTYPES CPPFLAGS.t_ptrace_wait6.c += -D_KERNTYPES CPPFLAGS.t_ptrace_waitid.c += -D_KERNTYPES CPPFLAGS.t_ptrace_waitpid.c += -D_KERNTYPES +CPPFLAGS.t_ucontext.c += -D_KERNTYPES FILES= truncate_test.root_owned FILESBUILD= yes diff --git a/tests/lib/libc/sys/t_ucontext.c b/tests/lib/libc/sys/t_ucontext.c index 27d6740ba50e..61ac4d9f6f13 100644 --- a/tests/lib/libc/sys/t_ucontext.c +++ b/tests/lib/libc/sys/t_ucontext.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_ucontext.c,v 1.1 2011/10/15 06:54:52 jruoho Exp $ */ +/* $NetBSD: t_ucontext.c,v 1.1.34.1 2018/02/25 23:50:23 snj Exp $ */ /* * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -29,7 +29,7 @@ #include __COPYRIGHT("@(#) Copyright (c) 2008\ The NetBSD Foundation, inc. All rights reserved."); -__RCSID("$NetBSD: t_ucontext.c,v 1.1 2011/10/15 06:54:52 jruoho Exp $"); +__RCSID("$NetBSD: t_ucontext.c,v 1.1.34.1 2018/02/25 23:50:23 snj Exp $"); #include #include @@ -68,9 +68,73 @@ ATF_TC_BODY(ucontext_basic, tc) ATF_REQUIRE_EQ(y, 21); } +ATF_TC(ucontext_sp); +ATF_TC_HEAD(ucontext_sp, tc) +{ + atf_tc_set_md_var(tc, "descr", "Retrive _UC_MACHINE_SP()"); +} + +ATF_TC_BODY(ucontext_sp, tc) +{ + ucontext_t u; + + getcontext(&u); + + printf("_UC_MACHINE_SP(u)=%" PRIxREGISTER "\n", _UC_MACHINE_SP(&u)); +} + +ATF_TC(ucontext_fp); +ATF_TC_HEAD(ucontext_fp, tc) +{ + atf_tc_set_md_var(tc, "descr", "Retrive _UC_MACHINE_FP()"); +} + +ATF_TC_BODY(ucontext_fp, tc) +{ + ucontext_t u; + + getcontext(&u); + + printf("_UC_MACHINE_FP(u)=%" PRIxREGISTER "\n", _UC_MACHINE_FP(&u)); +} + +ATF_TC(ucontext_pc); +ATF_TC_HEAD(ucontext_pc, tc) +{ + atf_tc_set_md_var(tc, "descr", "Retrive _UC_MACHINE_PC()"); +} + +ATF_TC_BODY(ucontext_pc, tc) +{ + ucontext_t u; + + getcontext(&u); + + printf("_UC_MACHINE_PC(u)=%" PRIxREGISTER "\n", _UC_MACHINE_PC(&u)); +} + +ATF_TC(ucontext_intrv); +ATF_TC_HEAD(ucontext_intrv, tc) +{ + atf_tc_set_md_var(tc, "descr", "Retrive _UC_MACHINE_INTRV()"); +} + +ATF_TC_BODY(ucontext_intrv, tc) +{ + ucontext_t u; + + getcontext(&u); + + printf("_UC_MACHINE_INTRV(u)=%" PRIxREGISTER "\n", _UC_MACHINE_INTRV(&u)); +} + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, ucontext_basic); + ATF_TP_ADD_TC(tp, ucontext_sp); + ATF_TP_ADD_TC(tp, ucontext_fp); + ATF_TP_ADD_TC(tp, ucontext_pc); + ATF_TP_ADD_TC(tp, ucontext_intrv); return atf_no_error(); }