Module Name:    src
Committed By:   christos
Date:           Sun Nov  3 22:24:23 UTC 2024

Modified Files:
        src/distrib/sets/lists/comp: ad.arm ad.m68k ad.mips ad.powerpc ad.riscv
            ad.sh3 md.alpha md.amd64 md.hppa md.i386 md.ia64 md.or1k md.sparc
            md.vax
        src/include: lwp.h
        src/libexec/ld.elf_so/arch/i386: mdreloc.c
        src/sys/arch/alpha/include: Makefile mcontext.h
        src/sys/arch/amd64/include: Makefile mcontext.h
        src/sys/arch/arm/include: Makefile mcontext.h
        src/sys/arch/hppa/include: Makefile mcontext.h
        src/sys/arch/i386/include: Makefile mcontext.h
        src/sys/arch/ia64/include: Makefile mcontext.h
        src/sys/arch/m68k/include: Makefile mcontext.h
        src/sys/arch/mips/include: Makefile mcontext.h
        src/sys/arch/or1k/include: Makefile mcontext.h
        src/sys/arch/powerpc/include: Makefile mcontext.h
        src/sys/arch/riscv/include: Makefile mcontext.h
        src/sys/arch/sh3/include: Makefile mcontext.h
        src/sys/arch/sparc/include: Makefile mcontext.h
        src/sys/arch/vax/include: Makefile mcontext.h
Added Files:
        src/sys/arch/alpha/include: lwp.h
        src/sys/arch/amd64/include: lwp.h
        src/sys/arch/arm/include: lwp.h
        src/sys/arch/hppa/include: lwp.h
        src/sys/arch/i386/include: lwp.h
        src/sys/arch/ia64/include: lwp.h
        src/sys/arch/m68k/include: lwp.h
        src/sys/arch/mips/include: lwp.h
        src/sys/arch/or1k/include: lwp.h
        src/sys/arch/powerpc/include: lwp.h
        src/sys/arch/riscv/include: lwp.h
        src/sys/arch/sh3/include: lwp.h
        src/sys/arch/sparc/include: lwp.h
        src/sys/arch/vax/include: lwp.h

Log Message:
Split __lwp_getprivate_fast and __lwp_*tcb from mcontext.h into a separate
lwp.h file.


To generate a diff of this commit:
cvs rdiff -u -r1.111 -r1.112 src/distrib/sets/lists/comp/ad.arm
cvs rdiff -u -r1.73 -r1.74 src/distrib/sets/lists/comp/ad.m68k
cvs rdiff -u -r1.94 -r1.95 src/distrib/sets/lists/comp/ad.mips
cvs rdiff -u -r1.108 -r1.109 src/distrib/sets/lists/comp/ad.powerpc
cvs rdiff -u -r1.23 -r1.24 src/distrib/sets/lists/comp/ad.riscv
cvs rdiff -u -r1.49 -r1.50 src/distrib/sets/lists/comp/ad.sh3
cvs rdiff -u -r1.82 -r1.83 src/distrib/sets/lists/comp/md.alpha
cvs rdiff -u -r1.303 -r1.304 src/distrib/sets/lists/comp/md.amd64
cvs rdiff -u -r1.18 -r1.19 src/distrib/sets/lists/comp/md.hppa
cvs rdiff -u -r1.210 -r1.211 src/distrib/sets/lists/comp/md.i386
cvs rdiff -u -r1.13 -r1.14 src/distrib/sets/lists/comp/md.ia64
cvs rdiff -u -r1.14 -r1.15 src/distrib/sets/lists/comp/md.or1k
cvs rdiff -u -r1.105 -r1.106 src/distrib/sets/lists/comp/md.sparc
cvs rdiff -u -r1.56 -r1.57 src/distrib/sets/lists/comp/md.vax
cvs rdiff -u -r1.13 -r1.14 src/include/lwp.h
cvs rdiff -u -r1.44 -r1.45 src/libexec/ld.elf_so/arch/i386/mdreloc.c
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/alpha/include/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/arch/alpha/include/lwp.h
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/alpha/include/mcontext.h
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/amd64/include/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/arch/amd64/include/lwp.h
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/amd64/include/mcontext.h
cvs rdiff -u -r1.52 -r1.53 src/sys/arch/arm/include/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/include/lwp.h
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/arm/include/mcontext.h
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/hppa/include/Makefile \
    src/sys/arch/hppa/include/mcontext.h
cvs rdiff -u -r0 -r1.1 src/sys/arch/hppa/include/lwp.h
cvs rdiff -u -r1.50 -r1.51 src/sys/arch/i386/include/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/arch/i386/include/lwp.h
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/i386/include/mcontext.h
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/ia64/include/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/arch/ia64/include/lwp.h
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/ia64/include/mcontext.h
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/m68k/include/Makefile
cvs rdiff -u -r0 -r1.2 src/sys/arch/m68k/include/lwp.h
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/m68k/include/mcontext.h
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/mips/include/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/arch/mips/include/lwp.h
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/mips/include/mcontext.h
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/or1k/include/Makefile \
    src/sys/arch/or1k/include/mcontext.h
cvs rdiff -u -r0 -r1.1 src/sys/arch/or1k/include/lwp.h
cvs rdiff -u -r1.42 -r1.43 src/sys/arch/powerpc/include/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/arch/powerpc/include/lwp.h
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/powerpc/include/mcontext.h
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/riscv/include/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/arch/riscv/include/lwp.h
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/riscv/include/mcontext.h
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/sh3/include/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/arch/sh3/include/lwp.h
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/sh3/include/mcontext.h
cvs rdiff -u -r1.36 -r1.37 src/sys/arch/sparc/include/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/arch/sparc/include/lwp.h
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/sparc/include/mcontext.h
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/vax/include/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/arch/vax/include/lwp.h
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/vax/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/distrib/sets/lists/comp/ad.arm
diff -u src/distrib/sets/lists/comp/ad.arm:1.111 src/distrib/sets/lists/comp/ad.arm:1.112
--- src/distrib/sets/lists/comp/ad.arm:1.111	Thu Jul 11 16:41:06 2024
+++ src/distrib/sets/lists/comp/ad.arm	Sun Nov  3 17:24:20 2024
@@ -1,4 +1,4 @@
-# $NetBSD: ad.arm,v 1.111 2024/07/11 20:41:06 riastradh Exp $
+# $NetBSD: ad.arm,v 1.112 2024/11/03 22:24:20 christos Exp $
 #
 ./usr/bin/elf2aout				comp-sysutil-bin
 ./usr/include/acorn26				comp-obsolete		obsolete
@@ -162,6 +162,7 @@
 ./usr/include/arm/kcore.h			comp-c-include
 ./usr/include/arm/limits.h			comp-c-include
 ./usr/include/arm/lock.h			comp-c-include
+./usr/include/arm/lwp.h				comp-c-include
 ./usr/include/arm/math.h			comp-c-include
 ./usr/include/arm/mcontext.h			comp-c-include
 ./usr/include/arm/mutex.h			comp-c-include

Index: src/distrib/sets/lists/comp/ad.m68k
diff -u src/distrib/sets/lists/comp/ad.m68k:1.73 src/distrib/sets/lists/comp/ad.m68k:1.74
--- src/distrib/sets/lists/comp/ad.m68k:1.73	Thu Jul 11 16:41:06 2024
+++ src/distrib/sets/lists/comp/ad.m68k	Sun Nov  3 17:24:20 2024
@@ -1,4 +1,4 @@
-# $NetBSD: ad.m68k,v 1.73 2024/07/11 20:41:06 riastradh Exp $
+# $NetBSD: ad.m68k,v 1.74 2024/11/03 22:24:20 christos Exp $
 #
 ./usr/bin/elf2aout				comp-sysutil-bin
 ./usr/include/gcc-4.5/math-68881.h		comp-obsolete		obsolete
@@ -55,6 +55,7 @@
 ./usr/include/m68k/kcore.h			comp-c-include
 ./usr/include/m68k/limits.h			comp-c-include
 ./usr/include/m68k/lock.h			comp-c-include
+./usr/include/m68k/lwp.h			comp-c-include
 ./usr/include/m68k/m68k.h			comp-c-include
 ./usr/include/m68k/math.h			comp-c-include
 ./usr/include/m68k/mcontext.h			comp-c-include

Index: src/distrib/sets/lists/comp/ad.mips
diff -u src/distrib/sets/lists/comp/ad.mips:1.94 src/distrib/sets/lists/comp/ad.mips:1.95
--- src/distrib/sets/lists/comp/ad.mips:1.94	Thu Jul 11 16:41:06 2024
+++ src/distrib/sets/lists/comp/ad.mips	Sun Nov  3 17:24:20 2024
@@ -1,4 +1,4 @@
-# $NetBSD: ad.mips,v 1.94 2024/07/11 20:41:06 riastradh Exp $
+# $NetBSD: ad.mips,v 1.95 2024/11/03 22:24:20 christos Exp $
 #
 -./usr/lib/64/libgomp.a
 -./usr/lib/64/libgomp.so
@@ -83,6 +83,7 @@
 ./usr/include/mips/limits.h			comp-c-include
 ./usr/include/mips/lock.h			comp-c-include
 ./usr/include/mips/locore.h			comp-c-include
+./usr/include/mips/lwp.h			comp-c-include
 ./usr/include/mips/math.h			comp-c-include
 ./usr/include/mips/mcontext.h			comp-c-include
 ./usr/include/mips/mips1_pte.h			comp-c-include

Index: src/distrib/sets/lists/comp/ad.powerpc
diff -u src/distrib/sets/lists/comp/ad.powerpc:1.108 src/distrib/sets/lists/comp/ad.powerpc:1.109
--- src/distrib/sets/lists/comp/ad.powerpc:1.108	Tue Aug 27 17:51:43 2024
+++ src/distrib/sets/lists/comp/ad.powerpc	Sun Nov  3 17:24:20 2024
@@ -1,4 +1,4 @@
-# $NetBSD: ad.powerpc,v 1.108 2024/08/27 21:51:43 christos Exp $
+# $NetBSD: ad.powerpc,v 1.109 2024/11/03 22:24:20 christos Exp $
 #
 ./usr/bin/elf2aout				comp-sysutil-bin
 ./usr/bin/psim					comp-obsolete		obsolete
@@ -218,6 +218,7 @@
 ./usr/include/powerpc/kcore.h			comp-c-include
 ./usr/include/powerpc/limits.h			comp-c-include
 ./usr/include/powerpc/lock.h			comp-c-include
+./usr/include/powerpc/lwp.h			comp-c-include
 ./usr/include/powerpc/machine_type.h		comp-obsolete		obsolete
 ./usr/include/powerpc/math.h			comp-c-include
 ./usr/include/powerpc/mcontext.h		comp-c-include

