aboutsummaryrefslogtreecommitdiff
path: root/src/libtrace/__setfpucw.c
blob: 5b48c37c1853d86899d50ffbb1411ddca8db9b54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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));
}