fenv.h 4.5 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, see
  13. <http://www.gnu.org/licenses/>. */
  14. /*
  15. * ISO C99 7.6: Floating-point environment <fenv.h>
  16. */
  17. #ifndef _FENV_H
  18. #define _FENV_H 1
  19. #include <features.h>
  20. /* Get the architecture dependend definitions. The following definitions
  21. are expected to be done:
  22. fenv_t type for object representing an entire floating-point
  23. environment
  24. FE_DFL_ENV macro of type pointer to fenv_t to be used as the argument
  25. to functions taking an argument of type fenv_t; in this
  26. case the default environment will be used
  27. fexcept_t type for object representing the floating-point exception
  28. flags including status associated with the flags
  29. The following macros are defined iff the implementation supports this
  30. kind of exception.
  31. FE_INEXACT inexact result
  32. FE_DIVBYZERO division by zero
  33. FE_UNDERFLOW result not representable due to underflow
  34. FE_OVERFLOW result not representable due to overflow
  35. FE_INVALID invalid operation
  36. FE_ALL_EXCEPT bitwise OR of all supported exceptions
  37. The next macros are defined iff the appropriate rounding mode is
  38. supported by the implementation.
  39. FE_TONEAREST round to nearest
  40. FE_UPWARD round toward +Inf
  41. FE_DOWNWARD round toward -Inf
  42. FE_TOWARDZERO round toward 0
  43. */
  44. #include <bits/fenv.h>
  45. __BEGIN_DECLS
  46. /* Floating-point exception handling. */
  47. /* Clear the supported exceptions represented by EXCEPTS. */
  48. extern int feclearexcept (int __excepts) __THROW;
  49. /* Store implementation-defined representation of the exception flags
  50. indicated by EXCEPTS in the object pointed to by FLAGP. */
  51. extern int fegetexceptflag (fexcept_t *__flagp, int __excepts) __THROW;
  52. /* Raise the supported exceptions represented by EXCEPTS. */
  53. extern int feraiseexcept (int __excepts) __THROW;
  54. /* Set complete status for exceptions indicated by EXCEPTS according to
  55. the representation in the object pointed to by FLAGP. */
  56. extern int fesetexceptflag (const fexcept_t *__flagp, int __excepts) __THROW;
  57. /* Determine which of subset of the exceptions specified by EXCEPTS are
  58. currently set. */
  59. extern int fetestexcept (int __excepts) __THROW;
  60. /* Rounding control. */
  61. /* Get current rounding direction. */
  62. extern int fegetround (void) __THROW;
  63. /* Establish the rounding direction represented by ROUND. */
  64. extern int fesetround (int __rounding_direction) __THROW;
  65. /* Floating-point environment. */
  66. /* Store the current floating-point environment in the object pointed
  67. to by ENVP. */
  68. extern int fegetenv (fenv_t *__envp) __THROW;
  69. /* Save the current environment in the object pointed to by ENVP, clear
  70. exception flags and install a non-stop mode (if available) for all
  71. exceptions. */
  72. extern int feholdexcept (fenv_t *__envp) __THROW;
  73. /* Establish the floating-point environment represented by the object
  74. pointed to by ENVP. */
  75. extern int fesetenv (const fenv_t *__envp) __THROW;
  76. /* Save current exceptions in temporary storage, install environment
  77. represented by object pointed to by ENVP and raise exceptions
  78. according to saved exceptions. */
  79. extern int feupdateenv (const fenv_t *__envp) __THROW;
  80. /* Include optimization. */
  81. #ifdef __OPTIMIZE__
  82. # include <bits/fenvinline.h>
  83. #endif
  84. #ifdef __USE_GNU
  85. /* Enable individual exceptions. Will not enable more exceptions than
  86. EXCEPTS specifies. Returns the previous enabled exceptions if all
  87. exceptions are successfully set, otherwise returns -1. */
  88. extern int feenableexcept (int __excepts) __THROW;
  89. /* Disable individual exceptions. Will not disable more exceptions than
  90. EXCEPTS specifies. Returns the previous enabled exceptions if all
  91. exceptions are successfully disabled, otherwise returns -1. */
  92. extern int fedisableexcept (int __excepts) __THROW;
  93. /* Return enabled exceptions. */
  94. extern int fegetexcept (void) __THROW;
  95. #endif
  96. __END_DECLS
  97. #endif /* fenv.h */