Index: src/distrib/sets/lists/comp/ad.riscv
diff -u src/distrib/sets/lists/comp/ad.riscv:1.23 src/distrib/sets/lists/comp/ad.riscv:1.24
--- src/distrib/sets/lists/comp/ad.riscv:1.23	Sat Oct 12 08:27:33 2024
+++ src/distrib/sets/lists/comp/ad.riscv	Sun Nov  3 17:24:20 2024
@@ -1,4 +1,4 @@
-# $NetBSD: ad.riscv,v 1.23 2024/10/12 12:27:33 skrll Exp $
+# $NetBSD: ad.riscv,v 1.24 2024/11/03 22:24:20 christos Exp $
 #
 ./usr/include/g++/bits/riscv32			comp-c-include		arch64,compat
 ./usr/include/g++/bits/riscv32/c++config.h	comp-c-include		arch64,gcc,compat
@@ -37,6 +37,7 @@
 ./usr/include/riscv/kcore.h			comp-c-include
 ./usr/include/riscv/limits.h			comp-c-include
 ./usr/include/riscv/lock.h			comp-c-include
+./usr/include/riscv/lwp.h			comp-c-include
 ./usr/include/riscv/math.h			comp-c-include
 ./usr/include/riscv/mcontext.h			comp-c-include
 ./usr/include/riscv/mutex.h			comp-c-include

Index: src/distrib/sets/lists/comp/ad.sh3
diff -u src/distrib/sets/lists/comp/ad.sh3:1.49 src/distrib/sets/lists/comp/ad.sh3:1.50
--- src/distrib/sets/lists/comp/ad.sh3:1.49	Thu Jul 11 16:41:06 2024
+++ src/distrib/sets/lists/comp/ad.sh3	Sun Nov  3 17:24:20 2024
@@ -1,4 +1,4 @@
-# $NetBSD: ad.sh3,v 1.49 2024/07/11 20:41:06 riastradh Exp $
+# $NetBSD: ad.sh3,v 1.50 2024/11/03 22:24:20 christos Exp $
 #
 ./usr/include/gcc-4.5/tgmath.h			comp-obsolete		obsolete
 ./usr/include/gcc-4.8/tgmath.h			comp-obsolete		obsolete
@@ -40,6 +40,7 @@
 ./usr/include/sh3/intr.h			comp-c-include
 ./usr/include/sh3/limits.h			comp-c-include
 ./usr/include/sh3/lock.h			comp-c-include
+./usr/include/sh3/lwp.h				comp-c-include
 ./usr/include/sh3/math.h			comp-c-include
 ./usr/include/sh3/mcontext.h			comp-c-include
 ./usr/include/sh3/mutex.h			comp-c-include

Index: src/distrib/sets/lists/comp/md.alpha
diff -u src/distrib/sets/lists/comp/md.alpha:1.82 src/distrib/sets/lists/comp/md.alpha:1.83
--- src/distrib/sets/lists/comp/md.alpha:1.82	Thu Jul 11 16:41:07 2024
+++ src/distrib/sets/lists/comp/md.alpha	Sun Nov  3 17:24:20 2024
@@ -1,4 +1,4 @@
-# $NetBSD: md.alpha,v 1.82 2024/07/11 20:41:07 riastradh Exp $
+# $NetBSD: md.alpha,v 1.83 2024/11/03 22:24:20 christos Exp $
 #
 ./usr/include/alpha				comp-c-include
 ./usr/include/alpha/_G_config.h			comp-obsolete		obsolete
@@ -42,6 +42,7 @@
 ./usr/include/alpha/kcore.h			comp-c-include
 ./usr/include/alpha/limits.h			comp-c-include
 ./usr/include/alpha/lock.h			comp-c-include
+./usr/include/alpha/lwp.h			comp-c-include
 ./usr/include/alpha/math.h			comp-c-include
 ./usr/include/alpha/mcontext.h			comp-c-include
 ./usr/include/alpha/mutex.h			comp-c-include

Index: src/distrib/sets/lists/comp/md.amd64
diff -u src/distrib/sets/lists/comp/md.amd64:1.303 src/distrib/sets/lists/comp/md.amd64:1.304
--- src/distrib/sets/lists/comp/md.amd64:1.303	Thu Jul 11 16:41:07 2024
+++ src/distrib/sets/lists/comp/md.amd64	Sun Nov  3 17:24:20 2024
@@ -1,4 +1,4 @@
-# $NetBSD: md.amd64,v 1.303 2024/07/11 20:41:07 riastradh Exp $
+# $NetBSD: md.amd64,v 1.304 2024/11/03 22:24:20 christos Exp $
 #
 ./usr/include/amd64				comp-c-include
 ./usr/include/amd64/ansi.h			comp-c-include
@@ -38,6 +38,7 @@
 ./usr/include/amd64/limits.h			comp-c-include
 ./usr/include/amd64/linux32_machdep.h		comp-c-include
 ./usr/include/amd64/lock.h			comp-c-include
+./usr/include/amd64/lwp.h			comp-c-include
 ./usr/include/amd64/math.h			comp-c-include
 ./usr/include/amd64/mcontext.h			comp-c-include
 ./usr/include/amd64/mtrr.h			comp-c-include
@@ -1303,6 +1304,7 @@
 ./usr/include/i386/kcore.h			comp-c-include
 ./usr/include/i386/limits.h			comp-c-include
 ./usr/include/i386/lock.h			comp-c-include
+./usr/include/i386/lwp.h			comp-c-include
 ./usr/include/i386/math.h			comp-c-include
 ./usr/include/i386/mcontext.h			comp-c-include
 ./usr/include/i386/mtrr.h			comp-c-include

Index: src/distrib/sets/lists/comp/md.hppa
diff -u src/distrib/sets/lists/comp/md.hppa:1.18 src/distrib/sets/lists/comp/md.hppa:1.19
--- src/distrib/sets/lists/comp/md.hppa:1.18	Thu Jul 11 16:41:07 2024
+++ src/distrib/sets/lists/comp/md.hppa	Sun Nov  3 17:24:20 2024
@@ -1,4 +1,4 @@
-# $NetBSD: md.hppa,v 1.18 2024/07/11 20:41:07 riastradh Exp $
+# $NetBSD: md.hppa,v 1.19 2024/11/03 22:24:20 christos Exp $
 #
 ./usr/include/gcc-4.5/tgmath.h			comp-obsolete		obsolete
 ./usr/include/gcc-4.8/tgmath.h			comp-obsolete		obsolete
@@ -105,6 +105,7 @@
 ./usr/include/hppa/limits.h			comp-c-include
 ./usr/include/hppa/loadfile_machdep.h		comp-c-include
 ./usr/include/hppa/lock.h			comp-c-include
+./usr/include/hppa/lwp.h			comp-c-include
 ./usr/include/hppa/math.h			comp-c-include
 ./usr/include/hppa/mcontext.h			comp-c-include
 ./usr/include/hppa/mutex.h			comp-c-include

Index: src/distrib/sets/lists/comp/md.i386
diff -u src/distrib/sets/lists/comp/md.i386:1.210 src/distrib/sets/lists/comp/md.i386:1.211
--- src/distrib/sets/lists/comp/md.i386:1.210	Thu Jul 11 16:41:07 2024
+++ src/distrib/sets/lists/comp/md.i386	Sun Nov  3 17:24:20 2024
@@ -1,4 +1,4 @@
-# $NetBSD: md.i386,v 1.210 2024/07/11 20:41:07 riastradh Exp $
+# $NetBSD: md.i386,v 1.211 2024/11/03 22:24:20 christos Exp $
 #
 ./usr/include/clang-3.4/__wmmintrin_aes.h	comp-obsolete		obsolete
 ./usr/include/clang-3.4/__wmmintrin_pclmul.h	comp-obsolete		obsolete
@@ -1232,6 +1232,7 @@
 ./usr/include/i386/limits.h			comp-c-include
 ./usr/include/i386/loadfile_machdep.h		comp-obsolete		obsolete
 ./usr/include/i386/lock.h			comp-c-include
+./usr/include/i386/lwp.h			comp-c-include
 ./usr/include/i386/math.h			comp-c-include
 ./usr/include/i386/mcontext.h			comp-c-include
 ./usr/include/i386/mouse.h			comp-obsolete		obsolete

Index: src/distrib/sets/lists/comp/md.ia64
diff -u src/distrib/sets/lists/comp/md.ia64:1.13 src/distrib/sets/lists/comp/md.ia64:1.14
--- src/distrib/sets/lists/comp/md.ia64:1.13	Thu Jul 11 16:41:07 2024
+++ src/distrib/sets/lists/comp/md.ia64	Sun Nov  3 17:24:21 2024
@@ -1,4 +1,4 @@
-# $NetBSD: md.ia64,v 1.13 2024/07/11 20:41:07 riastradh Exp $
+# $NetBSD: md.ia64,v 1.14 2024/11/03 22:24:21 christos Exp $
 #
 ./usr/include/gcc-4.8/ia64intrin.h	comp-obsolete		obsolete
 ./usr/include/gcc-4.8/tgmath.h		comp-obsolete		obsolete
@@ -51,6 +51,7 @@
 ./usr/include/ia64/limits.h		comp-c-include
 ./usr/include/ia64/loadfile_machdep.h	comp-c-include
 ./usr/include/ia64/lock.h		comp-c-include
+./usr/include/ia64/lwp.h		comp-c-include
 ./usr/include/ia64/math.h		comp-c-include
 ./usr/include/ia64/mca_machdep.h	comp-c-include
 ./usr/include/ia64/mcontext.h		comp-c-include

Index: src/distrib/sets/lists/comp/md.or1k
diff -u src/distrib/sets/lists/comp/md.or1k:1.14 src/distrib/sets/lists/comp/md.or1k:1.15
--- src/distrib/sets/lists/comp/md.or1k:1.14	Thu Jul 11 16:41:07 2024
+++ src/distrib/sets/lists/comp/md.or1k	Sun Nov  3 17:24:21 2024
@@ -1,4 +1,4 @@
-# $NetBSD: md.or1k,v 1.14 2024/07/11 20:41:07 riastradh Exp $
+# $NetBSD: md.or1k,v 1.15 2024/11/03 22:24:21 christos Exp $
 #
 ./usr/include/gcc-4.8/tgmath.h		comp-obsolete		obsolete
 ./usr/include/gcc-5/tgmath.h		comp-obsolete		obsolete
@@ -35,6 +35,7 @@
 ./usr/include/or1k/kcore.h		comp-c-include
 ./usr/include/or1k/limits.h		comp-c-include
 ./usr/include/or1k/lock.h		comp-c-include
+./usr/include/or1k/lwp.h		comp-c-include
 ./usr/include/or1k/math.h		comp-c-include
 ./usr/include/or1k/mcontext.h		comp-c-include
 ./usr/include/or1k/mutex.h		comp-c-include

