complex.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /* Copyright (C) 1997, 1998, 1999, 2000, 2006 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <http://www.gnu.org/licenses/>. */
  14. /*
  15. * ISO C99: 7.3 Complex arithmetic <complex.h>
  16. */
  17. #ifndef _COMPLEX_H
  18. #define _COMPLEX_H 1
  19. #include <features.h>
  20. /* Get general and ISO C99 specific information. */
  21. #include <bits/mathdef.h>
  22. __BEGIN_DECLS
  23. /* We might need to add support for more compilers here. But since ISO
  24. C99 is out hopefully all maintained compilers will soon provide the data
  25. types `float complex' and `double complex'. */
  26. #if __GNUC_PREREQ (2, 7) && !__GNUC_PREREQ (2, 97)
  27. # define _Complex __complex__
  28. #endif
  29. #define complex _Complex
  30. /* Narrowest imaginary unit. This depends on the floating-point
  31. evaluation method.
  32. XXX This probably has to go into a gcc related file. */
  33. #define _Complex_I (__extension__ 1.0iF)
  34. /* Another more descriptive name is `I'.
  35. XXX Once we have the imaginary support switch this to _Imaginary_I. */
  36. #undef I
  37. #define I _Complex_I
  38. /* The file <bits/cmathcalls.h> contains the prototypes for all the
  39. actual math functions. These macros are used for those prototypes,
  40. so we can easily declare each function as both `name' and `__name',
  41. and can declare the float versions `namef' and `__namef'. */
  42. #define __MATHCALL(function, args) \
  43. __MATHDECL(_Mdouble_complex_,function, args)
  44. #define __MATHDECL(type, function, args) \
  45. __MATHDECL_1(type, function, args); \
  46. __MATHDECL_1(type, __CONCAT(__,function), args)
  47. #define __MATHDECL_1(type, function, args) \
  48. extern type __MATH_PRECNAME(function) args __THROW
  49. #define _Mdouble_ double
  50. #define __MATH_PRECNAME(name) name
  51. #include <bits/cmathcalls.h>
  52. #undef _Mdouble_
  53. #undef __MATH_PRECNAME
  54. /* Now the float versions. */
  55. #ifndef _Mfloat_
  56. # define _Mfloat_ float
  57. #endif
  58. #define _Mdouble_ _Mfloat_
  59. #ifdef __STDC__
  60. # define __MATH_PRECNAME(name) name##f
  61. #else
  62. # define __MATH_PRECNAME(name) name/**/f
  63. #endif
  64. #include <bits/cmathcalls.h>
  65. #undef _Mdouble_
  66. #undef _Mfloat_
  67. #undef __MATH_PRECNAME
  68. /* And the long double versions. It is non-critical to define them
  69. here unconditionally since `long double' is required in ISO C99. */
  70. #if (__STDC__ - 0 || __GNUC__ - 0) \
  71. && defined __UCLIBC_HAS_LONG_DOUBLE_MATH__
  72. # ifndef _Mlong_double_
  73. # define _Mlong_double_ long double
  74. # endif
  75. # define _Mdouble_ _Mlong_double_
  76. # ifdef __STDC__
  77. # define __MATH_PRECNAME(name) name##l
  78. # else
  79. # define __MATH_PRECNAME(name) name/**/l
  80. # endif
  81. # include <bits/cmathcalls.h>
  82. #endif
  83. #undef _Mdouble_
  84. #undef _Mlong_double_
  85. #undef __MATH_PRECNAME
  86. #undef __MATHDECL_1
  87. #undef __MATHDECL
  88. #undef __MATHCALL
  89. __END_DECLS
  90. #endif /* complex.h */