aboutsummaryrefslogtreecommitdiff
path: root/src/libtrace/__setfpucw.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libtrace/__setfpucw.c')
-rw-r--r--src/libtrace/__setfpucw.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/libtrace/__setfpucw.c b/src/libtrace/__setfpucw.c
new file mode 100644
index 0000000..5b48c37
--- /dev/null
+++ b/src/libtrace/__setfpucw.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 1993 Olaf Flebbe
+This file is part of the Linux C Library.
+*/
+
+#include <fpu_control.h>
+
+extern void init_libtrace(void);
+
+void
+__setfpucw(unsigned short fpu_control)
+{
+ volatile unsigned short cw;
+
+ init_libtrace();
+
+ /* If user supplied _fpu_control, use it ! */
+ if (!fpu_control)
+ {
+ /* use linux defaults */
+ fpu_control = _FPU_DEFAULT;
+ }
+ /* Get Control Word */
+ __asm__ volatile ("fnstcw %0" : "=m" (cw) : );
+
+ /* mask in */
+ cw &= _FPU_RESERVED;
+ cw = cw | (fpu_control & ~_FPU_RESERVED);
+
+ /* set cw */
+ __asm__ volatile ("fldcw %0" :: "m" (cw));
+}