Index: src/distrib/sets/lists/comp/md.sparc
diff -u src/distrib/sets/lists/comp/md.sparc:1.105 src/distrib/sets/lists/comp/md.sparc:1.106
--- src/distrib/sets/lists/comp/md.sparc:1.105	Thu Jul 11 16:41:07 2024
+++ src/distrib/sets/lists/comp/md.sparc	Sun Nov  3 17:24:21 2024
@@ -1,4 +1,4 @@
-# $NetBSD: md.sparc,v 1.105 2024/07/11 20:41:07 riastradh Exp $
+# $NetBSD: md.sparc,v 1.106 2024/11/03 22:24:21 christos Exp $
 #
 ./usr/include/gcc-4.5/tgmath.h			comp-obsolete		obsolete
 ./usr/include/gcc-4.8/tgmath.h			comp-obsolete		obsolete
@@ -58,6 +58,7 @@
 ./usr/include/sparc/kcore.h			comp-c-include
 ./usr/include/sparc/limits.h			comp-c-include
 ./usr/include/sparc/lock.h			comp-c-include
+./usr/include/sparc/lwp.h			comp-c-include
 ./usr/include/sparc/math.h			comp-c-include
 ./usr/include/sparc/mcontext.h			comp-c-include
 ./usr/include/sparc/mutex.h			comp-c-include

Index: src/distrib/sets/lists/comp/md.vax
diff -u src/distrib/sets/lists/comp/md.vax:1.56 src/distrib/sets/lists/comp/md.vax:1.57
--- src/distrib/sets/lists/comp/md.vax:1.56	Thu Jul 11 16:41:07 2024
+++ src/distrib/sets/lists/comp/md.vax	Sun Nov  3 17:24:21 2024
@@ -1,4 +1,4 @@
-# $NetBSD: md.vax,v 1.56 2024/07/11 20:41:07 riastradh Exp $
+# $NetBSD: md.vax,v 1.57 2024/11/03 22:24:21 christos Exp $
 #
 ./usr/include/gcc-4.5/tgmath.h			comp-obsolete		obsolete
 ./usr/include/gcc-4.8/tgmath.h			comp-obsolete		obsolete
@@ -47,6 +47,7 @@
 ./usr/include/vax/leds.h			comp-c-include
 ./usr/include/vax/limits.h			comp-c-include
 ./usr/include/vax/lock.h			comp-c-include
+./usr/include/vax/lwp.h				comp-c-include
 ./usr/include/vax/macros.h			comp-c-include
 ./usr/include/vax/math.h			comp-c-include
 ./usr/include/vax/mcontext.h			comp-c-include

Index: src/include/lwp.h
diff -u src/include/lwp.h:1.13 src/include/lwp.h:1.14
--- src/include/lwp.h:1.13	Thu Dec  7 20:19:29 2017
+++ src/include/lwp.h	Sun Nov  3 17:24:20 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: lwp.h,v 1.13 2017/12/08 01:19:29 christos Exp $	*/
+/*	$NetBSD: lwp.h,v 1.14 2024/11/03 22:24:20 christos Exp $	*/
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -64,4 +64,6 @@ int	_lwp_getname(lwpid_t, char *, size_t
 int	_lwp_ctl(int, struct lwpctl **);
 __END_DECLS
 
+#include <machine/lwp.h>
+
 #endif /* !_LWP_H_ */

Index: src/libexec/ld.elf_so/arch/i386/mdreloc.c
diff -u src/libexec/ld.elf_so/arch/i386/mdreloc.c:1.44 src/libexec/ld.elf_so/arch/i386/mdreloc.c:1.45
--- src/libexec/ld.elf_so/arch/i386/mdreloc.c:1.44	Sat Aug  3 17:59:58 2024
+++ src/libexec/ld.elf_so/arch/i386/mdreloc.c	Sun Nov  3 17:24:20 2024
@@ -1,12 +1,12 @@
-/*	$NetBSD: mdreloc.c,v 1.44 2024/08/03 21:59:58 riastradh Exp $	*/
+/*	$NetBSD: mdreloc.c,v 1.45 2024/11/03 22:24:20 christos Exp $	*/
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: mdreloc.c,v 1.44 2024/08/03 21:59:58 riastradh Exp $");
+__RCSID("$NetBSD: mdreloc.c,v 1.45 2024/11/03 22:24:20 christos Exp $");
 #endif /* not lint */
 
 #include <sys/types.h>
-#include <sys/ucontext.h>
+#include <lwp.h>
 
 #include "debug.h"
 #include "rtld.h"

Index: src/sys/arch/alpha/include/Makefile
diff -u src/sys/arch/alpha/include/Makefile:1.34 src/sys/arch/alpha/include/Makefile:1.35
--- src/sys/arch/alpha/include/Makefile:1.34	Thu Jul 12 06:46:41 2018
+++ src/sys/arch/alpha/include/Makefile	Sun Nov  3 17:24:21 2024
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.34 2018/07/12 10:46:41 maxv Exp $
+#	$NetBSD: Makefile,v 1.35 2024/11/03 22:24:21 christos Exp $
 
 INCSDIR= /usr/include/alpha
 
@@ -13,7 +13,7 @@ INCS=	alpha_cpu.h ansi.h aout_machdep.h 
 	intr.h \
 	joystick.h \
 	kbio.h kcore.h \
-	limits.h lock.h \
+	limits.h lock.h lwp.h \
 	math.h mcontext.h mutex.h \
 	pal.h param.h pcb.h pio.h pmap.h proc.h profile.h prom.h psl.h \
 	pte.h ptrace.h \

Index: src/sys/arch/alpha/include/mcontext.h
diff -u src/sys/arch/alpha/include/mcontext.h:1.12 src/sys/arch/alpha/include/mcontext.h:1.13
--- src/sys/arch/alpha/include/mcontext.h:1.12	Fri May 17 20:37:40 2024
+++ src/sys/arch/alpha/include/mcontext.h	Sun Nov  3 17:24:21 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: mcontext.h,v 1.12 2024/05/18 00:37:40 thorpej Exp $	*/
+/*	$NetBSD: mcontext.h,v 1.13 2024/11/03 22:24:21 christos Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -104,24 +104,4 @@ typedef struct {
 
 #define	_UC_MACHINE_SET_PC(uc, pc)	_UC_MACHINE_PC(uc) = (pc)
 
-#if defined(_RTLD_SOURCE) || defined(_LIBC_SOURCE) || \
-    defined(__LIBPTHREAD_SOURCE__)
-#include <sys/tls.h>
-
-__BEGIN_DECLS
-static __inline void *
-__lwp_getprivate_fast(void)
-{
-	register void *__tmp __asm("$0");
-
-	__asm volatile("call_pal %1 # PAL_rdunique"
-		: "=r" (__tmp)
-		: "i" (0x009e /* PAL_rdunique */));
-
-	return __tmp;
-}
-__END_DECLS
-
-#endif
-
 #endif	/* !_ALPHA_MCONTEXT_H_ */

Index: src/sys/arch/amd64/include/Makefile
diff -u src/sys/arch/amd64/include/Makefile:1.22 src/sys/arch/amd64/include/Makefile:1.23
--- src/sys/arch/amd64/include/Makefile:1.22	Wed Oct 31 14:35:04 2018
+++ src/sys/arch/amd64/include/Makefile	Sun Nov  3 17:24:21 2024
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.22 2018/10/31 18:35:04 maxv Exp $
+#	$NetBSD: Makefile,v 1.23 2024/11/03 22:24:21 christos Exp $
 
 INCSDIR= /usr/include/amd64
 
@@ -19,7 +19,7 @@ INCS=	ansi.h aout_machdep.h asm.h \
 	netbsd32_machdep.h \
 	param.h pcb.h pci_machdep.h pio.h pmap.h proc.h \
 	profile.h psl.h pte.h ptrace.h \
-	reg.h rwlock.h \
+	lwp.h reg.h rwlock.h \
 	segments.h setjmp.h signal.h sljit_machdep.h specialreg.h sysarch.h \
 	trap.h tss.h types.h \
 	userret.h \

Index: src/sys/arch/amd64/include/mcontext.h
diff -u src/sys/arch/amd64/include/mcontext.h:1.21 src/sys/arch/amd64/include/mcontext.h:1.22
--- src/sys/arch/amd64/include/mcontext.h:1.21	Fri May 17 20:37:40 2024
+++ src/sys/arch/amd64/include/mcontext.h	Sun Nov  3 17:24:21 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: mcontext.h,v 1.21 2024/05/18 00:37:40 thorpej Exp $	*/
+/*	$NetBSD: mcontext.h,v 1.22 2024/11/03 22:24:21 christos Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -84,24 +84,6 @@ typedef struct {
 
 #define	__UCONTEXT_SIZE	784
 
-#if defined(_RTLD_SOURCE) || defined(_LIBC_SOURCE) || \
-    defined(__LIBPTHREAD_SOURCE__)
-#include <sys/tls.h>
-
-__BEGIN_DECLS
-static __inline void *
-__lwp_getprivate_fast(void)
-{
-	void *__tmp;
-
-	__asm volatile("movq %%fs:0, %0" : "=r" (__tmp));
-
-	return __tmp;
-}
-__END_DECLS
-
-#endif
-
 #ifdef _KERNEL
 
 /*

Index: src/sys/arch/arm/include/Makefile
diff -u src/sys/arch/arm/include/Makefile:1.52 src/sys/arch/arm/include/Makefile:1.53
--- src/sys/arch/arm/include/Makefile:1.52	Sat Sep 26 06:06:26 2020
+++ src/sys/arch/arm/include/Makefile	Sun Nov  3 17:24:21 2024
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.52 2020/09/26 10:06:26 skrll Exp $
+#	$NetBSD: Makefile,v 1.53 2024/11/03 22:24:21 christos Exp $
 
 INCSDIR= /usr/include/arm
 
@@ -12,7 +12,7 @@ INCS=	aeabi.h ansi.h aout_machdep.h apmv
 	int_const.h int_fmtio.h int_limits.h int_mwgwtypes.h int_types.h \
 	joystick.h \
 	kcore.h \
-	limits.h lock.h \
+	limits.h lock.h lwp.h \
 	math.h mcontext.h mutex.h \
 	param.h pcb.h proc.h profile.h rwlock.h \
 	ptrace.h \

Index: src/sys/arch/arm/include/mcontext.h
diff -u src/sys/arch/arm/include/mcontext.h:1.24 src/sys/arch/arm/include/mcontext.h:1.25
--- src/sys/arch/arm/include/mcontext.h:1.24	Fri May 17 20:37:40 2024
+++ src/sys/arch/arm/include/mcontext.h	Sun Nov  3 17:24:21 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: mcontext.h,v 1.24 2024/05/18 00:37:40 thorpej Exp $	*/
+/*	$NetBSD: mcontext.h,v 1.25 2024/11/03 22:24:21 christos Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
@@ -210,52 +210,6 @@ typedef struct {
 
 #endif
 
-#if defined(_RTLD_SOURCE) || defined(_LIBC_SOURCE) || \
-    defined(__LIBPTHREAD_SOURCE__)
-
-#include <sys/tls.h>
-
-#if defined(__aarch64__)
-
-__BEGIN_DECLS
-static __inline void *
-__lwp_getprivate_fast(void)
-{
-	void *__tpidr;
-	__asm __volatile("mrs\t%0, tpidr_el0" : "=r"(__tpidr));
-	return __tpidr;
-}
-__END_DECLS
-
-#elif defined(__arm__)
-
-__BEGIN_DECLS
-static __inline void *
-__lwp_getprivate_fast(void)
-{
-#if !defined(__thumb__) || defined(_ARM_ARCH_T2)
-	extern void *_lwp_getprivate(void);
-	void *rv;
-	__asm("mrc p15, 0, %0, c13, c0, 3" : "=r"(rv));
-	if (__predict_true(rv))
-		return rv;
-	/*
-	 * Some ARM cores are broken and don't raise an undefined fault when an
-	 * unrecogized mrc instruction is encountered, but just return zero.
-	 * To do deal with that, if we get a zero we (re-)fetch the value using
-	 * syscall.
-	 */
-	return _lwp_getprivate();
-#else
-	extern void *__aeabi_read_tp(void);
-	return __aeabi_read_tp();
-#endif /* !__thumb__ || _ARM_ARCH_T2 */
-}
-__END_DECLS
-#endif
-
-#endif /* _RTLD_SOURCE || _LIBC_SOURCE || __LIBPTHREAD_SOURCE__ */
-
 /* Machine-dependent uc_flags */
 #define _UC_TLSBASE	_UC_MD_BIT19	/* see <sys/ucontext.h> */
 

