fenv.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /* $OpenBSD: fenv.h,v 1.3 2011/05/25 21:46:49 martynas Exp $ */
  2. /* $NetBSD: fenv.h,v 1.1.2.2 2011/02/08 16:19:41 bouyer Exp $ */
  3. /*-
  4. * Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  17. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  18. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  19. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  20. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  21. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  22. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  23. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  24. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  25. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  26. * SUCH DAMAGE.
  27. *
  28. * $FreeBSD$
  29. */
  30. #ifndef _SPARC_FENV_H_
  31. #define _SPARC_FENV_H_
  32. /*
  33. * Each symbol representing a floating point exception expands to an integer
  34. * constant expression with values, such that bitwise-inclusive ORs of _all
  35. * combinations_ of the constants result in distinct values.
  36. *
  37. * We use such values that allow direct bitwise operations on FPU registers.
  38. */
  39. #define FE_INEXACT 0x020
  40. #define FE_DIVBYZERO 0x040
  41. #define FE_UNDERFLOW 0x080
  42. #define FE_OVERFLOW 0x100
  43. #define FE_INVALID 0x200
  44. /*
  45. * The following symbol is simply the bitwise-inclusive OR of all floating-point
  46. * exception constants defined above.
  47. */
  48. #define FE_ALL_EXCEPT (FE_INEXACT | FE_DIVBYZERO | FE_UNDERFLOW | \
  49. FE_OVERFLOW | FE_INVALID)
  50. #define _MASK_SHIFT 18
  51. /*
  52. * Each symbol representing the rounding direction, expands to an integer
  53. * constant expression whose value is distinct non-negative value.
  54. *
  55. * We use such values that allow direct bitwise operations on FPU registers.
  56. */
  57. #define FE_TONEAREST 0x0
  58. #define FE_TOWARDZERO 0x1
  59. #define FE_UPWARD 0x2
  60. #define FE_DOWNWARD 0x3
  61. /*
  62. * The following symbol is simply the bitwise-inclusive OR of all floating-point
  63. * rounding direction constants defined above.
  64. */
  65. #define _ROUND_MASK (FE_TONEAREST | FE_TOWARDZERO | FE_UPWARD | \
  66. FE_DOWNWARD)
  67. #define _ROUND_SHIFT 30
  68. /*
  69. * fenv_t represents the entire floating-point environment.
  70. */
  71. typedef unsigned long fenv_t;
  72. /*
  73. * The following constant represents the default floating-point environment
  74. * (that is, the one installed at program startup) and has type pointer to
  75. * const-qualified fenv_t.
  76. *
  77. * It can be used as an argument to the functions within the <fenv.h> header
  78. * that manage the floating-point environment, namely fesetenv() and
  79. * feupdateenv().
  80. */
  81. __BEGIN_DECLS
  82. extern fenv_t __fe_dfl_env;
  83. __END_DECLS
  84. #define FE_DFL_ENV ((const fenv_t *)&__fe_dfl_env)
  85. /*
  86. * fexcept_t represents the floating-point status flags collectively, including
  87. * any status the implementation associates with the flags.
  88. *
  89. * A floating-point status flag is a system variable whose value is set (but
  90. * never cleared) when a floating-point exception is raised, which occurs as a
  91. * side effect of exceptional floating-point arithmetic to provide auxiliary
  92. * information.
  93. *
  94. * A floating-point control mode is a system variable whose value may be set by
  95. * the user to affect the subsequent behavior of floating-point arithmetic.
  96. */
  97. typedef unsigned long fexcept_t;
  98. #endif /* !_SPARC_FENV_H_ */