/math/test-tgmath-int.c

https://github.com/nitinkamble/x32-glibc · C · 71 lines · 42 code · 10 blank · 19 comment · 3 complexity · 341343218688bada06ad3092caafb79b MD5 · raw file

  1. /* Test compilation of tgmath macros.
  2. Copyright (C) 2005 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, write to the Free
  15. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  16. 02111-1307 USA. */
  17. #include <math.h>
  18. #include <complex.h>
  19. #include <tgmath.h>
  20. #include <stdio.h>
  21. static int errors = 0;
  22. static void
  23. our_error (const char *c)
  24. {
  25. puts (c);
  26. ++errors;
  27. }
  28. #define CHECK_RET_CONST_TYPE(func, rettype, name) \
  29. if (sizeof (func) != sizeof (rettype)) \
  30. our_error ("Return size of " #name " is " #func" wrong");
  31. #define CHECK_RET_CONST_FLOAT(func, name) \
  32. CHECK_RET_CONST_TYPE (func, float, name)
  33. #define CHECK_RET_CONST_DOUBLE(func, name) \
  34. CHECK_RET_CONST_TYPE (func, double, name)
  35. static int
  36. do_test (void)
  37. {
  38. int i;
  39. float f;
  40. double d;
  41. CHECK_RET_CONST_DOUBLE (sin (i), "sin (i)");
  42. CHECK_RET_CONST_DOUBLE (pow (i, i), "pow (i, i)");
  43. CHECK_RET_CONST_DOUBLE (pow (i, i), "pow (i, i)");
  44. CHECK_RET_CONST_DOUBLE (pow (i, f), "pow (i, f)");
  45. CHECK_RET_CONST_DOUBLE (pow (i, d), "pow (i, d)");
  46. CHECK_RET_CONST_DOUBLE (pow (f, i), "pow (f, i)");
  47. CHECK_RET_CONST_DOUBLE (pow (d, i), "pow (d, i)");
  48. CHECK_RET_CONST_DOUBLE (fma (i, i, i), "fma (i, i, i)");
  49. CHECK_RET_CONST_DOUBLE (fma (f, i, i), "fma (f, i, i)");
  50. CHECK_RET_CONST_DOUBLE (fma (i, f, i), "fma (i, f, i)");
  51. CHECK_RET_CONST_DOUBLE (fma (i, i, f), "fma (i, i, f)");
  52. CHECK_RET_CONST_DOUBLE (fma (d, i, i), "fma (d, i, i)");
  53. CHECK_RET_CONST_DOUBLE (fma (i, d, i), "fma (i, d, i)");
  54. CHECK_RET_CONST_DOUBLE (fma (i, i, d), "fma (i, i, d)");
  55. return errors != 0;
  56. }
  57. #define TEST_FUNCTION do_test ()
  58. #include "../test-skeleton.c"