summaryrefslogtreecommitdiffstats
path: root/lib/libpthread
diff options
context:
space:
mode:
authormarc <marc@openbsd.org>2003-01-24 20:58:23 +0000
committermarc <marc@openbsd.org>2003-01-24 20:58:23 +0000
commite32b89e515ec9b160a1e0616ae11243384a78d24 (patch)
tree4a51e9f2e8da2823a885c1524c26e5e9b55f6aab /lib/libpthread
parentChanged: - Am. Eng. -> Br. Eng. (diff)
downloadwireguard-openbsd-e32b89e515ec9b160a1e0616ae11243384a78d24.tar.xz
wireguard-openbsd-e32b89e515ec9b160a1e0616ae11243384a78d24.zip
save i386 fpu state
Diffstat (limited to 'lib/libpthread')
-rw-r--r--lib/libpthread/arch/i386/uthread_machdep.c35
-rw-r--r--lib/libpthread/arch/i386/uthread_machdep.h6
2 files changed, 24 insertions, 17 deletions
diff --git a/lib/libpthread/arch/i386/uthread_machdep.c b/lib/libpthread/arch/i386/uthread_machdep.c
index 2b0847b3804..f516eebcbc0 100644
--- a/lib/libpthread/arch/i386/uthread_machdep.c
+++ b/lib/libpthread/arch/i386/uthread_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uthread_machdep.c,v 1.2 2001/03/13 00:05:51 d Exp $ */
+/* $OpenBSD: uthread_machdep.c,v 1.3 2003/01/24 20:58:23 marc Exp $ */
/* David Leonard, <d@csee.uq.edu.au>. Public domain. */
/*
@@ -36,11 +36,8 @@ struct frame {
* structure that can be later switched to.
*/
void
-_thread_machdep_init(statep, base, len, entry)
- struct _machdep_state* statep;
- void *base;
- int len;
- void (*entry)(void);
+_thread_machdep_init(struct _machdep_state* statep, void *base, int len,
+ void (*entry)(void))
{
struct frame *f;
@@ -58,23 +55,33 @@ _thread_machdep_init(statep, base, len, entry)
f->fr_eip = (int)entry;
statep->esp = (int)f;
+
+ _thread_machdep_save_float_state(statep);
}
+/*
+ * Floating point save restore copied from code in npx.c
+ * (without really understanding what it does).
+ */
+#define fldcw(addr) __asm("fldcw %0" : : "m" (*addr))
+#define fnsave(addr) __asm("fnsave %0" : "=m" (*addr))
+#define frstor(addr) __asm("frstor %0" : : "m" (*addr))
+#define fwait() __asm("fwait")
+
void
-_thread_machdep_save_float_state(ms)
- struct _machdep_state *ms;
+_thread_machdep_save_float_state(struct _machdep_state *ms)
{
- char *fdata = (char *)&ms->fpreg;
+ struct save87 *addr = &ms->fpreg;
- __asm__("fsave %0"::"m" (*fdata));
+ fnsave(addr);
+ fwait();
}
void
-_thread_machdep_restore_float_state(ms)
- struct _machdep_state *ms;
+_thread_machdep_restore_float_state(struct _machdep_state *ms)
{
- char *fdata = (char *)&ms->fpreg;
+ struct save87 *addr = &ms->fpreg;
- __asm__("frstor %0"::"m" (*fdata));
+ frstor(addr);
}
diff --git a/lib/libpthread/arch/i386/uthread_machdep.h b/lib/libpthread/arch/i386/uthread_machdep.h
index 22d48624d0d..f0f13ce7710 100644
--- a/lib/libpthread/arch/i386/uthread_machdep.h
+++ b/lib/libpthread/arch/i386/uthread_machdep.h
@@ -1,10 +1,10 @@
-/* $OpenBSD: uthread_machdep.h,v 1.7 2000/10/04 05:55:34 d Exp $ */
+/* $OpenBSD: uthread_machdep.h,v 1.8 2003/01/24 20:58:23 marc Exp $ */
/* David Leonard, <d@csee.uq.edu.au>. Public domain. */
-#include <machine/reg.h>
+#include <machine/npx.h>
struct _machdep_state {
int esp;
- struct fpreg fpreg;
+ struct save87 fpreg;
};