test-tgmath-int.c 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /* Test compilation of tgmath macros.
  2. Copyright (C) 2005-2016 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. Contributed by Andreas Jaeger <aj@suse.de>, 2005.
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; if not, see
  15. <http://www.gnu.org/licenses/>. */
  16. #include <math.h>
  17. #include <complex.h>
  18. #include <tgmath.h>
  19. #include <stdio.h>
  20. static int errors = 0;
  21. static void
  22. our_error (const char *c)
  23. {
  24. puts (c);
  25. ++errors;
  26. }
  27. #define CHECK_RET_CONST_TYPE(func, rettype, name) \
  28. if (sizeof (func) != sizeof (rettype)) \
  29. our_error ("Return size of " #name " is " #func" wrong");
  30. #define CHECK_RET_CONST_FLOAT(func, name) \
  31. CHECK_RET_CONST_TYPE (func, float, name)
  32. #define CHECK_RET_CONST_DOUBLE(func, name) \
  33. CHECK_RET_CONST_TYPE (func, double, name)
  34. static int
  35. do_test (void)
  36. {
  37. int i;
  38. float f;
  39. double d;
  40. CHECK_RET_CONST_DOUBLE (sin (i), "sin (i)");
  41. CHECK_RET_CONST_DOUBLE (pow (i, i), "pow (i, i)");
  42. CHECK_RET_CONST_DOUBLE (pow (i, i), "pow (i, i)");
  43. CHECK_RET_CONST_DOUBLE (pow (i, f), "pow (i, f)");
  44. CHECK_RET_CONST_DOUBLE (pow (i, d), "pow (i, d)");
  45. CHECK_RET_CONST_DOUBLE (pow (f, i), "pow (f, i)");
  46. CHECK_RET_CONST_DOUBLE (pow (d, i), "pow (d, i)");
  47. CHECK_RET_CONST_DOUBLE (fma (i, i, i), "fma (i, i, i)");
  48. CHECK_RET_CONST_DOUBLE (fma (f, i, i), "fma (f, i, i)");
  49. CHECK_RET_CONST_DOUBLE (fma (i, f, i), "fma (i, f, i)");
  50. CHECK_RET_CONST_DOUBLE (fma (i, i, f), "fma (i, i, f)");
  51. CHECK_RET_CONST_DOUBLE (fma (d, i, i), "fma (d, i, i)");
  52. CHECK_RET_CONST_DOUBLE (fma (i, d, i), "fma (i, d, i)");
  53. CHECK_RET_CONST_DOUBLE (fma (i, i, d), "fma (i, i, d)");
  54. return errors != 0;
  55. }
  56. #define TEST_FUNCTION do_test ()
  57. #include "../test-skeleton.c"