summaryrefslogtreecommitdiffstats
path: root/lib/libpthread/arch/sh/uthread_machdep_asm.S
diff options
context:
space:
mode:
authormiod <miod@openbsd.org>2007-03-02 06:11:52 +0000
committermiod <miod@openbsd.org>2007-03-02 06:11:52 +0000
commit243b5df446d5f4ce83bb376b1240a8a96ea22b23 (patch)
treedd88f5cc1fce930b7242a301dc74fdfff077b32c /lib/libpthread/arch/sh/uthread_machdep_asm.S
parentSync rcsnum.c with OpenCVS, from Charles Longeau. (diff)
downloadwireguard-openbsd-243b5df446d5f4ce83bb376b1240a8a96ea22b23.tar.xz
wireguard-openbsd-243b5df446d5f4ce83bb376b1240a8a96ea22b23.zip
Move landisk to hardware floating point. At the moment the FPU context is
always saved upon context switches, as FPU registers are heavily used for long long computations (don't ask). Gcc default to -m4. Credits to drahn@ otto@ and deraadt@ for feedback and help testing. Upgrade procedure if you don't want to use the damn snapshots: - build and install new kernel, reboot off it - build new gcc, do not install it yet - make includes - install new gcc - build and install lib/csu and lib/libc - make build
Diffstat (limited to 'lib/libpthread/arch/sh/uthread_machdep_asm.S')
-rw-r--r--lib/libpthread/arch/sh/uthread_machdep_asm.S56
1 files changed, 49 insertions, 7 deletions
diff --git a/lib/libpthread/arch/sh/uthread_machdep_asm.S b/lib/libpthread/arch/sh/uthread_machdep_asm.S
index 702d5c04434..13b7111a692 100644
--- a/lib/libpthread/arch/sh/uthread_machdep_asm.S
+++ b/lib/libpthread/arch/sh/uthread_machdep_asm.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: uthread_machdep_asm.S,v 1.1 2007/02/19 21:03:50 miod Exp $ */
+/* $OpenBSD: uthread_machdep_asm.S,v 1.2 2007/03/02 06:11:54 miod Exp $ */
/*
* Copyright (c) 2007 Miodrag Vallat.
@@ -27,7 +27,26 @@ ENTRY(_thread_machdep_switch)
* On entry: r4 = new, r5 = oldsave
*/
- /* save caller-saved context on stack */
+ /*
+ * Save current context on the stack.
+ */
+#if defined(__SH4__) && !defined(__SH4_NOFPU__)
+ sts.l fpscr, @-r15
+ mov #0, r1
+ sts.l fpul, @-r15
+ lds r1, fpscr
+ fmov.s fr15, @-r15 /* note that we can't do double stores... */
+ fmov.s fr14, @-r15 /* ...as we don't control stack alignment. */
+ fmov.s fr13, @-r15
+ fmov.s fr12, @-r15
+ frchg
+ fmov.s fr15, @-r15
+ fmov.s fr14, @-r15
+ fmov.s fr13, @-r15
+ fmov.s fr12, @-r15
+#endif
+ sts.l mach, @-r15
+ sts.l macl, @-r15
mov.l r8, @-r15
mov.l r9, @-r15
mov.l r10, @-r15
@@ -37,13 +56,15 @@ ENTRY(_thread_machdep_switch)
mov.l r14, @-r15
sts.l pr, @-r15
- /* save old stack */
+ /*
+ * Switch stacks.
+ */
mov.l r15, @r5
-
- /* switch stacks */
mov.l @r4, r15
- /* restore new context */
+ /*
+ * Restore new context.
+ */
lds.l @r15+, pr
mov.l @r15+, r14
mov.l @r15+, r13
@@ -51,5 +72,26 @@ ENTRY(_thread_machdep_switch)
mov.l @r15+, r11
mov.l @r15+, r10
mov.l @r15+, r9
+ mov.l @r15+, r8
+ lds.l @r15+, macl
+#if defined(__SH4__) && !defined(__SH4_NOFPU__)
+ mov #0, r1
+ lds.l @r15+, mach
+ lds r1, fpscr
+ frchg
+ fmov.s @r15+, fr12
+ fmov.s @r15+, fr13
+ fmov.s @r15+, fr14
+ fmov.s @r15+, fr15
+ frchg
+ fmov.s @r15+, fr12
+ fmov.s @r15+, fr13
+ fmov.s @r15+, fr14
+ fmov.s @r15+, fr15
+ lds.l @r15+, fpul
+ rts
+ lds.l @r15+, fpscr
+#else
rts
- mov.l @r15+, r8
+ lds.l @r15+, mach
+#endif