Index: src/sys/arch/hppa/include/Makefile
diff -u src/sys/arch/hppa/include/Makefile:1.13 src/sys/arch/hppa/include/Makefile:1.14
--- src/sys/arch/hppa/include/Makefile:1.13	Thu Jul 12 06:46:44 2018
+++ src/sys/arch/hppa/include/Makefile	Sun Nov  3 17:24:21 2024
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.13 2018/07/12 10:46:44 maxv Exp $
+#	$NetBSD: Makefile,v 1.14 2024/11/03 22:24:21 christos Exp $
 
 INCSDIR= /usr/include/hppa
 
@@ -11,7 +11,7 @@ INCS=	ansi.h aout_machdep.h asm.h autoco
 	ieee.h ieeefp.h intr.h intrdefs.h iomod.h isa_machdep.h \
 	int_const.h int_fmtio.h int_limits.h int_mwgwtypes.h int_types.h \
 	kcore.h \
-	limits.h loadfile_machdep.h lock.h \
+	limits.h loadfile_machdep.h lock.h lwp.h \
 	math.h mcontext.h mutex.h \
 	nvm.h \
 	param.h pcb.h pdc.h pmap.h proc.h profile.h psl.h pte.h ptrace.h \
Index: src/sys/arch/hppa/include/mcontext.h
diff -u src/sys/arch/hppa/include/mcontext.h:1.13 src/sys/arch/hppa/include/mcontext.h:1.14
--- src/sys/arch/hppa/include/mcontext.h:1.13	Fri May 17 20:37:40 2024
+++ src/sys/arch/hppa/include/mcontext.h	Sun Nov  3 17:24:21 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: mcontext.h,v 1.13 2024/05/18 00:37:40 thorpej Exp $	*/
+/*	$NetBSD: mcontext.h,v 1.14 2024/11/03 22:24:21 christos Exp $	*/
 
 #ifndef _HPPA_MCONTEXT_H_
 #define	_HPPA_MCONTEXT_H_
@@ -91,24 +91,6 @@ do {									\
 } while (/*CONSTCOND*/0)
 #define	_UC_MACHINE_INTRV(uc) 	((uc)->uc_mcontext.__gregs[_REG_RET0])
 
-#if defined(_RTLD_SOURCE) || defined(_LIBC_SOURCE) || \
-    defined(__LIBPTHREAD_SOURCE__)
-#include <sys/tls.h>
-
-__BEGIN_DECLS
-static __inline void *
-__lwp_getprivate_fast(void)
-{
-	register void *__tmp;
-
-	__asm volatile("mfctl\t27 /* CR_TLS */, %0" : "=r" (__tmp));
-
-	return __tmp;
-}
-__END_DECLS
-
-#endif
-
 #endif /* !__ASSEMBLER__ */
 
 #define	_UC_SETSTACK	_UC_MD_BIT16

Index: src/sys/arch/i386/include/Makefile
diff -u src/sys/arch/i386/include/Makefile:1.50 src/sys/arch/i386/include/Makefile:1.51
--- src/sys/arch/i386/include/Makefile:1.50	Thu Sep 12 22:19:45 2019
+++ src/sys/arch/i386/include/Makefile	Sun Nov  3 17:24:21 2024
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.50 2019/09/13 02:19:45 manu Exp $
+#	$NetBSD: Makefile,v 1.51 2024/11/03 22:24:21 christos Exp $
 
 INCSDIR= /usr/include/i386
 
@@ -14,7 +14,7 @@ INCS=	ansi.h aout_machdep.h apmvar.h asm
 	intr.h intrdefs.h \
 	joystick.h \
 	kcore.h \
-	limits.h lock.h \
+	limits.h lock.h lwp.h \
 	math.h mcontext.h mutex.h mtrr.h multiboot.h multiboot2.h \
 	param.h pcb.h pio.h pmap.h proc.h profile.h psl.h \
 	pte.h ptrace.h \

Index: src/sys/arch/i386/include/mcontext.h
diff -u src/sys/arch/i386/include/mcontext.h:1.16 src/sys/arch/i386/include/mcontext.h:1.17
--- src/sys/arch/i386/include/mcontext.h:1.16	Fri May 17 20:37:40 2024
+++ src/sys/arch/i386/include/mcontext.h	Sun Nov  3 17:24:21 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: mcontext.h,v 1.16 2024/05/18 00:37:40 thorpej Exp $	*/
+/*	$NetBSD: mcontext.h,v 1.17 2024/11/03 22:24:21 christos Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -113,22 +113,4 @@ typedef struct {
 
 #define	__UCONTEXT_SIZE	776
 
-#if defined(_RTLD_SOURCE) || defined(_LIBC_SOURCE) || \
-    defined(__LIBPTHREAD_SOURCE__)
-#include <sys/tls.h>
-
-__BEGIN_DECLS
-static __inline void *
-__lwp_getprivate_fast(void)
-{
-	void *__tmp;
-
-	__asm volatile("movl %%gs:0, %0" : "=r" (__tmp));
-
-	return __tmp;
-}
-__END_DECLS
-
-#endif
-
 #endif	/* !_I386_MCONTEXT_H_ */

Index: src/sys/arch/ia64/include/Makefile
diff -u src/sys/arch/ia64/include/Makefile:1.8 src/sys/arch/ia64/include/Makefile:1.9
--- src/sys/arch/ia64/include/Makefile:1.8	Wed Feb 22 21:03:27 2017
+++ src/sys/arch/ia64/include/Makefile	Sun Nov  3 17:24:22 2024
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.8 2017/02/23 02:03:27 scole Exp $
+#	$NetBSD: Makefile,v 1.9 2024/11/03 22:24:22 christos Exp $
 
 INCSDIR= /usr/include/ia64
 
@@ -8,9 +8,9 @@ INCS=	_regset.h acpi_machdep.h ansi.h \
 	endian.h endian_machdep.h fenv.h float.h fpu.h frame.h \
 	ia64_cpu.h ieee.h ieeefp.h int_const.h int_fmtio.h int_limits.h \
 	int_mwgwtypes.h int_types.h intr.h limits.h \
-	loadfile_machdep.h lock.h math.h mca_machdep.h mcontext.h md_var.h \
-	mutex.h pal.h param.h pcb.h pmap.h proc.h profile.h pte.h ptrace.h \
-	reg.h sal.h rwlock.h setjmp.h signal.h smp.h ssc.h types.h \
+	loadfile_machdep.h lock.h lwp.h math.h mca_machdep.h mcontext.h \
+	md_var.h mutex.h pal.h param.h pcb.h pmap.h proc.h profile.h pte.h \
+	ptrace.h reg.h sal.h rwlock.h setjmp.h signal.h smp.h ssc.h types.h \
 	vmparam.h wchar_limits.h
 
 .include <bsd.kinc.mk>

Index: src/sys/arch/ia64/include/mcontext.h
diff -u src/sys/arch/ia64/include/mcontext.h:1.13 src/sys/arch/ia64/include/mcontext.h:1.14
--- src/sys/arch/ia64/include/mcontext.h:1.13	Sat May 18 15:57:03 2024
+++ src/sys/arch/ia64/include/mcontext.h	Sun Nov  3 17:24:22 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: mcontext.h,v 1.13 2024/05/18 19:57:03 christos Exp $	*/
+/*	$NetBSD: mcontext.h,v 1.14 2024/11/03 22:24:22 christos Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -121,19 +121,4 @@ typedef struct __mcontext {
 #define	_UC_SETSTACK	_UC_MD_BIT17
 #define	_UC_CLRSTACK	_UC_MD_BIT18
 
-
-#if defined(_RTLD_SOURCE) || defined(_LIBC_SOURCE) || \
-    defined(__LIBPTHREAD_SOURCE__)
-#include <sys/tls.h>
-
-__BEGIN_DECLS
-static __inline void *
-__lwp_getprivate_fast(void)
-{
-	return (void*)0;
-}
-__END_DECLS
-
-#endif
-
 #endif	/* !_IA64_MCONTEXT_H_ */

Index: src/sys/arch/m68k/include/Makefile
diff -u src/sys/arch/m68k/include/Makefile:1.35 src/sys/arch/m68k/include/Makefile:1.36
--- src/sys/arch/m68k/include/Makefile:1.35	Sun Jan 14 17:32:32 2024
+++ src/sys/arch/m68k/include/Makefile	Sun Nov  3 17:24:22 2024
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.35 2024/01/14 22:32:32 thorpej Exp $
+#	$NetBSD: Makefile,v 1.36 2024/11/03 22:24:22 christos Exp $
 
 INCSDIR= /usr/include/m68k
 
@@ -12,7 +12,7 @@ INCS=	ansi.h aout_machdep.h asm.h asm_si
 	int_const.h int_fmtio.h int_limits.h int_mwgwtypes.h int_types.h \
 	intr.h \
 	kcore.h \
-	limits.h lock.h \
+	limits.h lock.h lwp.h \
 	m68k.h math.h mcontext.h mmu_30.h mmu_40.h mmu_51.h mutex.h \
 	param.h pmap_motorola.h pcb.h proc.h profile.h \
 	psl.h pte_motorola.h ptrace.h \

