home *** CD-ROM | disk | FTP | other *** search
/ RISCWORLD 7 / RISCWORLD_VOL7.iso / Software / Issue2 / SDL.ARC / !unixlib / source / clib / h / fenv < prev    next >
Encoding:
Text File  |  2004-09-05  |  3.3 KB  |  114 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /usr/local/cvsroot/gccsdk/unixlib/source/clib/fenv.h,v $
  4.  * $Date: 2004/04/12 13:03:37 $
  5.  * $Revision: 1.4 $
  6.  * $State: Exp $
  7.  * $Author: nick $
  8.  *
  9.  ***************************************************************************/
  10.  
  11. #ifndef __FENV_H
  12. #define __FENV_H 1
  13.  
  14. #ifndef __UNIXLIB_FEATURES_H
  15. #include <unixlib/features.h>
  16. #endif
  17.  
  18. __BEGIN_DECLS
  19.  
  20. /* Define bits representing exceptions in the FPU status word.  */
  21.  
  22. /* Invalid operation.  */
  23. #define FE_INVALID 1
  24. /* Division by zero.  */
  25. #define FE_DIVBYZERO 2
  26. /* Result not representable due to overflow.  */
  27. #define FE_OVERFLOW 4
  28. /* Result not representable due to underflow.  */
  29. #define FE_UNDERFLOW 8
  30.  
  31. /* Amount to shift by to convert an exception to a mask bit.  */
  32. #define FE_EXCEPT_SHIFT 16
  33.  
  34. /* All supported exceptions.  */
  35. #define FE_ALL_EXCEPT \
  36.     (FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW | FE_UNDERFLOW)
  37.  
  38. /* The ARM FPU only supports round-to-nearest.  The other rounding modes
  39.    have to be encoded in the instruction.  */
  40. #define FE_TONEAREST 0
  41.  
  42. /* Type representing exception flags. */
  43. typedef unsigned long fexcept_t;
  44.  
  45. /* Type representing floating-point environment.  */
  46. typedef struct
  47.   {
  48.     unsigned long cw;
  49.   }
  50. fenv_t;
  51.  
  52. /* If the default argument is used we use this value.  */
  53. #define FE_DFL_ENV ((fenv_t *) -1l)
  54. #define _FPU_RESERVED 0xfff0e0f0  /* These bits are reserved.  */
  55. #define _FPU_DEFAULT  0x00000000 /* Default value.  */
  56.  
  57. /* Type of the control word.  */
  58. typedef unsigned int fpu_control_t;
  59.  
  60. /* Floating-point exception handling.  */
  61.  
  62. /* Clear the supported exceptions represented by EXCEPTS.  */
  63. extern void feclearexcept (int __excepts) __THROW;
  64.  
  65. /* Store implementation-defined representation of the exception flags
  66.    indicated by EXCEPTS in the object pointed to by FLAGP.  */
  67. extern void fegetexceptflag (fexcept_t *__flagp, int __excepts) __THROW;
  68.  
  69. /* Raise the supported exceptions represented by EXCEPTS.  */
  70. extern void feraiseexcept (int __excepts) __THROW;
  71.  
  72. /* Set complete status for exceptions indicated by EXCEPTS according to
  73.    the representation in the object pointed to by FLAGP.  */
  74. extern void fesetexceptflag (const fexcept_t *__flagp, int __excepts)
  75.      __THROW;
  76.  
  77. /* Determine which of subset of the exceptions specified by EXCEPTS are
  78.    currently set.  */
  79. extern int fetestexcept (int __excepts) __THROW;
  80.  
  81.  
  82. /* Rounding control.  */
  83.  
  84. /* Get current rounding direction.  */
  85. extern int fegetround (void) __THROW;
  86.  
  87. /* Establish the rounding direction represented by ROUND.  */
  88. extern int fesetround (int __rounding_direction) __THROW;
  89.  
  90.  
  91. /* Floating-point environment.  */
  92.  
  93. /* Store the current floating-point environment in the object pointed
  94.    to by ENVP.  */
  95. extern void fegetenv (fenv_t *__envp) __THROW;
  96.  
  97. /* Save the current environment in the object pointed to by ENVP, clear
  98.    exception flags and install a non-stop mode (if available) for all
  99.    exceptions.  */
  100. extern int feholdexcept (fenv_t *__envp) __THROW;
  101.  
  102. /* Establish the floating-point environment represented by the object
  103.    pointed to by ENVP.  */
  104. extern void fesetenv (const fenv_t *__envp) __THROW;
  105.  
  106. /* Save current exceptions in temporary storage, install environment
  107.    represented by object pointed to by ENVP and raise exceptions
  108.    according to saved exceptions.  */
  109. extern void feupdateenv (const fenv_t *__envp) __THROW;
  110.  
  111. __END_DECLS
  112.  
  113. #endif
  114.