From e21f96a811d9776f976751b01ac7975eeffcdeb2 Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Thu, 22 Aug 2019 21:43:21 +0000 Subject: [PATCH] mips: hide regnum definitions behind _KERNEL/_WANT_MIPS_REGNUM machine/regnum.h ends up being included by sys/procfs.h and sys/ptrace.h via machine/reg.h. Many of the regnum definitions are too short and too generic to be exposing to any userland application including one of these two headers. Moreover, these actively cause build failures in googletest (template expanding to template ). Hide the definitions behind _KERNEL or _WANT_MIPS_REGNUM, and patch all of the userland consumers to define as needed. Discussed with: imp, jhb Reviewed by: imp, jhb MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D21330 --- lib/libc/mips/gen/_setjmp.S | 1 - lib/libc/mips/gen/makecontext.c | 1 + lib/libc/mips/gen/setjmp.S | 1 - lib/libc/mips/gen/sigsetjmp.S | 1 - lib/libproc/proc_regs.c | 1 + lib/libthread_db/arch/mips/libpthread_md.c | 1 + sys/mips/include/regnum.h | 11 ++++++----- tests/sys/kern/ptrace_test.c | 1 + 8 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/libc/mips/gen/_setjmp.S b/lib/libc/mips/gen/_setjmp.S index 6944d06fbb2c..10c4cda5e0c1 100644 --- a/lib/libc/mips/gen/_setjmp.S +++ b/lib/libc/mips/gen/_setjmp.S @@ -34,7 +34,6 @@ #include __FBSDID("$FreeBSD$"); -#include #include "SYS.h" diff --git a/lib/libc/mips/gen/makecontext.c b/lib/libc/mips/gen/makecontext.c index 1f8886f869a5..7d3e647b4d09 100644 --- a/lib/libc/mips/gen/makecontext.c +++ b/lib/libc/mips/gen/makecontext.c @@ -39,6 +39,7 @@ __RCSID("$NetBSD: makecontext.c,v 1.5 2009/12/14 01:07:42 matt Exp $"); #include #include +#define _WANT_MIPS_REGNUM #include #include diff --git a/lib/libc/mips/gen/setjmp.S b/lib/libc/mips/gen/setjmp.S index 4eb12f53b703..3ef6878bb608 100644 --- a/lib/libc/mips/gen/setjmp.S +++ b/lib/libc/mips/gen/setjmp.S @@ -34,7 +34,6 @@ #include __FBSDID("$FreeBSD$"); -#include #if defined(LIBC_SCCS) && !defined(lint) ASMSTR("from: @(#)setjmp.s 8.1 (Berkeley) 6/4/93") diff --git a/lib/libc/mips/gen/sigsetjmp.S b/lib/libc/mips/gen/sigsetjmp.S index 41c47f284433..a36b2803a10b 100644 --- a/lib/libc/mips/gen/sigsetjmp.S +++ b/lib/libc/mips/gen/sigsetjmp.S @@ -34,7 +34,6 @@ #include __FBSDID("$FreeBSD$"); -#include #if defined(LIBC_SCCS) && !defined(lint) ASMSTR("from: @(#)setjmp.s 8.1 (Berkeley) 6/4/93") ASMSTR("$NetBSD: sigsetjmp.S,v 1.8 2005/09/17 11:49:39 tsutsui Exp $") diff --git a/lib/libproc/proc_regs.c b/lib/libproc/proc_regs.c index 83988c2bac35..da2cba18bbbd 100644 --- a/lib/libproc/proc_regs.c +++ b/lib/libproc/proc_regs.c @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); #include +#define _WANT_MIPS_REGNUM #include #include diff --git a/lib/libthread_db/arch/mips/libpthread_md.c b/lib/libthread_db/arch/mips/libpthread_md.c index cef786a32887..1ded66d1c3fe 100644 --- a/lib/libthread_db/arch/mips/libpthread_md.c +++ b/lib/libthread_db/arch/mips/libpthread_md.c @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); #include +#define _WANT_MIPS_REGNUM #include #include #include diff --git a/sys/mips/include/regnum.h b/sys/mips/include/regnum.h index dd61d70d3eb2..20ce3c0094c5 100644 --- a/sys/mips/include/regnum.h +++ b/sys/mips/include/regnum.h @@ -44,11 +44,15 @@ #ifndef _MACHINE_REGNUM_H_ #define _MACHINE_REGNUM_H_ +#define NUMSAVEREGS 40 +#define NUMFPREGS 34 + /* * Location of the saved registers relative to ZERO. * This must match struct trapframe defined in frame.h exactly. * This must also match regdef.h. */ +#if defined(_KERNEL) || defined(_WANT_MIPS_REGNUM) #define ZERO 0 #define AST 1 #define V0 2 @@ -105,7 +109,6 @@ */ #define IC 38 #define DUMMY 39 /* for 8 byte alignment */ -#define NUMSAVEREGS 40 /* * Pseudo registers so we save a complete set of registers regardless of @@ -164,10 +167,6 @@ #define FSR (FPBASE+32) #define FIR (FPBASE+33) -#define NUMFPREGS 34 - -#define NREGS (NUMSAVEREGS + NUMFPREGS) - /* * Index of FP registers in 'struct frame', relative to the base * of the FP registers in frame (i.e., *not* including the general @@ -208,4 +207,6 @@ #define FSR_NUM (32) #define FIR_NUM (33) +#endif /* _KERNEL || _WANT_MIPS_REGNUM */ + #endif /* !_MACHINE_REGNUM_H_ */ diff --git a/tests/sys/kern/ptrace_test.c b/tests/sys/kern/ptrace_test.c index 977dcb5aaaa3..6ac3ed6243bb 100644 --- a/tests/sys/kern/ptrace_test.c +++ b/tests/sys/kern/ptrace_test.c @@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#define _WANT_MIPS_REGNUM #include #include #include