fenv.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. (c) Copyright 2019 Joel Sherrill <joel@rtems.org
  3. (c) Copyright 2019 Craig Howlang <craig.howland@caci.com>
  4. All rights reserved.
  5. Redistribution and use in source and binary forms, with or without
  6. modification, are permitted provided that the following conditions
  7. are met:
  8. 1. Redistributions of source code must retain the above copyright
  9. notice, this list of conditions and the following disclaimer.
  10. 2. Redistributions in binary form must reproduce the above copyright
  11. notice, this list of conditions and the following disclaimer in the
  12. documentation and/or other materials provided with the distribution.
  13. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  14. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  15. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  16. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  17. HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  18. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  19. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  20. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  21. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  22. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  23. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. */
  25. #ifndef _SYS_FENV_H_
  26. #define _SYS_FENV_H_
  27. /*******************************************************************************
  28. * THIS FILE IS A TEMPLATE, INTENDED TO BE USED AS A STARTING POINT FOR
  29. * TARGET-SPECIFIC FLOATING-POINT IMPLEMENTATIONS. NOTES BELOW HIGHLIGHT THE
  30. * BASICS OF WHAT NEEDS TO BE DEFINED. THE DEFAULT IMPLEMTATION IS
  31. * DEGENERATE, WITH ALL FUNCTIONS RETURNING ERROR AND NO EXCEPTIONS AND NO
  32. * ROUNDING MODES DEFINED (SINCE NONE ARE SUPPORTED).
  33. * THE MACRO VALUES ARE EXAMPLES ONLY, ALTHOUGH TAKEN FROM A WORKING
  34. * IMPLEMENTATION.
  35. * REMOVE THIS NOTICE WHEN COPYING TO A REAL IMPLEMENTATION, REPLACING IT WITH
  36. * ANY TARGET-SPECIFIC NOTES OF INTEREST. THE FENV FUNCTION MAN PAGES POINT TO
  37. * THIS FILE AS A MEANS OF DETERMINING A FUNCTIONAL VS. NON-FUNCTIONAL
  38. * IMPLEMENTATION.
  39. ******************************************************************************/
  40. /*
  41. * The following macros are to be defined if the respective exception is
  42. * supported by the implementation, each with a unique bit mask:
  43. *
  44. * FE_DIVBYZERO
  45. * FE_INEXACT
  46. * FE_INVALID
  47. * FE_OVERFLOW
  48. * FE_UNDERFLOW
  49. *
  50. * Other implementation-specific exceptions may be defined, and must start
  51. * with FE_ followed by a capital letter.
  52. *
  53. * FE_ALL_EXCEPT must be defined as the logical OR of all exceptions.
  54. */
  55. //#define FE_DIVBYZERO 0x00000001
  56. //#define FE_INEXACT 0x00000002
  57. //#define FE_INVALID 0x00000004
  58. //#define FE_OVERFLOW 0x00000008
  59. //#define FE_UNDERFLOW 0x00000010
  60. //#define FE_ALL_EXCEPT \
  61. //(FE_DIVBYZERO|FE_INEXACT|FE_INVALID|FE_OVERFLOW|FE_UNDERFLOW)
  62. #define FE_ALL_EXCEPT 0 /* NONE SUPPORTED IN PLACEHOLDER TEMPLATE */
  63. /*
  64. * The following macros are to be defined if the respective rounding
  65. * direction is supported by the implementation via the fegetround() and
  66. * fesetround() functions, each with a unique positive value.
  67. *
  68. * FE_DOWNWARD
  69. * FE_TONEAREST
  70. * FE_TOWARDZERO
  71. * FE_UPWARD
  72. *
  73. * Other implementation-specific rounding modes may be defined, and must start
  74. * with FE_ followed by a capital letter.
  75. */
  76. //#define FE_DOWNWARD 1
  77. //#define FE_TONEAREST 2
  78. //#define FE_TOWARDZERO 3
  79. //#define FE_UPWARD 4
  80. /*
  81. * The following typedefs are required. These should be defined properly
  82. * to support the architecture specific implementation. See the C and
  83. * POSIX standards for details:
  84. *
  85. * fenv_t
  86. * fexcept_t
  87. */
  88. typedef int fenv_t;
  89. typedef int fexcept_t;
  90. /*
  91. * Lastly, a FE_DFL_ENV macro must be defined, representing a pointer
  92. * to const fenv_t that contains the value of the default floating point
  93. * environment.
  94. *
  95. * NOTE: The extern'ed variable fe_default_env_p is an implementation
  96. * detail of this stub. FE_DFL_ENV must point to an instance of
  97. * fenv_t with the default fenv_t. The format of fenv_t and where
  98. * FE_DFL_ENV is are implementation specific.
  99. */
  100. extern const fenv_t *_fe_dfl_env;
  101. #define FE_DFL_ENV _fe_dfl_env
  102. #endif /* _SYS_FENV_H_ */