fenv.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /* Copyright (C) 1997, 1999, 2000 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, write to the Free
  13. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  14. 02111-1307 USA. */
  15. /*
  16. * ISO C99 7.6: Floating-point environment <fenv.h>
  17. */
  18. #ifndef _FENV_H
  19. #define _FENV_H 1
  20. #include <features.h>
  21. /* Get the architecture dependend definitions. The following definitions
  22. are expected to be done:
  23. fenv_t type for object representing an entire floating-point
  24. environment
  25. FE_DFL_ENV macro of type pointer to fenv_t to be used as the argument
  26. to functions taking an argument of type fenv_t; in this
  27. case the default environment will be used
  28. fexcept_t type for object representing the floating-point exception
  29. flags including status associated with the flags
  30. The following macros are defined iff the implementation supports this
  31. kind of exception.
  32. FE_INEXACT inexact result
  33. FE_DIVBYZERO division by zero
  34. FE_UNDERFLOW result not representable due to underflow
  35. FE_OVERFLOW result not representable due to overflow
  36. FE_INVALID invalid operation
  37. FE_ALL_EXCEPT bitwise OR of all supported exceptions
  38. The next macros are defined iff the appropriate rounding mode is
  39. supported by the implementation.
  40. FE_TONEAREST round to nearest
  41. FE_UPWARD round toward +Inf
  42. FE_DOWNWARD round toward -Inf
  43. FE_TOWARDZERO round toward 0
  44. */
  45. #include <bits/fenv.h>
  46. __BEGIN_DECLS
  47. /* Floating-point exception handling. */
  48. /* Clear the supported exceptions represented by EXCEPTS. */
  49. extern int feclearexcept (int __excepts) __THROW;
  50. /* Store implementation-defined representation of the exception flags
  51. indicated by EXCEPTS in the object pointed to by FLAGP. */
  52. extern int fegetexceptflag (fexcept_t *__flagp, int __excepts) __THROW;
  53. /* Raise the supported exceptions represented by EXCEPTS. */
  54. extern int feraiseexcept (int __excepts) __THROW;
  55. /* Set complete status for exceptions indicated by EXCEPTS according to
  56. the representation in the object pointed to by FLAGP. */
  57. extern int fesetexceptflag (__const fexcept_t *__flagp, int __excepts) __THROW;
  58. /* Determine which of subset of the exceptions specified by EXCEPTS are
  59. currently set. */
  60. extern int fetestexcept (int __excepts) __THROW;
  61. /* Rounding control. */
  62. /* Get current rounding direction. */
  63. extern int fegetround (void) __THROW;
  64. /* Establish the rounding direction represented by ROUND. */
  65. extern int fesetround (int __rounding_direction) __THROW;
  66. /* Floating-point environment. */
  67. /* Store the current floating-point environment in the object pointed
  68. to by ENVP. */
  69. extern int fegetenv (fenv_t *__envp) __THROW;
  70. /* Save the current environment in the object pointed to by ENVP, clear
  71. exception flags and install a non-stop mode (if available) for all
  72. exceptions. */
  73. extern int feholdexcept (fenv_t *__envp) __THROW;
  74. /* Establish the floating-point environment represented by the object
  75. pointed to by ENVP. */
  76. extern int fesetenv (__const fenv_t *__envp) __THROW;
  77. /* Save current exceptions in temporary storage, install environment
  78. represented by object pointed to by ENVP and raise exceptions
  79. according to saved exceptions. */
  80. extern int feupdateenv (__const fenv_t *__envp) __THROW;
  81. /* Include optimization. */
  82. #ifdef __OPTIMIZE__
  83. # include <bits/fenvinline.h>
  84. #endif
  85. #ifdef __USE_GNU
  86. /* Enable individual exceptions. Will not enable more exceptions than
  87. EXCEPTS specifies. Returns the previous enabled exceptions if all
  88. exceptions are successfully set, otherwise returns -1. */
  89. extern int feenableexcept (int __excepts) __THROW;
  90. /* Disable individual exceptions. Will not disable more exceptions than
  91. EXCEPTS specifies. Returns the previous enabled exceptions if all
  92. exceptions are successfully disabled, otherwise returns -1. */
  93. extern int fedisableexcept (int __excepts) __THROW;
  94. /* Return enabled exceptions. */
  95. extern int fegetexcept (void) __THROW;
  96. #endif
  97. __END_DECLS
  98. #endif /* fenv.h */