fix "uname -p" on mips n32. this has been returning "mipsn64eb" on my edgerouter4 with the 32 bit uname binary. introduce o32, n32, and n64 versions of MACHINE_ARCH, and use them appropriately in PROC_MACHINE_ARCH32(). now o32, n32 and n64 "uname -p" all return different values. Index: arch/mips/include/mips_param.h =================================================================== RCS file: /cvsroot/src/sys/arch/mips/include/mips_param.h,v retrieving revision 1.49 diff -p -u -r1.49 mips_param.h --- arch/mips/include/mips_param.h 8 May 2021 13:09:58 -0000 1.49 +++ arch/mips/include/mips_param.h 23 May 2021 22:59:14 -0000 @@ -38,19 +38,28 @@ # error neither __MIPSEL__ nor __MIPSEB__ are defined. #endif +#define ___MACHINE32_OARCH mips##_MACHINE_SUFFIX +#define __MACHINE32_OARCH "mips" MACHINE_SUFFIX +#define ___MACHINE32_NARCH mips64##_MACHINE_SUFFIX +#define __MACHINE32_NARCH "mips64" MACHINE_SUFFIX +#define ___MACHINE64_NARCH mipsn64##_MACHINE_SUFFIX +#define __MACHINE64_NARCH "mipsn64" MACHINE_SUFFIX + #if defined(__mips_n32) || defined(__mips_n64) # if defined(__mips_n32) -# define _MACHINE_ARCH mips64##_MACHINE_SUFFIX -# define MACHINE_ARCH "mips64" MACHINE_SUFFIX +# define _MACHINE_ARCH ___MACHINE32_NARCH +# define MACHINE_ARCH __MACHINE32_NARCH # else /* __mips_n64 */ -# define _MACHINE_ARCH mipsn64##_MACHINE_SUFFIX -# define MACHINE_ARCH "mipsn64" MACHINE_SUFFIX +# define _MACHINE_ARCH ___MACHINE64_NARCH +# define MACHINE_ARCH __MACHINE64_NARCH +# define _MACHINE32_NARCH ___MACHINE32_NARCH +# define MACHINE32_NARCH __MACHINE32_NARCH # endif -# define _MACHINE32_ARCH mips##_MACHINE_SUFFIX -# define MACHINE32_ARCH "mips" MACHINE_SUFFIX +# define _MACHINE32_OARCH ___MACHINE32_OARCH +# define MACHINE32_OARCH __MACHINE32_OARCH #else /* o32 */ -# define _MACHINE_ARCH mips##_MACHINE_SUFFIX -# define MACHINE_ARCH "mips" MACHINE_SUFFIX +# define _MACHINE_ARCH ___MACHINE32_OARCH +# define MACHINE_ARCH __MACHINE32_OARCH #endif /* Index: arch/mips/include/netbsd32_machdep.h =================================================================== RCS file: /cvsroot/src/sys/arch/mips/include/netbsd32_machdep.h,v retrieving revision 1.6 diff -p -u -r1.6 netbsd32_machdep.h --- arch/mips/include/netbsd32_machdep.h 26 Jul 2020 08:08:41 -0000 1.6 +++ arch/mips/include/netbsd32_machdep.h 23 May 2021 22:59:14 -0000 @@ -44,10 +44,17 @@ typedef struct { NETBSD32_POINTER_TYPE i typedef netbsd32_pointer_t netbsd32_sigcontextp_t; -/* Support varying ABI names for netbsd32 */ -extern const char machine_arch32[]; +/* Support varying ABI names for netbsd32/ABI */ +extern const char machine_archo32[]; +#if defined(__mips_n64) +extern const char machine_archn32[]; #define PROC_MACHINE_ARCH32(P) ((P)->p_md.md_abi == _MIPS_BSD_API_O32) ? \ - __UNCONST(machine_arch32) : machine_arch + __UNCONST(machine_archo32) : ((P)->p_md.md_abi == _MIPS_BSD_API_N32) ? \ + __UNCONST(machine_archn32) : machine_arch +#else +#define PROC_MACHINE_ARCH32(P) ((P)->p_md.md_abi == _MIPS_BSD_API_O32) ? \ + __UNCONST(machine_archo32) : machine_arch +#endif /* * The sigcode is ABI neutral. Index: arch/mips/mips/cpu_exec.c =================================================================== RCS file: /cvsroot/src/sys/arch/mips/mips/cpu_exec.c,v retrieving revision 1.67 diff -p -u -r1.67 cpu_exec.c --- arch/mips/mips/cpu_exec.c 19 Aug 2018 10:33:49 -0000 1.67 +++ arch/mips/mips/cpu_exec.c 23 May 2021 22:59:14 -0000 @@ -201,7 +201,7 @@ coredump_elf32_setup(struct lwp *l, void eh->e_flags |= EF_MIPS_ABI2; break; case _MIPS_BSD_API_O32: - eh->e_flags |=EF_MIPS_ABI_O32; + eh->e_flags |= EF_MIPS_ABI_O32; break; } } Index: arch/mips/mips/netbsd32_machdep.c =================================================================== RCS file: /cvsroot/src/sys/arch/mips/mips/netbsd32_machdep.c,v retrieving revision 1.20 diff -p -u -r1.20 netbsd32_machdep.c --- arch/mips/mips/netbsd32_machdep.c 12 Dec 2019 02:15:42 -0000 1.20 +++ arch/mips/mips/netbsd32_machdep.c 23 May 2021 22:59:14 -0000 @@ -67,7 +67,10 @@ __KERNEL_RCSID(0, "$NetBSD: netbsd32_mac #include const char machine32[] = MACHINE; -const char machine_arch32[] = MACHINE32_ARCH; +const char machine_archo32[] = MACHINE32_OARCH; +#ifdef MACHINE32_NARCH +const char machine_archn32[] = MACHINE32_NARCH; +#endif #if 0 cpu_coredump32 @@ -321,7 +324,7 @@ static const char * netbsd32_machine32(void) { - return machine32; + return PROC_MACHINE_ARCH32(curproc); } void