home *** CD-ROM | disk | FTP | other *** search
/ RISCWORLD 7 / RISCWORLD_VOL7.iso / Software / Issue6 / SDL.ZIP / !gcc / include / unixlib / h / fpu_control < prev    next >
Encoding:
Text File  |  2006-09-17  |  3.9 KB  |  107 lines

  1. /* FPU control word definitions.  ARM version.
  2.    Copyright (C) 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
  3.    This file is part of the GNU C Library.
  4.  
  5.    The GNU C Library is free software; you can redistribute it and/or
  6.    modify it under the terms of the GNU Lesser General Public
  7.    License as published by the Free Software Foundation; either
  8.    version 2.1 of the License, or (at your option) any later version.
  9.  
  10.    The GNU C Library is distributed in the hope that it will be useful,
  11.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.    Lesser General Public License for more details.
  14.  
  15.    You should have received a copy of the GNU Lesser General Public
  16.    License along with the GNU C Library; if not, write to the Free
  17.    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  18.    02111-1307 USA.  */
  19.  
  20. #ifndef __FPU_CONTROL_H
  21. #define __FPU_CONTROL_H
  22.  
  23. /* We have a slight terminology confusion here.  On the ARM, the register
  24.  * we're interested in is actually the FPU status word - the FPU control
  25.  * word is something different (which is implementation-defined and only
  26.  * accessible from supervisor mode.)
  27.  *
  28.  * The FPSR looks like this:
  29.  *
  30.  *     31-24        23-16          15-8              7-0
  31.  * | system ID | trap enable | system control | exception flags |
  32.  *
  33.  * We ignore the system ID bits; for interest's sake they are:
  34.  *
  35.  *  0000    "old" FPE
  36.  *  1000    FPPC hardware
  37.  *  0001    FPE 400
  38.  *  1001    FPA hardware
  39.  *
  40.  * The trap enable and exception flags are both structured like this:
  41.  *
  42.  *     7 - 5     4     3     2     1     0
  43.  * | reserved | INX | UFL | OFL | DVZ | IVO |
  44.  *
  45.  * where a `1' bit in the enable byte means that the trap can occur, and
  46.  * a `1' bit in the flags byte means the exception has occurred.
  47.  *
  48.  * The exceptions are:
  49.  *
  50.  *  IVO - invalid operation
  51.  *  DVZ - divide by zero
  52.  *  OFL - overflow
  53.  *  UFL - underflow
  54.  *  INX - inexact (do not use; implementations differ)
  55.  *
  56.  * The system control byte looks like this:
  57.  *
  58.  *     7-5      4    3    2    1    0
  59.  * | reserved | AC | EP | SO | NE | ND |
  60.  *
  61.  * where the bits mean
  62.  *
  63.  *  ND - no denormalised numbers (force them all to zero)
  64.  *  NE - enable NaN exceptions
  65.  *  SO - synchronous operation
  66.  *  EP - use expanded packed-decimal format
  67.  *  AC - use alternate definition for C flag on compare operations
  68.  */
  69.  
  70. /* masking of interrupts */
  71. #define _FPU_MASK_IM    0x00010000    /* invalid operation */
  72. #define _FPU_MASK_ZM    0x00020000    /* divide by zero */
  73. #define _FPU_MASK_OM    0x00040000    /* overflow */
  74. #define _FPU_MASK_UM    0x00080000    /* underflow */
  75. #define _FPU_MASK_PM    0x00100000    /* inexact */
  76. #define _FPU_MASK_DM    0x00000000    /* denormalized operation */
  77.  
  78. /* The system id bytes cannot be changed.
  79.    Only the bottom 5 bits in the trap enable byte can be changed.
  80.    Only the bottom 5 bits in the system control byte can be changed.
  81.    Only the bottom 5 bits in the exception flags are used.
  82.    The exception flags are set by the fpu, but can be zeroed by the user. */
  83. #define _FPU_RESERVED    0xffe0e0e0    /* These bits are reserved.  */
  84.  
  85. /* The fdlibm code requires strict IEEE double precision arithmetic,
  86.    no interrupts for exceptions, rounding to nearest.  Changing the
  87.    rounding mode will break long double I/O.  Turn on the AC bit,
  88.    the compiler generates code that assumes it is on.  */
  89. #define _FPU_DEFAULT    0x00001000    /* Default value.  */
  90. #define _FPU_IEEE    0x001f1000    /* Default + exceptions enabled. */
  91.  
  92. /* Type of the control word.  */
  93. typedef unsigned int fpu_control_t;
  94.  
  95. /* Floating point status register access */
  96. extern unsigned int __unixlib_get_fpstatus (void);
  97. extern void __unixlib_set_fpstatus (unsigned int status);
  98.  
  99. /* Macros for accessing the hardware control word.  */
  100. #define _FPU_GETCW(cw) cw = __unixlib_get_fpstatus ()
  101. #define _FPU_SETCW(cw) __unixlib_set_fpstatus (cw)
  102.  
  103. /* Default control word set at startup.  */
  104. extern fpu_control_t __fpu_control;
  105.  
  106. #endif /* _FPU_CONTROL_H */
  107.