tgmath.h 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * ISO C Standard: 7.22 Type-generic math <tgmath.h>
  3. */
  4. #ifndef _TGMATH_H
  5. #define _TGMATH_H
  6. #include <math.h>
  7. #ifndef __cplusplus
  8. #define __tgmath_real(x, F) \
  9. _Generic ((x), float: F##f, long double: F##l, default: F)(x)
  10. #define __tgmath_real_2_1(x, y, F) \
  11. _Generic ((x), float: F##f, long double: F##l, default: F)(x, y)
  12. #define __tgmath_real_2(x, y, F) \
  13. _Generic ((x)+(y), float: F##f, long double: F##l, default: F)(x, y)
  14. #define __tgmath_real_3_2(x, y, z, F) \
  15. _Generic ((x)+(y), float: F##f, long double: F##l, default: F)(x, y, z)
  16. #define __tgmath_real_3(x, y, z, F) \
  17. _Generic ((x)+(y)+(z), float: F##f, long double: F##l, default: F)(x, y, z)
  18. /* Functions defined in both <math.h> and <complex.h> (7.22p4) */
  19. #define acos(z) __tgmath_real(z, acos)
  20. #define asin(z) __tgmath_real(z, asin)
  21. #define atan(z) __tgmath_real(z, atan)
  22. #define acosh(z) __tgmath_real(z, acosh)
  23. #define asinh(z) __tgmath_real(z, asinh)
  24. #define atanh(z) __tgmath_real(z, atanh)
  25. #define cos(z) __tgmath_real(z, cos)
  26. #define sin(z) __tgmath_real(z, sin)
  27. #define tan(z) __tgmath_real(z, tan)
  28. #define cosh(z) __tgmath_real(z, cosh)
  29. #define sinh(z) __tgmath_real(z, sinh)
  30. #define tanh(z) __tgmath_real(z, tanh)
  31. #define exp(z) __tgmath_real(z, exp)
  32. #define log(z) __tgmath_real(z, log)
  33. #define pow(z1,z2) __tgmath_real_2(z1, z2, pow)
  34. #define sqrt(z) __tgmath_real(z, sqrt)
  35. #define fabs(z) __tgmath_real(z, fabs)
  36. /* Functions defined in <math.h> only (7.22p5) */
  37. #define atan2(x,y) __tgmath_real_2(x, y, atan2)
  38. #define cbrt(x) __tgmath_real(x, cbrt)
  39. #define ceil(x) __tgmath_real(x, ceil)
  40. #define copysign(x,y) __tgmath_real_2(x, y, copysign)
  41. #define erf(x) __tgmath_real(x, erf)
  42. #define erfc(x) __tgmath_real(x, erfc)
  43. #define exp2(x) __tgmath_real(x, exp2)
  44. #define expm1(x) __tgmath_real(x, expm1)
  45. #define fdim(x,y) __tgmath_real_2(x, y, fdim)
  46. #define floor(x) __tgmath_real(x, floor)
  47. #define fma(x,y,z) __tgmath_real_3(x, y, z, fma)
  48. #define fmax(x,y) __tgmath_real_2(x, y, fmax)
  49. #define fmin(x,y) __tgmath_real_2(x, y, fmin)
  50. #define fmod(x,y) __tgmath_real_2(x, y, fmod)
  51. #define frexp(x,y) __tgmath_real_2_1(x, y, frexp)
  52. #define hypot(x,y) __tgmath_real_2(x, y, hypot)
  53. #define ilogb(x) __tgmath_real(x, ilogb)
  54. #define ldexp(x,y) __tgmath_real_2_1(x, y, ldexp)
  55. #define lgamma(x) __tgmath_real(x, lgamma)
  56. #define llrint(x) __tgmath_real(x, llrint)
  57. #define llround(x) __tgmath_real(x, llround)
  58. #define log10(x) __tgmath_real(x, log10)
  59. #define log1p(x) __tgmath_real(x, log1p)
  60. #define log2(x) __tgmath_real(x, log2)
  61. #define logb(x) __tgmath_real(x, logb)
  62. #define lrint(x) __tgmath_real(x, lrint)
  63. #define lround(x) __tgmath_real(x, lround)
  64. #define nearbyint(x) __tgmath_real(x, nearbyint)
  65. #define nextafter(x,y) __tgmath_real_2(x, y, nextafter)
  66. #define nexttoward(x,y) __tgmath_real_2(x, y, nexttoward)
  67. #define remainder(x,y) __tgmath_real_2(x, y, remainder)
  68. #define remquo(x,y,z) __tgmath_real_3_2(x, y, z, remquo)
  69. #define rint(x) __tgmath_real(x, rint)
  70. #define round(x) __tgmath_real(x, round)
  71. #define scalbln(x,y) __tgmath_real_2_1(x, y, scalbln)
  72. #define scalbn(x,y) __tgmath_real_2_1(x, y, scalbn)
  73. #define tgamma(x) __tgmath_real(x, tgamma)
  74. #define trunc(x) __tgmath_real(x, trunc)
  75. /* Functions defined in <complex.h> only (7.22p6)
  76. #define carg(z) __tgmath_cplx_only(z, carg)
  77. #define cimag(z) __tgmath_cplx_only(z, cimag)
  78. #define conj(z) __tgmath_cplx_only(z, conj)
  79. #define cproj(z) __tgmath_cplx_only(z, cproj)
  80. #define creal(z) __tgmath_cplx_only(z, creal)
  81. */
  82. #endif /* __cplusplus */
  83. #endif /* _TGMATH_H */