home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / D / LIBC / LIBC-4.6 / LIBC-4 / libc-linux / sysdeps / linux / i386 / __setfpucw.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-09  |  1.0 KB  |  37 lines

  1. /* Copyright (C) 1993  Olaf Flebbe
  2. This file is part of the Linux C Library.
  3.  
  4. The Linux C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. License, or (at your option) any later version.
  8.  
  9. The Linux C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. Library General Public License for more details.  */
  13.  
  14. #include <fpu_control.h>
  15.  
  16. void
  17. __setfpucw(unsigned short fpu_control)
  18. {
  19.   volatile unsigned short cw;
  20.  
  21.   /* If user supplied _fpu_control, use it ! */
  22.   if (!fpu_control)
  23.   { 
  24.     /* use linux defaults */
  25.     fpu_control = _FPU_DEFAULT;
  26.   }
  27.   /* Get Control Word */
  28.   __asm__ volatile ("fnstcw %0" : "=m" (cw) : );
  29.   
  30.   /* mask in */
  31.   cw &= _FPU_RESERVED;
  32.   cw = cw | (fpu_control & ~_FPU_RESERVED);
  33.  
  34.   /* set cw */
  35.   __asm__ volatile ("fldcw %0" :: "m" (cw));
  36. }
  37.