Module Name: src
Committed By: thorpej
Date: Sat May 18 00:37:42 UTC 2024
Modified Files:
src/sys/arch/alpha/include: mcontext.h
src/sys/arch/amd64/include: mcontext.h
src/sys/arch/arm/include: mcontext.h
src/sys/arch/hppa/include: mcontext.h
src/sys/arch/i386/include: mcontext.h
src/sys/arch/m68k/include: mcontext.h
src/sys/arch/powerpc/include: mcontext.h
src/sys/arch/sh3/include: mcontext.h
src/sys/arch/sparc/include: mcontext.h
src/sys/arch/sparc64/include: mcontext.h
src/sys/arch/vax/include: mcontext.h
src/sys/sys: ucontext.h
Log Message:
Clean up the <sys/ucontext.h> <-> <machine/mcontext.h> interface up
a little:
- Define _UC_MD_BIT* constants for the available machine-dependent bits,
and use those constants to define the machine-dependent bits as well
as the machine-independent bits that have machine-dependent values.
- Explicitly generate an error if _UC_TLSBASE, _UC_SETSTACK, or
_UC_CLRSTACK are not defined by <machine/mcontext.h>.
To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/alpha/include/mcontext.h
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/amd64/include/mcontext.h
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/arm/include/mcontext.h
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/hppa/include/mcontext.h
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/i386/include/mcontext.h
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/m68k/include/mcontext.h
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/powerpc/include/mcontext.h
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/sh3/include/mcontext.h
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/sparc/include/mcontext.h
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/sparc64/include/mcontext.h
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/vax/include/mcontext.h
cvs rdiff -u -r1.19 -r1.20 src/sys/sys/ucontext.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/alpha/include/mcontext.h
diff -u src/sys/arch/alpha/include/mcontext.h:1.11 src/sys/arch/alpha/include/mcontext.h:1.12
--- src/sys/arch/alpha/include/mcontext.h:1.11 Mon May 24 21:00:12 2021
+++ src/sys/arch/alpha/include/mcontext.h Sat May 18 00:37:40 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: mcontext.h,v 1.11 2021/05/24 21:00:12 thorpej Exp $ */
+/* $NetBSD: mcontext.h,v 1.12 2024/05/18 00:37:40 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -93,9 +93,9 @@ typedef struct {
} mcontext_t;
/* Machine-dependent uc_flags */
-#define _UC_TLSBASE 0x20 /* valid process-unique value in _REG_UNIQUE */
-#define _UC_SETSTACK 0x00010000
-#define _UC_CLRSTACK 0x00020000
+#define _UC_TLSBASE _UC_MD_BIT5 /* valid value in _REG_UNIQUE */
+#define _UC_SETSTACK _UC_MD_BIT16
+#define _UC_CLRSTACK _UC_MD_BIT17
#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_SP])
#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_S6])
Index: src/sys/arch/amd64/include/mcontext.h
diff -u src/sys/arch/amd64/include/mcontext.h:1.20 src/sys/arch/amd64/include/mcontext.h:1.21
--- src/sys/arch/amd64/include/mcontext.h:1.20 Fri Dec 27 00:32:16 2019
+++ src/sys/arch/amd64/include/mcontext.h Sat May 18 00:37:40 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: mcontext.h,v 1.20 2019/12/27 00:32:16 kamil Exp $ */
+/* $NetBSD: mcontext.h,v 1.21 2024/05/18 00:37:40 thorpej Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -74,13 +74,13 @@ typedef struct {
#define _UC_MACHINE_SET_PC(uc, pc) _UC_MACHINE_PC(uc) = (pc)
-#define _UC_TLSBASE 0x00080000
+#define _UC_TLSBASE _UC_MD_BIT19
/*
* mcontext extensions to handle signal delivery.
*/
-#define _UC_SETSTACK 0x00010000
-#define _UC_CLRSTACK 0x00020000
+#define _UC_SETSTACK _UC_MD_BIT16
+#define _UC_CLRSTACK _UC_MD_BIT17
#define __UCONTEXT_SIZE 784
@@ -155,7 +155,7 @@ typedef struct {
uint32_t _mc_tlsbase;
} mcontext32_t;
-#define _UC_FXSAVE 0x20 /* FP state is in FXSAVE format in XMM space */
+#define _UC_FXSAVE _UC_MD_BIT5 /* FP state is in FXSAVE format in XMM space */
#define _UC_MACHINE32_PAD 4
#define __UCONTEXT32_SIZE 776
Index: src/sys/arch/arm/include/mcontext.h
diff -u src/sys/arch/arm/include/mcontext.h:1.23 src/sys/arch/arm/include/mcontext.h:1.24
--- src/sys/arch/arm/include/mcontext.h:1.23 Wed Oct 6 05:33:15 2021
+++ src/sys/arch/arm/include/mcontext.h Sat May 18 00:37:40 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: mcontext.h,v 1.23 2021/10/06 05:33:15 skrll Exp $ */
+/* $NetBSD: mcontext.h,v 1.24 2024/05/18 00:37:40 thorpej Exp $ */
/*-
* Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -257,14 +257,14 @@ __END_DECLS
#endif /* _RTLD_SOURCE || _LIBC_SOURCE || __LIBPTHREAD_SOURCE__ */
/* Machine-dependent uc_flags */
-#define _UC_TLSBASE 0x00080000 /* see <sys/ucontext.h> */
+#define _UC_TLSBASE _UC_MD_BIT19 /* see <sys/ucontext.h> */
/* Machine-dependent uc_flags for arm */
-#define _UC_ARM_VFP 0x00010000 /* FPU field is VFP */
+#define _UC_ARM_VFP _UC_MD_BIT16 /* FPU field is VFP */
/* used by signal delivery to indicate status of signal stack */
-#define _UC_SETSTACK 0x00020000
-#define _UC_CLRSTACK 0x00040000
+#define _UC_SETSTACK _UC_MD_BIT17
+#define _UC_CLRSTACK _UC_MD_BIT18
#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_SP])
#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_FP])
Index: src/sys/arch/hppa/include/mcontext.h
diff -u src/sys/arch/hppa/include/mcontext.h:1.12 src/sys/arch/hppa/include/mcontext.h:1.13
--- src/sys/arch/hppa/include/mcontext.h:1.12 Sun Jun 26 14:37:13 2022
+++ src/sys/arch/hppa/include/mcontext.h Sat May 18 00:37:40 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: mcontext.h,v 1.12 2022/06/26 14:37:13 skrll Exp $ */
+/* $NetBSD: mcontext.h,v 1.13 2024/05/18 00:37:40 thorpej Exp $ */
#ifndef _HPPA_MCONTEXT_H_
#define _HPPA_MCONTEXT_H_
@@ -111,8 +111,8 @@ __END_DECLS
#endif /* !__ASSEMBLER__ */
-#define _UC_SETSTACK 0x00010000
-#define _UC_CLRSTACK 0x00020000
-#define _UC_TLSBASE 0x00040000
+#define _UC_SETSTACK _UC_MD_BIT16
+#define _UC_CLRSTACK _UC_MD_BIT17
+#define _UC_TLSBASE _UC_MD_BIT18
#endif /* _HPPA_MCONTEXT_H_ */
Index: src/sys/arch/i386/include/mcontext.h
diff -u src/sys/arch/i386/include/mcontext.h:1.15 src/sys/arch/i386/include/mcontext.h:1.16
--- src/sys/arch/i386/include/mcontext.h:1.15 Fri Dec 27 00:32:17 2019
+++ src/sys/arch/i386/include/mcontext.h Sat May 18 00:37:40 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: mcontext.h,v 1.15 2019/12/27 00:32:17 kamil Exp $ */
+/* $NetBSD: mcontext.h,v 1.16 2024/05/18 00:37:40 thorpej Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -36,10 +36,10 @@
/*
* mcontext extensions to handle signal delivery.
*/
-#define _UC_SETSTACK 0x00010000
-#define _UC_CLRSTACK 0x00020000
-#define _UC_VM 0x00040000
-#define _UC_TLSBASE 0x00080000
+#define _UC_SETSTACK _UC_MD_BIT16
+#define _UC_CLRSTACK _UC_MD_BIT17
+#define _UC_VM _UC_MD_BIT18
+#define _UC_TLSBASE _UC_MD_BIT19
/*
* Layout of mcontext_t according to the System V Application Binary Interface,
@@ -96,7 +96,7 @@ typedef struct {
__greg_t _mc_tlsbase;
} mcontext_t;
-#define _UC_FXSAVE 0x20 /* FP state is in FXSAVE format in XMM space */
+#define _UC_FXSAVE _UC_MD_BIT5 /* FP state is in FXSAVE format in XMM space */
#define _UC_MACHINE_PAD 4 /* Padding appended to ucontext_t */
Index: src/sys/arch/m68k/include/mcontext.h
diff -u src/sys/arch/m68k/include/mcontext.h:1.12 src/sys/arch/m68k/include/mcontext.h:1.13
--- src/sys/arch/m68k/include/mcontext.h:1.12 Sun Oct 4 10:34:18 2020
+++ src/sys/arch/m68k/include/mcontext.h Sat May 18 00:37:41 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: mcontext.h,v 1.12 2020/10/04 10:34:18 rin Exp $ */
+/* $NetBSD: mcontext.h,v 1.13 2024/05/18 00:37:41 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -39,8 +39,8 @@
/*
* mcontext extensions to handle signal delivery.
*/
-#define _UC_SETSTACK 0x00010000
-#define _UC_CLRSTACK 0x00020000
+#define _UC_SETSTACK _UC_MD_BIT16
+#define _UC_CLRSTACK _UC_MD_BIT17
/*
* General register state
@@ -98,8 +98,8 @@ typedef struct {
/* Note: no additional padding is to be performed in ucontext_t. */
/* Machine-specific uc_flags value */
-#define _UC_M68K_UC_USER 0x40000000
-#define _UC_TLSBASE 0x00080000
+#define _UC_M68K_UC_USER _UC_MD_BIT30
+#define _UC_TLSBASE _UC_MD_BIT19
#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_A7])
#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_A6])
Index: src/sys/arch/powerpc/include/mcontext.h
diff -u src/sys/arch/powerpc/include/mcontext.h:1.22 src/sys/arch/powerpc/include/mcontext.h:1.23
--- src/sys/arch/powerpc/include/mcontext.h:1.22 Sun Oct 4 10:34:18 2020
+++ src/sys/arch/powerpc/include/mcontext.h Sat May 18 00:37:41 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: mcontext.h,v 1.22 2020/10/04 10:34:18 rin Exp $ */
+/* $NetBSD: mcontext.h,v 1.23 2024/05/18 00:37:41 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -128,11 +128,11 @@ typedef struct {
#endif
/* Machine-dependent uc_flags */
-#define _UC_POWERPC_VEC 0x00010000 /* Vector Register File valid */
-#define _UC_POWERPC_SPE 0x00020000 /* Vector Register File valid */
-#define _UC_TLSBASE 0x00080000 /* thread context valid in R2 */
-#define _UC_SETSTACK 0x00100000
-#define _UC_CLRSTACK 0x00200000
+#define _UC_POWERPC_VEC _UC_MD_BIT16 /* Vector Register File valid */
+#define _UC_POWERPC_SPE _UC_MD_BIT17 /* Vector Register File valid */
+#define _UC_TLSBASE _UC_MD_BIT19 /* thread context valid in R2 */
+#define _UC_SETSTACK _UC_MD_BIT20
+#define _UC_CLRSTACK _UC_MD_BIT21
#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_R1])
#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_R31])
Index: src/sys/arch/sh3/include/mcontext.h
diff -u src/sys/arch/sh3/include/mcontext.h:1.12 src/sys/arch/sh3/include/mcontext.h:1.13
--- src/sys/arch/sh3/include/mcontext.h:1.12 Fri Dec 27 00:32:17 2019
+++ src/sys/arch/sh3/include/mcontext.h Sat May 18 00:37:41 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: mcontext.h,v 1.12 2019/12/27 00:32:17 kamil Exp $ */
+/* $NetBSD: mcontext.h,v 1.13 2024/05/18 00:37:41 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -91,9 +91,9 @@ typedef struct {
/*
* Machine dependent uc_flags
*/
-#define _UC_SETSTACK 0x10000
-#define _UC_CLRSTACK 0x20000
-#define _UC_TLSBASE 0x80000
+#define _UC_SETSTACK _UC_MD_BIT16
+#define _UC_CLRSTACK _UC_MD_BIT17
+#define _UC_TLSBASE _UC_MD_BIT19
#if defined(_RTLD_SOURCE) || defined(_LIBC_SOURCE) || \
defined(__LIBPTHREAD_SOURCE__)
Index: src/sys/arch/sparc/include/mcontext.h
diff -u src/sys/arch/sparc/include/mcontext.h:1.18 src/sys/arch/sparc/include/mcontext.h:1.19
--- src/sys/arch/sparc/include/mcontext.h:1.18 Fri Dec 27 00:32:17 2019
+++ src/sys/arch/sparc/include/mcontext.h Sat May 18 00:37:41 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: mcontext.h,v 1.18 2019/12/27 00:32:17 kamil Exp $ */
+/* $NetBSD: mcontext.h,v 1.19 2024/05/18 00:37:41 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -32,9 +32,9 @@
#ifndef _SPARC_MCONTEXT_H_
#define _SPARC_MCONTEXT_H_
-#define _UC_SETSTACK 0x00010000
-#define _UC_CLRSTACK 0x00020000
-#define _UC_TLSBASE 0x00080000
+#define _UC_SETSTACK _UC_MD_BIT16
+#define _UC_CLRSTACK _UC_MD_BIT17
+#define _UC_TLSBASE _UC_MD_BIT19
/*
* Layout of mcontext_t according the System V Application Binary Interface,
Index: src/sys/arch/sparc64/include/mcontext.h
diff -u src/sys/arch/sparc64/include/mcontext.h:1.10 src/sys/arch/sparc64/include/mcontext.h:1.11
--- src/sys/arch/sparc64/include/mcontext.h:1.10 Mon Feb 19 08:31:13 2018
+++ src/sys/arch/sparc64/include/mcontext.h Sat May 18 00:37:41 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: mcontext.h,v 1.10 2018/02/19 08:31:13 mrg Exp $ */
+/* $NetBSD: mcontext.h,v 1.11 2024/05/18 00:37:41 thorpej Exp $ */
#ifndef _SPARC64_MCONTEXT_H_
#define _SPARC64_MCONTEXT_H_
@@ -72,9 +72,9 @@ typedef struct {
__xrs32_t __xrs; /* may indicate extra reg state */
} mcontext32_t;
-#define _UC_SETSTACK 0x00010000
-#define _UC_CLRSTACK 0x00020000
-#define _UC_TLSBASE 0x00080000
+#define _UC_SETSTACK _UC_MD_BIT16
+#define _UC_CLRSTACK _UC_MD_BIT17
+#define _UC_TLSBASE _UC_MD_BIT19
#define _UC_MACHINE32_PAD 43 /* compat_netbsd32 variant */
#define _UC_MACHINE32_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_O6])
Index: src/sys/arch/vax/include/mcontext.h
diff -u src/sys/arch/vax/include/mcontext.h:1.11 src/sys/arch/vax/include/mcontext.h:1.12
--- src/sys/arch/vax/include/mcontext.h:1.11 Fri May 17 21:37:07 2024
+++ src/sys/arch/vax/include/mcontext.h Sat May 18 00:37:41 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: mcontext.h,v 1.11 2024/05/17 21:37:07 thorpej Exp $ */
+/* $NetBSD: mcontext.h,v 1.12 2024/05/18 00:37:41 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -65,9 +65,9 @@ typedef struct {
} mcontext_t;
/* Machine-dependent uc_flags */
-#define _UC_SETSTACK 0x00010000
-#define _UC_CLRSTACK 0x00020000
-#define _UC_TLSBASE 0x00080000
+#define _UC_SETSTACK _UC_MD_BIT16
+#define _UC_CLRSTACK _UC_MD_BIT17
+#define _UC_TLSBASE _UC_MD_BIT19
#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_SP])
#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_FP])
Index: src/sys/sys/ucontext.h
diff -u src/sys/sys/ucontext.h:1.19 src/sys/sys/ucontext.h:1.20
--- src/sys/sys/ucontext.h:1.19 Tue Feb 27 23:09:02 2018
+++ src/sys/sys/ucontext.h Sat May 18 00:37:41 2024
@@ -1,7 +1,7 @@
-/* $NetBSD: ucontext.h,v 1.19 2018/02/27 23:09:02 uwe Exp $ */
+/* $NetBSD: ucontext.h,v 1.20 2024/05/18 00:37:41 thorpej Exp $ */
/*-
- * Copyright (c) 1999, 2003 The NetBSD Foundation, Inc.
+ * Copyright (c) 1999, 2003, 2024 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -57,50 +57,42 @@ struct __ucontext {
#define _UC_STACK 0x02 /* valid uc_stack */
#define _UC_CPU 0x04 /* valid GPR context in uc_mcontext */
#define _UC_FPU 0x08 /* valid FPU context in uc_mcontext */
-#define _UC_MD 0x400f0020 /* MD bits. see below */
+#define _UC_MD_BIT5 0x00000020 /* MD bits. see below */
+#define _UC_MD_BIT16 0x00010000
+#define _UC_MD_BIT17 0x00020000
+#define _UC_MD_BIT18 0x00040000
+#define _UC_MD_BIT19 0x00080000
+#define _UC_MD_BIT20 0x00100000
+#define _UC_MD_BIT21 0x00200000
+#define _UC_MD_BIT30 0x40000000
/*
- * if your port needs more MD bits, please try to choose bits from _UC_MD
- * first, rather than picking random unused bits.
+ * if your port needs more MD bits, please choose bits from _UC_MD_BIT*
+ * rather than picking random unused bits.
*
- * _UC_MD details
+ * For historical reasons, some common flags have machine-dependent
+ * definitions. All platforms must define and handle those flags,
+ * which are:
*
* _UC_TLSBASE Context contains valid pthread private pointer
- * All ports must define this MD flag
- * 0x00040000 hppa, mips
- * 0x00000020 alpha
- * 0x00080000 all other ports
*
* _UC_SETSTACK Context uses signal stack
- * 0x00020000 arm
- * [undefined] alpha, powerpc and vax
- * 0x00010000 other ports
*
* _UC_CLRSTACK Context does not use signal stack
- * 0x00040000 arm
- * [undefined] alpha, powerpc and vax
- * 0x00020000 other ports
- *
- * _UC_POWERPC_VEC Context contains valid AltiVec context
- * 0x00010000 powerpc only
- *
- * _UC_POWERPC_SPE Context contains valid SPE context
- * 0x00020000 powerpc only
- *
- * _UC_M68K_UC_USER Used by m68k machdep code, but undocumented
- * 0x40000000 m68k only
- *
- * _UC_ARM_VFP Unused
- * 0x00010000 arm only
- *
- * _UC_VM Context contains valid virtual 8086 context
- * 0x00040000 i386, amd64 only
- *
- * _UC_FXSAVE Context contains FPU context in that
- * is in FXSAVE format in XMM space
- * 0x00000020 i386, amd64 only
*/
+#ifndef _UC_TLSBASE
+#error _UC_TLSBASE not defined.
+#endif
+
+#ifndef _UC_SETSTACK
+#error _UC_SETSTACK not defined.
+#endif
+
+#ifndef _UC_CLRSTACK
+#error _UC_CLRSTACK not defined.
+#endif
+
#ifdef _KERNEL
struct lwp;