Index: src/sys/arch/m68k/include/mcontext.h
diff -u src/sys/arch/m68k/include/mcontext.h:1.13 src/sys/arch/m68k/include/mcontext.h:1.14
--- src/sys/arch/m68k/include/mcontext.h:1.13	Fri May 17 20:37:41 2024
+++ src/sys/arch/m68k/include/mcontext.h	Sun Nov  3 17:24:22 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: mcontext.h,v 1.13 2024/05/18 00:37:41 thorpej Exp $	*/
+/*	$NetBSD: mcontext.h,v 1.14 2024/11/03 22:24:22 christos Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -110,35 +110,4 @@ typedef struct {
 
 #define	__UCONTEXT_SIZE	1024
 
-#if defined(_LIBC_SOURCE) || defined(_RTLD_SOURCE) || defined(__LIBPTHREAD_SOURCE__)
-#define	TLS_TP_OFFSET	0x7000
-#define	TLS_DTV_OFFSET	0x8000
-
-#include <sys/tls.h>
-
-__CTASSERT(TLS_TP_OFFSET + sizeof(struct tls_tcb) < 0x8000);
-__CTASSERT(TLS_TP_OFFSET % sizeof(struct tls_tcb) == 0);
-
-__BEGIN_DECLS
-
-void *_lwp_getprivate(void);
-void _lwp_setprivate(void *);
-
-static __inline struct tls_tcb *
-__lwp_gettcb_fast(void)
-{
-	unsigned int __tcb = (unsigned int)_lwp_getprivate();
-	return (struct tls_tcb *)(uintptr_t)
-	    (__tcb - TLS_TP_OFFSET - sizeof(struct tls_tcb));
-}
-
-static inline void
-__lwp_settcb(struct tls_tcb *__tcb)
-{
-	__tcb += TLS_TP_OFFSET / sizeof(*__tcb) + 1;
-	_lwp_setprivate(__tcb);
-}
-__END_DECLS
-#endif
-
 #endif	/* !_M68K_MCONTEXT_H_ */

Index: src/sys/arch/mips/include/Makefile
diff -u src/sys/arch/mips/include/Makefile:1.35 src/sys/arch/mips/include/Makefile:1.36
--- src/sys/arch/mips/include/Makefile:1.35	Sun Mar 28 21:48:29 2021
+++ src/sys/arch/mips/include/Makefile	Sun Nov  3 17:24:22 2024
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.35 2021/03/29 01:48:29 simonb Exp $
+#	$NetBSD: Makefile,v 1.36 2024/11/03 22:24:22 christos Exp $
 
 INCSDIR= /usr/include/mips
 
@@ -10,7 +10,7 @@ INCS=	ansi.h asm.h \
 	ieee.h ieeefp.h \
 	int_const.h int_fmtio.h int_limits.h int_mwgwtypes.h int_types.h \
 	kcore.h kdbparam.h \
-	limits.h lock.h locore.h mcontext.h math.h \
+	limits.h lock.h locore.h lwp.h mcontext.h math.h \
 	mips1_pte.h mips3_pte.h mips_opcode.h mips_param.h mutex.h \
 	pcb.h pmap.h proc.h profile.h psl.h pte.h ptrace.h \
 	reg.h regdef.h regnum.h reloc.h rwlock.h \

Index: src/sys/arch/mips/include/mcontext.h
diff -u src/sys/arch/mips/include/mcontext.h:1.24 src/sys/arch/mips/include/mcontext.h:1.25
--- src/sys/arch/mips/include/mcontext.h:1.24	Sat Oct  3 05:56:00 2020
+++ src/sys/arch/mips/include/mcontext.h	Sun Nov  3 17:24:22 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: mcontext.h,v 1.24 2020/10/03 09:56:00 martin Exp $	*/
+/*	$NetBSD: mcontext.h,v 1.25 2024/11/03 22:24:22 christos Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2002 The NetBSD Foundation, Inc.
@@ -187,55 +187,4 @@ typedef struct {
 #error O64 is not supported
 #endif
 
-#if defined(_LIBC_SOURCE) || defined(_RTLD_SOURCE) || defined(__LIBPTHREAD_SOURCE__)
-#define	TLS_TP_OFFSET	0x7000
-#define	TLS_DTV_OFFSET	0x8000
-
-#include <sys/tls.h>
-
-__CTASSERT(TLS_TP_OFFSET + sizeof(struct tls_tcb) < 0x8000);
-__CTASSERT(TLS_TP_OFFSET % sizeof(struct tls_tcb) == 0);
-
-__BEGIN_DECLS
-
-static __inline struct tls_tcb *
-__lwp_gettcb_fast(void)
-{
-	struct tls_tcb *__tcb;
-
-	/*
-	 * Only emit a rdhwr $3, $29 so the kernel can quickly emulate it.
-	 */
-	__asm __volatile(
-#if 1
-		// For some reason the syscall is much faster than
-		// emulating rdhwr $3,$29 on a CN50xx
-		"addiu $2,$0,316; syscall; nop; move %[__tcb],$2"
-#else
-		".set push"
-		";.set mips32r2"
-		";.p2align 4"
-		";ssnop"
-		";rdhwr $3,$29"
-		";ssnop"
-		";move %0,$3"
-		";.set pop"
-#endif
-	    : [__tcb]"=r"(__tcb)
-	    :
-	    : "v0", "v1", "a3");
-	return __tcb - (TLS_TP_OFFSET / sizeof(*__tcb) + 1);
-}
-
-void _lwp_setprivate(void *);
-
-static inline void
-__lwp_settcb(struct tls_tcb *__tcb)
-{
-	__tcb += TLS_TP_OFFSET / sizeof(*__tcb) + 1;
-	_lwp_setprivate(__tcb);
-}
-__END_DECLS
-#endif
-
 #endif	/* _MIPS_MCONTEXT_H_ */

Index: src/sys/arch/or1k/include/Makefile
diff -u src/sys/arch/or1k/include/Makefile:1.2 src/sys/arch/or1k/include/Makefile:1.3
--- src/sys/arch/or1k/include/Makefile:1.2	Thu Jul 12 06:46:46 2018
+++ src/sys/arch/or1k/include/Makefile	Sun Nov  3 17:24:22 2024
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.2 2018/07/12 10:46:46 maxv Exp $
+# $NetBSD: Makefile,v 1.3 2024/11/03 22:24:22 christos Exp $
 
 INCSDIR= /usr/include/or1k
 
@@ -12,7 +12,7 @@ INCS=	ansi.h aout_machdep.h asm.h \
 	int_const.h int_fmtio.h int_limits.h int_mwgwtypes.h int_types.h \
 	intr.h \
 	kcore.h \
-	limits.h lock.h \
+	limits.h lock.h lwp.h \
 	math.h mcontext.h mutex.h \
 	param.h pcb.h pmap.h \
 	proc.h profile.h pte.h ptrace.h \
Index: src/sys/arch/or1k/include/mcontext.h
diff -u src/sys/arch/or1k/include/mcontext.h:1.2 src/sys/arch/or1k/include/mcontext.h:1.3
--- src/sys/arch/or1k/include/mcontext.h:1.2	Thu Feb 15 10:53:56 2018
+++ src/sys/arch/or1k/include/mcontext.h	Sun Nov  3 17:24:22 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: mcontext.h,v 1.2 2018/02/15 15:53:56 kamil Exp $ */
+/* $NetBSD: mcontext.h,v 1.3 2024/11/03 22:24:22 christos Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -94,48 +94,4 @@ typedef struct {
 
 #define	_UC_MACHINE_SET_PC(uc, pc)	_UC_MACHINE_PC(uc) = (pc)
 
-#if defined(_RTLD_SOURCE) || defined(_LIBC_SOURCE) || defined(__LIBPTHREAD_SOURCE__)
-#include <sys/tls.h>
-
-/*
- * On OpenRISC 1000, since displacements are signed 16-bit values, the TCB
- * Pointer is biased by 0x7000 + sizeof(tcb) so that first thread datum can be 
- * addressed by -28672 thereby leaving 60KB available for use as thread data.
- */
-#define	TLS_TP_OFFSET	0x7000
-#define	TLS_DTV_OFFSET	0x8000
-__CTASSERT(TLS_TP_OFFSET + sizeof(struct tls_tcb) < 0x8000);
-
-static __inline void *
-__lwp_getprivate_fast(void)
-{
-	void *__tp;
-	__asm("l.ori %0,r10,0" : "=r"(__tp));
-	return __tp;
-}
-
-static __inline void *
-__lwp_gettcb_fast(void)
-{
-	void *__tcb;
-
-	__asm __volatile(
-		"l.addi %[__tcb],r10,%[__offset]"
-	    :	[__tcb] "=r" (__tcb)
-	    :	[__offset] "n" (-(TLS_TP_OFFSET + sizeof(struct tls_tcb))));
-
-	return __tcb;
-}
-
-static __inline void
-__lwp_settcb(void *__tcb)
-{
-	__asm __volatile(
-		"l.addi r10,%[__tcb],%[__offset]"
-	    :
-	    :	[__tcb] "r" (__tcb),
-		[__offset] "n" (TLS_TP_OFFSET + sizeof(struct tls_tcb)));
-}
-#endif /* _RTLD_SOURCE || _LIBC_SOURCE || __LIBPTHREAD_SOURCE__ */
-
 #endif /* !_OR1K_MCONTEXT_H_ */

Index: src/sys/arch/powerpc/include/Makefile
diff -u src/sys/arch/powerpc/include/Makefile:1.42 src/sys/arch/powerpc/include/Makefile:1.43
--- src/sys/arch/powerpc/include/Makefile:1.42	Thu Jul 12 06:46:46 2018
+++ src/sys/arch/powerpc/include/Makefile	Sun Nov  3 17:24:22 2024
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.42 2018/07/12 10:46:46 maxv Exp $
+#	$NetBSD: Makefile,v 1.43 2024/11/03 22:24:22 christos Exp $
 
 .if !defined(INCSDIR)
 INCSDIR?= /usr/include/powerpc
@@ -13,7 +13,7 @@ INCS+=	ansi.h aout_machdep.h asm.h \
 	ieee.h ieeefp.h \
 	int_const.h int_fmtio.h int_limits.h int_mwgwtypes.h int_types.h \
 	kcore.h \
-	limits.h lock.h \
+	limits.h lock.h lwp.h \
 	math.h mcontext.h mutex.h \
 	param.h pcb.h pmap.h proc.h profile.h psl.h pte.h ptrace.h \
 	reg.h reloc.h rwlock.h \

