math-tests.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /* Configuration for math tests. Generic version.
  2. Copyright (C) 2013-2016 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <http://www.gnu.org/licenses/>. */
  15. /* Indicate whether to run tests involving sNaN values for the float, double,
  16. and long double C data types, respectively. All are run unless
  17. overridden. */
  18. #ifndef SNAN_TESTS_float
  19. # define SNAN_TESTS_float 1
  20. #endif
  21. #ifndef SNAN_TESTS_double
  22. # define SNAN_TESTS_double 1
  23. #endif
  24. #ifndef SNAN_TESTS_long_double
  25. # define SNAN_TESTS_long_double 1
  26. #endif
  27. /* Return nonzero value if to run tests involving sNaN values for X. */
  28. #define SNAN_TESTS(x) \
  29. (sizeof (x) == sizeof (float) ? SNAN_TESTS_float \
  30. : sizeof (x) == sizeof (double) ? SNAN_TESTS_double \
  31. : SNAN_TESTS_long_double)
  32. /* Indicate whether to run tests involving type casts of sNaN values. These
  33. are run unless overridden. */
  34. #ifndef SNAN_TESTS_TYPE_CAST
  35. # define SNAN_TESTS_TYPE_CAST 1
  36. #endif
  37. /* Indicate whether to run tests involving a given rounding mode for a
  38. given floating-point type, given that fesetround succeeds for that
  39. mode. All are run if fesetround succeeds unless overridden. */
  40. #ifndef ROUNDING_TESTS_float
  41. # define ROUNDING_TESTS_float(MODE) 1
  42. #endif
  43. #ifndef ROUNDING_TESTS_double
  44. # define ROUNDING_TESTS_double(MODE) 1
  45. #endif
  46. #ifndef ROUNDING_TESTS_long_double
  47. # define ROUNDING_TESTS_long_double(MODE) 1
  48. #endif
  49. #define ROUNDING_TESTS(TYPE, MODE) \
  50. (sizeof (TYPE) == sizeof (float) ? ROUNDING_TESTS_float (MODE) \
  51. : sizeof (TYPE) == sizeof (double) ? ROUNDING_TESTS_double (MODE) \
  52. : ROUNDING_TESTS_long_double (MODE))
  53. /* Indicate whether to run tests of floating-point exceptions for a
  54. given floating-point type, given that the exception macros are
  55. defined. All are run unless overridden. */
  56. #ifndef EXCEPTION_TESTS_float
  57. # define EXCEPTION_TESTS_float 1
  58. #endif
  59. #ifndef EXCEPTION_TESTS_double
  60. # define EXCEPTION_TESTS_double 1
  61. #endif
  62. #ifndef EXCEPTION_TESTS_long_double
  63. # define EXCEPTION_TESTS_long_double 1
  64. #endif
  65. #define EXCEPTION_TESTS(TYPE) \
  66. (sizeof (TYPE) == sizeof (float) ? EXCEPTION_TESTS_float \
  67. : sizeof (TYPE) == sizeof (double) ? EXCEPTION_TESTS_double \
  68. : EXCEPTION_TESTS_long_double)
  69. /* Indicate whether the given exception trap(s) can be enabled
  70. in feenableexcept. If non-zero, the traps are always supported.
  71. If zero, traps may or may not be supported depending on the
  72. target (this can be determined by checking the return value
  73. of feenableexcept). This enables skipping of tests which use
  74. traps. By default traps are supported unless overridden. */
  75. #ifndef EXCEPTION_ENABLE_SUPPORTED
  76. # define EXCEPTION_ENABLE_SUPPORTED(EXCEPT) \
  77. (EXCEPTION_TESTS_float || EXCEPTION_TESTS_double)
  78. #endif