Index: src/sys/arch/powerpc/include/mcontext.h
diff -u src/sys/arch/powerpc/include/mcontext.h:1.23 src/sys/arch/powerpc/include/mcontext.h:1.24
--- src/sys/arch/powerpc/include/mcontext.h:1.23	Fri May 17 20:37:41 2024
+++ src/sys/arch/powerpc/include/mcontext.h	Sun Nov  3 17:24:22 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: mcontext.h,v 1.23 2024/05/18 00:37:41 thorpej Exp $	*/
+/*	$NetBSD: mcontext.h,v 1.24 2024/11/03 22:24:22 christos Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -141,48 +141,4 @@ typedef struct {
 
 #define	_UC_MACHINE_SET_PC(uc, pc)	_UC_MACHINE_PC(uc) = (pc)
 
-#if defined(_RTLD_SOURCE) || defined(_LIBC_SOURCE) || defined(__LIBPTHREAD_SOURCE__)
-#include <sys/tls.h>
-
-/*
- * On PowerPC, since displacements are signed 16-bit values, the TCB Pointer
- * is biased by 0x7000 + sizeof(tcb) so that first thread datum can be 
- * addressed by -28672 thereby leaving 60KB available for use as thread data.
- */
-#define	TLS_TP_OFFSET	0x7000
-#define	TLS_DTV_OFFSET	0x8000
-__CTASSERT(TLS_TP_OFFSET + sizeof(struct tls_tcb) < 0x8000);
-
-__BEGIN_DECLS
-
-static __inline void *
-__lwp_gettcb_fast(void)
-{
-	void *__tcb;
-
-	__asm __volatile(
-		"addi %[__tcb],%%r2,%[__offset]"
-	    :	[__tcb] "=r" (__tcb)
-	    :	[__offset] "n" (-(TLS_TP_OFFSET + sizeof(struct tls_tcb))));
-
-	return __tcb;
-}
-
-void _lwp_setprivate(void *);
-
-static __inline void
-__lwp_settcb(void *__tcb)
-{
-	__tcb = (uint8_t *)__tcb + TLS_TP_OFFSET + sizeof(struct tls_tcb);
-
-	__asm __volatile(
-		"mr %%r2,%[__tcb]"
-	    :
-	    :	[__tcb] "r" (__tcb));
-
-	_lwp_setprivate(__tcb);
-}
-__END_DECLS
-#endif /* _RTLD_SOURCE || _LIBC_SOURCE || __LIBPTHREAD_SOURCE__ */
-
 #endif	/* !_POWERPC_MCONTEXT_H_ */

Index: src/sys/arch/riscv/include/Makefile
diff -u src/sys/arch/riscv/include/Makefile:1.3 src/sys/arch/riscv/include/Makefile:1.4
--- src/sys/arch/riscv/include/Makefile:1.3	Sat Oct 12 08:27:33 2024
+++ src/sys/arch/riscv/include/Makefile	Sun Nov  3 17:24:22 2024
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.3 2024/10/12 12:27:33 skrll Exp $
+# $NetBSD: Makefile,v 1.4 2024/11/03 22:24:22 christos Exp $
 
 INCSDIR= /usr/include/riscv
 
@@ -11,7 +11,7 @@ INCS=	ansi.h aout_machdep.h asm.h \
 	ieee.h ieeefp.h \
 	int_const.h int_fmtio.h int_limits.h int_mwgwtypes.h int_types.h \
 	kcore.h \
-	limits.h lock.h \
+	limits.h lock.h lwp.h \
 	math.h mcontext.h mutex.h \
 	param.h pcb.h pmap.h \
 	proc.h profile.h pte.h ptrace.h \

Index: src/sys/arch/riscv/include/mcontext.h
diff -u src/sys/arch/riscv/include/mcontext.h:1.9 src/sys/arch/riscv/include/mcontext.h:1.10
--- src/sys/arch/riscv/include/mcontext.h:1.9	Fri May 31 09:11:41 2024
+++ src/sys/arch/riscv/include/mcontext.h	Sun Nov  3 17:24:22 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: mcontext.h,v 1.9 2024/05/31 13:11:41 skrll Exp $ */
+/* $NetBSD: mcontext.h,v 1.10 2024/11/03 22:24:22 christos Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -147,51 +147,4 @@ typedef struct {
 
 #define	_UC_MACHINE_SET_PC(uc, pc)	_UC_MACHINE_PC(uc) = (pc)
 
-#if defined(_RTLD_SOURCE) || defined(_LIBC_SOURCE) || defined(__LIBPTHREAD_SOURCE__)
-#include <sys/tls.h>
-
-static __inline void *
-__lwp_getprivate_fast(void)
-{
-	void *__tp;
-	__asm("mv %0, tp" : "=r"(__tp));
-	return __tp;
-}
-
-/*
- * On RISCV, since displacements are signed 12-bit values, the TCB Pointer
- * is biased by sizeof(tcb) so that first thread datum can be addressed by
- * -sizeof(tcb).
- */
-
-#define	TLS_TP_OFFSET	0x0
-#define	TLS_TCB_ALIGN	16
-#define	TLS_DTV_OFFSET	0x800
-__CTASSERT(TLS_TP_OFFSET + sizeof(struct tls_tcb) < 0x800);
-
-static __inline void *
-__lwp_gettcb_fast(void)
-{
-	void *__tcb;
-
-	__asm __volatile(
-		"addi %[__tcb], tp, %[__offset]"
-	    :	[__tcb] "=r" (__tcb)
-	    :	[__offset] "n" (-(TLS_TP_OFFSET + sizeof(struct tls_tcb))));
-
-	return __tcb;
-}
-
-static __inline void
-__lwp_settcb(void *__tcb)
-{
-	__asm __volatile(
-		"addi tp, %[__tcb], %[__offset]"
-	    :
-	    :	[__tcb] "r" (__tcb),
-		[__offset] "n" (TLS_TP_OFFSET + sizeof(struct tls_tcb)));
-}
-
-#endif /* _RTLD_SOURCE || _LIBC_SOURCE || __LIBPTHREAD_SOURCE__ */
-
 #endif /* !_RISCV_MCONTEXT_H_ */

Index: src/sys/arch/sh3/include/Makefile
diff -u src/sys/arch/sh3/include/Makefile:1.29 src/sys/arch/sh3/include/Makefile:1.30
--- src/sys/arch/sh3/include/Makefile:1.29	Thu Jul 12 06:46:47 2018
+++ src/sys/arch/sh3/include/Makefile	Sun Nov  3 17:24:23 2024
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.29 2018/07/12 10:46:47 maxv Exp $
+#	$NetBSD: Makefile,v 1.30 2024/11/03 22:24:23 christos Exp $
 
 INCSDIR= /usr/include/sh3
 
@@ -11,7 +11,7 @@ INCS=	ansi.h aout_machdep.h asm.h \
 	ieee.h ieeefp.h \
 	int_const.h int_fmtio.h int_limits.h int_mwgwtypes.h int_types.h \
 	intr.h \
-	limits.h lock.h \
+	limits.h lock.h lwp.h \
 	math.h mcontext.h mutex.h \
 	param.h pcb.h pmap.h proc.h profile.h psl.h \
 	pte.h ptrace.h \

Index: src/sys/arch/sh3/include/mcontext.h
diff -u src/sys/arch/sh3/include/mcontext.h:1.13 src/sys/arch/sh3/include/mcontext.h:1.14
--- src/sys/arch/sh3/include/mcontext.h:1.13	Fri May 17 20:37:41 2024
+++ src/sys/arch/sh3/include/mcontext.h	Sun Nov  3 17:24:23 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: mcontext.h,v 1.13 2024/05/18 00:37:41 thorpej Exp $	*/
+/*	$NetBSD: mcontext.h,v 1.14 2024/11/03 22:24:23 christos Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -95,22 +95,4 @@ typedef struct {
 #define	_UC_CLRSTACK		_UC_MD_BIT17
 #define	_UC_TLSBASE		_UC_MD_BIT19
 
-#if defined(_RTLD_SOURCE) || defined(_LIBC_SOURCE) || \
-    defined(__LIBPTHREAD_SOURCE__)
-#include <sys/tls.h>
-
-__BEGIN_DECLS
-static __inline void *
-__lwp_getprivate_fast(void)
-{
-	register void *__gbr;
-
-	__asm volatile("stc gbr, %0" : "=r" (__gbr));
-
-	return __gbr;
-}
-__END_DECLS
-
-#endif
-
 #endif /* !_SH3_MCONTEXT_H_ */

Index: src/sys/arch/sparc/include/Makefile
diff -u src/sys/arch/sparc/include/Makefile:1.36 src/sys/arch/sparc/include/Makefile:1.37
--- src/sys/arch/sparc/include/Makefile:1.36	Sun May 17 09:49:37 2020
+++ src/sys/arch/sparc/include/Makefile	Sun Nov  3 17:24:23 2024
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.36 2020/05/17 13:49:37 ad Exp $
+#	$NetBSD: Makefile,v 1.37 2024/11/03 22:24:23 christos Exp $
 
 INCSDIR= /usr/include/sparc
 
@@ -12,7 +12,7 @@ INCS=	ansi.h aout_machdep.h apmvar.h asm
 	int_const.h int_fmtio.h int_limits.h int_mwgwtypes.h int_types.h \
 	intr.h \
 	kbd.h kbio.h kcore.h \
-	limits.h lock.h \
+	limits.h lock.h lwp.h \
 	math.h mcontext.h mutex.h \
 	oldmon.h openpromio.h \
 	param.h pcb.h pmap.h proc.h profile.h psl.h pte.h ptrace.h \

Index: src/sys/arch/sparc/include/mcontext.h
diff -u src/sys/arch/sparc/include/mcontext.h:1.19 src/sys/arch/sparc/include/mcontext.h:1.20
--- src/sys/arch/sparc/include/mcontext.h:1.19	Fri May 17 20:37:41 2024
+++ src/sys/arch/sparc/include/mcontext.h	Sun Nov  3 17:24:23 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: mcontext.h,v 1.19 2024/05/18 00:37:41 thorpej Exp $	*/
+/*	$NetBSD: mcontext.h,v 1.20 2024/11/03 22:24:23 christos Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -161,22 +161,4 @@ do {									\
 	(uc)->uc_mcontext.__gregs[_REG_nPC] = (pc) + 4;			\
 } while (/*CONSTCOND*/0)
 
-#if defined(_RTLD_SOURCE) || defined(_LIBC_SOURCE) || \
-    defined(__LIBPTHREAD_SOURCE__)
-#include <sys/tls.h>
-
-__BEGIN_DECLS
-static __inline void *
-__lwp_getprivate_fast(void)
-{
-	register void *__tmp;
-
-	__asm volatile("mov %%g7, %0" : "=r" (__tmp));
-
-	return __tmp;
-}
-__END_DECLS
-
-#endif
-
 #endif	/* !_SPARC_MCONTEXT_H_ */

Index: src/sys/arch/vax/include/Makefile
diff -u src/sys/arch/vax/include/Makefile:1.30 src/sys/arch/vax/include/Makefile:1.31
--- src/sys/arch/vax/include/Makefile:1.30	Sat Dec 29 06:30:12 2018
+++ src/sys/arch/vax/include/Makefile	Sun Nov  3 17:24:23 2024
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.30 2018/12/29 11:30:12 maxv Exp $
+#	$NetBSD: Makefile,v 1.31 2024/11/03 22:24:23 christos Exp $
 
 INCSDIR= /usr/include/vax
 
@@ -11,7 +11,7 @@ INCS=	ansi.h aout_machdep.h asm.h \
 	int_const.h int_fmtio.h int_limits.h int_mwgwtypes.h int_types.h \
 	ioa.h \
 	ka410.h ka420.h ka43.h ka630.h ka650.h ka750.h ka820.h \
-	leds.h lcgreg.h limits.h lock.h \
+	leds.h lcgreg.h limits.h lock.h lwp.h \
 	macros.h math.h mcontext.h mtpr.h mutex.h \
 	nexus.h param.h pcb.h pmap.h \
 	proc.h profile.h psl.h pte.h ptrace.h \

Index: src/sys/arch/vax/include/mcontext.h
diff -u src/sys/arch/vax/include/mcontext.h:1.12 src/sys/arch/vax/include/mcontext.h:1.13
--- src/sys/arch/vax/include/mcontext.h:1.12	Fri May 17 20:37:41 2024
+++ src/sys/arch/vax/include/mcontext.h	Sun Nov  3 17:24:23 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: mcontext.h,v 1.12 2024/05/18 00:37:41 thorpej Exp $	*/
+/*	$NetBSD: mcontext.h,v 1.13 2024/11/03 22:24:23 christos Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -76,21 +76,4 @@ typedef struct {
 
 #define	_UC_MACHINE_SET_PC(uc, pc)	_UC_MACHINE_PC(uc) = (pc)
 
-#if defined(_RTLD_SOURCE) || defined(_LIBC_SOURCE) || \
-    defined(__LIBPTHREAD_SOURCE__)
-#include <sys/tls.h>
-#include <sys/syscall.h>
-
-__BEGIN_DECLS
-static __inline void *
-__lwp_getprivate_fast(void)
-{
-	register void *tcb __asm("r0");
-	__asm("chmk %0" :: "i"(SYS__lwp_getprivate) : "r0");
-	return tcb;
-}
-__END_DECLS
-
-#endif
-
 #endif	/* !_VAX_MCONTEXT_H_ */

Added files:

Index: src/sys/arch/alpha/include/lwp.h
diff -u /dev/null src/sys/arch/alpha/include/lwp.h:1.1
--- /dev/null	Sun Nov  3 17:24:24 2024
+++ src/sys/arch/alpha/include/lwp.h	Sun Nov  3 17:24:21 2024
@@ -0,0 +1,52 @@
+/*	$NetBSD: lwp.h,v 1.1 2024/11/03 22:24:21 christos Exp $	*/
+
+/*-
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Klaus Klein.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _ALPHA_LWP_H_
+#define _ALPHA_LWP_H_
+
+#include <sys/tls.h>
+
+__BEGIN_DECLS
+static __inline void *
+__lwp_getprivate_fast(void)
+{
+	register void *__tmp __asm("$0");
+
+	__asm volatile("call_pal %1 # PAL_rdunique"
+		: "=r" (__tmp)
+		: "i" (0x009e /* PAL_rdunique */));
+
+	return __tmp;
+}
+__END_DECLS
+
+
+#endif	/* !_ALPHA_LWP_H_ */

Index: src/sys/arch/amd64/include/lwp.h
diff -u /dev/null src/sys/arch/amd64/include/lwp.h:1.1
--- /dev/null	Sun Nov  3 17:24:24 2024
+++ src/sys/arch/amd64/include/lwp.h	Sun Nov  3 17:24:21 2024
@@ -0,0 +1,53 @@
+/*	$NetBSD: lwp.h,v 1.1 2024/11/03 22:24:21 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1999 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Klaus Klein.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _AMD64_LWP_H_
+#define _AMD64_LWP_H_
+
+#include <sys/tls.h>
+
+__BEGIN_DECLS
+static __inline void *
+__lwp_getprivate_fast(void)
+{
+	void *__tmp;
+
+#ifdef _LP64
+	__asm volatile("movq %%fs:0, %0" : "=r" (__tmp));
+#else
+	__asm volatile("movl %%gs:0, %0" : "=r" (__tmp));
+#endif
+
+	return __tmp;
+}
+__END_DECLS
+
+#endif	/* !_AMD64_LWP_H_ */

Index: src/sys/arch/arm/include/lwp.h
diff -u /dev/null src/sys/arch/arm/include/lwp.h:1.1
--- /dev/null	Sun Nov  3 17:24:24 2024
+++ src/sys/arch/arm/include/lwp.h	Sun Nov  3 17:24:21 2024
@@ -0,0 +1,79 @@
+/*	$NetBSD: lwp.h,v 1.1 2024/11/03 22:24:21 christos Exp $	*/
+
+/*-
+ * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Klaus Klein and by Jason R. Thorpe of Wasabi Systems, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _ARM_LWP_H_
+#define _ARM_LWP_H_
+
+#include <sys/stdint.h>
+#include <sys/tls.h>
+
+#if defined(__aarch64__)
+
+__BEGIN_DECLS
+static __inline void *
+__lwp_getprivate_fast(void)
+{
+	void *__tpidr;
+	__asm __volatile("mrs\t%0, tpidr_el0" : "=r"(__tpidr));
+	return __tpidr;
+}
+__END_DECLS
+
+#elif defined(__arm__)
+
+#if defined(__thumb__) && !defined(_ARM_ARCH_T2)
+#include <arm/eabi.h>
+#endif
+
+__BEGIN_DECLS
+static __inline void *
+__lwp_getprivate_fast(void)
+{
+#if !defined(__thumb__) || defined(_ARM_ARCH_T2)
+	void *rv;
+	__asm("mrc p15, 0, %0, c13, c0, 3" : "=r"(rv));
+	if (__predict_true(rv))
+		return rv;
+	/*
+	 * Some ARM cores are broken and don't raise an undefined fault when an
+	 * unrecogized mrc instruction is encountered, but just return zero.
+	 * To do deal with that, if we get a zero we (re-)fetch the value using
+	 * syscall.
+	 */
+	return _lwp_getprivate();
+#else
+	return __aeabi_read_tp();
+#endif /* !__thumb__ || _ARM_ARCH_T2 */
+}
+__END_DECLS
+#endif
+
+#endif	/* !_ARM_LWP_H_ */

Index: src/sys/arch/hppa/include/lwp.h
diff -u /dev/null src/sys/arch/hppa/include/lwp.h:1.1
--- /dev/null	Sun Nov  3 17:24:24 2024
+++ src/sys/arch/hppa/include/lwp.h	Sun Nov  3 17:24:21 2024
@@ -0,0 +1,22 @@
+/*	$NetBSD: lwp.h,v 1.1 2024/11/03 22:24:21 christos Exp $	*/
+
+#ifndef _HPPA_LWP_H_
+#define	_HPPA_LWP_H_
+
+#include <sys/tls.h>
+
+__BEGIN_DECLS
+static __inline void *
+__lwp_getprivate_fast(void)
+{
+	register void *__tmp;
+
+	__asm volatile("mfctl\t27 /* CR_TLS */, %0" : "=r" (__tmp));
+
+	return __tmp;
+}
+__END_DECLS
+
+#endif
+
+#endif /* _HPPA_LWP_H_ */

Index: src/sys/arch/i386/include/lwp.h
diff -u /dev/null src/sys/arch/i386/include/lwp.h:1.1
--- /dev/null	Sun Nov  3 17:24:24 2024
+++ src/sys/arch/i386/include/lwp.h	Sun Nov  3 17:24:21 2024
@@ -0,0 +1,49 @@
+/*	$NetBSD: lwp.h,v 1.1 2024/11/03 22:24:21 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1999 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Klaus Klein.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _I386_LWP_H_
+#define _I386_LWP_H_
+
+#include <sys/tls.h>
+
+__BEGIN_DECLS
+static __inline void *
+__lwp_getprivate_fast(void)
+{
+	void *__tmp;
+
+	__asm volatile("movl %%gs:0, %0" : "=r" (__tmp));
+
+	return __tmp;
+}
+__END_DECLS
+
+#endif	/* !_I386_LWP_H_ */

Index: src/sys/arch/ia64/include/lwp.h
diff -u /dev/null src/sys/arch/ia64/include/lwp.h:1.1
--- /dev/null	Sun Nov  3 17:24:24 2024
+++ src/sys/arch/ia64/include/lwp.h	Sun Nov  3 17:24:22 2024
@@ -0,0 +1,49 @@
+/*	$NetBSD: lwp.h,v 1.1 2024/11/03 22:24:22 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1999 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Copyright (c) 1999, 2003 Marcel Moolenaar
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Klaus Klein.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _IA64_LWP_H_
+#define _IA64_LWP_H_
+
+#include <sys/tls.h>
+
+__BEGIN_DECLS
+static __inline void *
+__lwp_getprivate_fast(void)
+{
+	return (void*)0;
+}
+__END_DECLS
+
+#endif	/* !_IA64_LWP_H_ */

Index: src/sys/arch/m68k/include/lwp.h
diff -u /dev/null src/sys/arch/m68k/include/lwp.h:1.2
--- /dev/null	Sun Nov  3 17:24:24 2024
+++ src/sys/arch/m68k/include/lwp.h	Sun Nov  3 17:24:22 2024
@@ -0,0 +1,61 @@
+/*	$NetBSD: lwp.h,v 1.2 2024/11/03 22:24:22 christos Exp $	*/
+
+/*-
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Klaus Klein.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _M68K_LWP_H_
+#define _M68K_LWP_H_
+
+#define	TLS_TP_OFFSET	0x7000
+#define	TLS_DTV_OFFSET	0x8000
+
+#include <sys/tls.h>
+
+__CTASSERT(TLS_TP_OFFSET + sizeof(struct tls_tcb) < 0x8000);
+__CTASSERT(TLS_TP_OFFSET % sizeof(struct tls_tcb) == 0);
+
+__BEGIN_DECLS
+
+static __inline struct tls_tcb *
+__lwp_gettcb_fast(void)
+{
+	unsigned int __tcb = (unsigned int)_lwp_getprivate();
+	return (struct tls_tcb *)(uintptr_t)
+	    (__tcb - TLS_TP_OFFSET - sizeof(struct tls_tcb));
+}
+
+static inline void
+__lwp_settcb(struct tls_tcb *__tcb)
+{
+	__tcb += TLS_TP_OFFSET / sizeof(*__tcb) + 1;
+	_lwp_setprivate(__tcb);
+}
+__END_DECLS
+
+#endif	/* !_M68K_LWP_H_ */

Index: src/sys/arch/mips/include/lwp.h
diff -u /dev/null src/sys/arch/mips/include/lwp.h:1.1
--- /dev/null	Sun Nov  3 17:24:24 2024
+++ src/sys/arch/mips/include/lwp.h	Sun Nov  3 17:24:22 2024
@@ -0,0 +1,84 @@
+/*	$NetBSD: lwp.h,v 1.1 2024/11/03 22:24:22 christos Exp $	*/
+
+/*-
+ * Copyright (c) 1999, 2002 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Klaus Klein, and by Jason R. Thorpe of Wasabi Systems, Inc.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _MIPS_LWP_H_
+#define	_MIPS_LWP_H_
+
+#define	TLS_TP_OFFSET	0x7000
+#define	TLS_DTV_OFFSET	0x8000
+
+#include <sys/tls.h>
+
+__CTASSERT(TLS_TP_OFFSET + sizeof(struct tls_tcb) < 0x8000);
+__CTASSERT(TLS_TP_OFFSET % sizeof(struct tls_tcb) == 0);
+
+__BEGIN_DECLS
+
+static __inline struct tls_tcb *
+__lwp_gettcb_fast(void)
+{
+	struct tls_tcb *__tcb;
+
+	/*
+	 * Only emit a rdhwr $3, $29 so the kernel can quickly emulate it.
+	 */
+	__asm __volatile(
+#if 1
+		// For some reason the syscall is much faster than
+		// emulating rdhwr $3,$29 on a CN50xx
+		"addiu $2,$0,316; syscall; nop; move %[__tcb],$2"
+#else
+		".set push"
+		";.set mips32r2"
+		";.p2align 4"
+		";ssnop"
+		";rdhwr $3,$29"
+		";ssnop"
+		";move %0,$3"
+		";.set pop"
+#endif
+	    : [__tcb]"=r"(__tcb)
+	    :
+	    : "v0", "v1", "a3");
+	return __tcb - (TLS_TP_OFFSET / sizeof(*__tcb) + 1);
+}
+
+void _lwp_setprivate(void *);
+
+static inline void
+__lwp_settcb(struct tls_tcb *__tcb)
+{
+	__tcb += TLS_TP_OFFSET / sizeof(*__tcb) + 1;
+	_lwp_setprivate(__tcb);
+}
+__END_DECLS
+
+#endif	/* _MIPS_LWP_H_ */

Index: src/sys/arch/or1k/include/lwp.h
diff -u /dev/null src/sys/arch/or1k/include/lwp.h:1.1
--- /dev/null	Sun Nov  3 17:24:24 2024
+++ src/sys/arch/or1k/include/lwp.h	Sun Nov  3 17:24:22 2024
@@ -0,0 +1,76 @@
+/* $NetBSD: lwp.h,v 1.1 2024/11/03 22:24:22 christos Exp $ */
+
+/*-
+ * Copyright (c) 2014 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matt Thomas of 3am Software Foundry.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef _OR1K_LWP_H_
+#define _OR1K_LWP_H_
+
+#include <sys/tls.h>
+
+/*
+ * On OpenRISC 1000, since displacements are signed 16-bit values, the TCB
+ * Pointer is biased by 0x7000 + sizeof(tcb) so that first thread datum can be 
+ * addressed by -28672 thereby leaving 60KB available for use as thread data.
+ */
+#define	TLS_TP_OFFSET	0x7000
+#define	TLS_DTV_OFFSET	0x8000
+__CTASSERT(TLS_TP_OFFSET + sizeof(struct tls_tcb) < 0x8000);
+
+static __inline void *
+__lwp_getprivate_fast(void)
+{
+	void *__tp;
+	__asm("l.ori %0,r10,0" : "=r"(__tp));
+	return __tp;
+}
+
+static __inline void *
+__lwp_gettcb_fast(void)
+{
+	void *__tcb;
+
+	__asm __volatile(
+		"l.addi %[__tcb],r10,%[__offset]"
+	    :	[__tcb] "=r" (__tcb)
+	    :	[__offset] "n" (-(TLS_TP_OFFSET + sizeof(struct tls_tcb))));
+
+	return __tcb;
+}
+
+static __inline void
+__lwp_settcb(void *__tcb)
+{
+	__asm __volatile(
+		"l.addi r10,%[__tcb],%[__offset]"
+	    :
+	    :	[__tcb] "r" (__tcb),
+		[__offset] "n" (TLS_TP_OFFSET + sizeof(struct tls_tcb)));
+}
+
+#endif /* !_OR1K_LWP_H_ */

Index: src/sys/arch/powerpc/include/lwp.h
diff -u /dev/null src/sys/arch/powerpc/include/lwp.h:1.1
--- /dev/null	Sun Nov  3 17:24:24 2024
+++ src/sys/arch/powerpc/include/lwp.h	Sun Nov  3 17:24:22 2024
@@ -0,0 +1,75 @@
+/*	$NetBSD: lwp.h,v 1.1 2024/11/03 22:24:22 christos Exp $	*/
+
+/*-
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Klaus Klein.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _POWERPC_LWP_H_
+#define _POWERPC_LWP_H_
+
+#include <sys/tls.h>
+
+/*
+ * On PowerPC, since displacements are signed 16-bit values, the TCB Pointer
+ * is biased by 0x7000 + sizeof(tcb) so that first thread datum can be 
+ * addressed by -28672 thereby leaving 60KB available for use as thread data.
+ */
+#define	TLS_TP_OFFSET	0x7000
+#define	TLS_DTV_OFFSET	0x8000
+__CTASSERT(TLS_TP_OFFSET + sizeof(struct tls_tcb) < 0x8000);
+
+__BEGIN_DECLS
+
+static __inline void *
+__lwp_gettcb_fast(void)
+{
+	void *__tcb;
+
+	__asm __volatile(
+		"addi %[__tcb],%%r2,%[__offset]"
+	    :	[__tcb] "=r" (__tcb)
+	    :	[__offset] "n" (-(TLS_TP_OFFSET + sizeof(struct tls_tcb))));
+
+	return __tcb;
+}
+
+static __inline void
+__lwp_settcb(void *__tcb)
+{
+	__tcb = (uint8_t *)__tcb + TLS_TP_OFFSET + sizeof(struct tls_tcb);
+
+	__asm __volatile(
+		"mr %%r2,%[__tcb]"
+	    :
+	    :	[__tcb] "r" (__tcb));
+
+	_lwp_setprivate(__tcb);
+}
+__END_DECLS
+
+#endif	/* !_POWERPC_LWP_H_ */

Index: src/sys/arch/riscv/include/lwp.h
diff -u /dev/null src/sys/arch/riscv/include/lwp.h:1.1
--- /dev/null	Sun Nov  3 17:24:24 2024
+++ src/sys/arch/riscv/include/lwp.h	Sun Nov  3 17:24:22 2024
@@ -0,0 +1,79 @@
+/* $NetBSD: lwp.h,v 1.1 2024/11/03 22:24:22 christos Exp $ */
+
+/*-
+ * Copyright (c) 2014 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Matt Thomas of 3am Software Foundry.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef _RISCV_LWP_H_
+#define _RISCV_LWP_H_
+
+#include <sys/tls.h>
+
+static __inline void *
+__lwp_getprivate_fast(void)
+{
+	void *__tp;
+	__asm("mv %0, tp" : "=r"(__tp));
+	return __tp;
+}
+
+/*
+ * On RISCV, since displacements are signed 12-bit values, the TCB Pointer
+ * is biased by sizeof(tcb) so that first thread datum can be addressed by
+ * -sizeof(tcb).
+ */
+
+#define	TLS_TP_OFFSET	0x0
+#define	TLS_TCB_ALIGN	16
+#define	TLS_DTV_OFFSET	0x800
+__CTASSERT(TLS_TP_OFFSET + sizeof(struct tls_tcb) < 0x800);
+
+static __inline void *
+__lwp_gettcb_fast(void)
+{
+	void *__tcb;
+
+	__asm __volatile(
+		"addi %[__tcb], tp, %[__offset]"
+	    :	[__tcb] "=r" (__tcb)
+	    :	[__offset] "n" (-(TLS_TP_OFFSET + sizeof(struct tls_tcb))));
+
+	return __tcb;
+}
+
+static __inline void
+__lwp_settcb(void *__tcb)
+{
+	__asm __volatile(
+		"addi tp, %[__tcb], %[__offset]"
+	    :
+	    :	[__tcb] "r" (__tcb),
+		[__offset] "n" (TLS_TP_OFFSET + sizeof(struct tls_tcb)));
+}
+
+
+#endif /* !_RISCV_LWP_H_ */

Index: src/sys/arch/sh3/include/lwp.h
diff -u /dev/null src/sys/arch/sh3/include/lwp.h:1.1
--- /dev/null	Sun Nov  3 17:24:24 2024
+++ src/sys/arch/sh3/include/lwp.h	Sun Nov  3 17:24:23 2024
@@ -0,0 +1,49 @@
+/*	$NetBSD: lwp.h,v 1.1 2024/11/03 22:24:23 christos Exp $	*/
+
+/*-
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Klaus Klein.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SH3_LWP_H_
+#define _SH3_LWP_H_
+
+#include <sys/tls.h>
+
+__BEGIN_DECLS
+static __inline void *
+__lwp_getprivate_fast(void)
+{
+	register void *__gbr;
+
+	__asm volatile("stc gbr, %0" : "=r" (__gbr));
+
+	return __gbr;
+}
+__END_DECLS
+
+#endif /* !_SH3_LWP_H_ */

Index: src/sys/arch/sparc/include/lwp.h
diff -u /dev/null src/sys/arch/sparc/include/lwp.h:1.1
--- /dev/null	Sun Nov  3 17:24:24 2024
+++ src/sys/arch/sparc/include/lwp.h	Sun Nov  3 17:24:23 2024
@@ -0,0 +1,50 @@
+/*	$NetBSD: lwp.h,v 1.1 2024/11/03 22:24:23 christos Exp $	*/
+
+/*-
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Klaus Klein.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _SPARC_LWP_H_
+#define	_SPARC_LWP_H_
+
+#include <sys/tls.h>
+
+__BEGIN_DECLS
+static __inline void *
+__lwp_getprivate_fast(void)
+{
+	register void *__tmp;
+
+	__asm volatile("mov %%g7, %0" : "=r" (__tmp));
+
+	return __tmp;
+}
+__END_DECLS
+
+
+#endif	/* !_SPARC_LWP_H_ */

Index: src/sys/arch/vax/include/lwp.h
diff -u /dev/null src/sys/arch/vax/include/lwp.h:1.1
--- /dev/null	Sun Nov  3 17:24:24 2024
+++ src/sys/arch/vax/include/lwp.h	Sun Nov  3 17:24:23 2024
@@ -0,0 +1,48 @@
+/*	$NetBSD: lwp.h,v 1.1 2024/11/03 22:24:23 christos Exp $	*/
+
+/*-
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Klaus Klein.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _VAX_LWP_H_
+#define _VAX_LWP_H_
+
+#include <sys/tls.h>
+#include <sys/syscall.h>
+
+__BEGIN_DECLS
+static __inline void *
+__lwp_getprivate_fast(void)
+{
+	register void *tcb __asm("r0");
+	__asm("chmk %0" :: "i"(SYS__lwp_getprivate) : "r0");
+	return tcb;
+}
+__END_DECLS
+
+#endif	/* !_VAX_LWP_H_ */

Reply via email to