glibc (2.38)

(root)/
include/
complex.h
       1  /* Copyright (C) 1997-2023 Free Software Foundation, Inc.
       2     This file is part of the GNU C Library.
       3  
       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  
       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  
      14     You should have received a copy of the GNU Lesser General Public
      15     License along with the GNU C Library; if not, see
      16     <https://www.gnu.org/licenses/>.  */
      17  
      18  /*
      19   *	ISO C99:  7.3 Complex arithmetic	<complex.h>
      20   */
      21  
      22  #ifndef _COMPLEX_H
      23  #define _COMPLEX_H	1
      24  
      25  #define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
      26  #include <bits/libc-header-start.h>
      27  
      28  /* Get general and ISO C99 specific information.  */
      29  #include <bits/mathdef.h>
      30  
      31  /* Gather machine-dependent _FloatN type support.  */
      32  #include <bits/floatn.h>
      33  
      34  __BEGIN_DECLS
      35  
      36  /* We might need to add support for more compilers here.  But since ISO
      37     C99 is out hopefully all maintained compilers will soon provide the data
      38     types `float complex' and `double complex'.  */
      39  #if __GNUC_PREREQ (2, 7) && !__GNUC_PREREQ (2, 97)
      40  # define _Complex __complex__
      41  #endif
      42  
      43  #define complex		_Complex
      44  
      45  /* Narrowest imaginary unit.  This depends on the floating-point
      46     evaluation method.
      47     XXX This probably has to go into a gcc related file.  */
      48  #define _Complex_I	(__extension__ 1.0iF)
      49  
      50  /* Another more descriptive name is `I'.
      51     XXX Once we have the imaginary support switch this to _Imaginary_I.  */
      52  #undef I
      53  #define I _Complex_I
      54  
      55  #if defined __USE_ISOC11 && __GNUC_PREREQ (4, 7)
      56  /* Macros to expand into expression of specified complex type.  */
      57  # define CMPLX(x, y) __builtin_complex ((double) (x), (double) (y))
      58  # define CMPLXF(x, y) __builtin_complex ((float) (x), (float) (y))
      59  # define CMPLXL(x, y) __builtin_complex ((long double) (x), (long double) (y))
      60  #endif
      61  
      62  #if __HAVE_FLOAT16 && __GLIBC_USE (IEC_60559_TYPES_EXT)
      63  # define CMPLXF16(x, y) __builtin_complex ((_Float16) (x), (_Float16) (y))
      64  #endif
      65  
      66  #if __HAVE_FLOAT32 && __GLIBC_USE (IEC_60559_TYPES_EXT)
      67  # define CMPLXF32(x, y) __builtin_complex ((_Float32) (x), (_Float32) (y))
      68  #endif
      69  
      70  #if __HAVE_FLOAT64 && __GLIBC_USE (IEC_60559_TYPES_EXT)
      71  # define CMPLXF64(x, y) __builtin_complex ((_Float64) (x), (_Float64) (y))
      72  #endif
      73  
      74  #if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)
      75  # define CMPLXF128(x, y) __builtin_complex ((_Float128) (x), (_Float128) (y))
      76  #endif
      77  
      78  #if __HAVE_FLOAT32X && __GLIBC_USE (IEC_60559_TYPES_EXT)
      79  # define CMPLXF32X(x, y) __builtin_complex ((_Float32x) (x), (_Float32x) (y))
      80  #endif
      81  
      82  #if __HAVE_FLOAT64X && __GLIBC_USE (IEC_60559_TYPES_EXT)
      83  # define CMPLXF64X(x, y) __builtin_complex ((_Float64x) (x), (_Float64x) (y))
      84  #endif
      85  
      86  #if __HAVE_FLOAT128X && __GLIBC_USE (IEC_60559_TYPES_EXT)
      87  # define CMPLXF128X(x, y)					\
      88    __builtin_complex ((_Float128x) (x), (_Float128x) (y))
      89  #endif
      90  
      91  /* The file <bits/cmathcalls.h> contains the prototypes for all the
      92     actual math functions.  These macros are used for those prototypes,
      93     so we can easily declare each function as both `name' and `__name',
      94     and can declare the float versions `namef' and `__namef'.  */
      95  
      96  #define __MATHCALL(function, args)	\
      97    __MATHDECL (_Mdouble_complex_,function, args)
      98  #define __MATHDECL_IMPL(type, function, args) \
      99    __MATHDECL_1(type, function, args); \
     100    __MATHDECL_1(type, __CONCAT(__,function), args)
     101  #define __MATHDECL(type, function, args) \
     102    __MATHDECL_IMPL(type, function, args)
     103  #define __MATHDECL_1_IMPL(type, function, args) \
     104    extern type __MATH_PRECNAME(function) args __THROW
     105  #define __MATHDECL_1(type, function, args) \
     106    __MATHDECL_1_IMPL(type, function, args)
     107  
     108  #define _Mdouble_ 		double
     109  #define __MATH_PRECNAME(name)	name
     110  #include <bits/cmathcalls.h>
     111  #undef	_Mdouble_
     112  #undef	__MATH_PRECNAME
     113  
     114  /* Now the float versions.  */
     115  #define _Mdouble_ 		float
     116  #define __MATH_PRECNAME(name)	name##f
     117  #include <bits/cmathcalls.h>
     118  #undef	_Mdouble_
     119  #undef	__MATH_PRECNAME
     120  
     121  /* And the long double versions.  It is non-critical to define them
     122     here unconditionally since `long double' is required in ISO C99.  */
     123  #if !(defined __NO_LONG_DOUBLE_MATH && defined _LIBC)	\
     124      || defined __LDBL_COMPAT
     125  # ifdef __LDBL_COMPAT
     126  #  undef __MATHDECL_1
     127  #  define __MATHDECL_1(type, function, args) \
     128    extern type __REDIRECT_NTH(__MATH_PRECNAME(function), args, function)
     129  # elif __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1
     130  #  undef __MATHDECL_1
     131  #  undef __MATHDECL
     132  #  define __REDIR_TO(function) \
     133    __ ## function ## ieee128
     134  #  define __MATHDECL_1(type, function, alias, args) \
     135    extern type __REDIRECT_NTH(__MATH_PRECNAME(function), args, alias)
     136  #define __MATHDECL(type, function, args) \
     137    __MATHDECL_1(type, function, __REDIR_TO(function), args); \
     138    __MATHDECL_1(type, __CONCAT(__,function), __REDIR_TO(function), args)
     139  # endif
     140  
     141  # define _Mdouble_ 		long double
     142  # define __MATH_PRECNAME(name)	name##l
     143  # include <bits/cmathcalls.h>
     144  # if defined __LDBL_COMPAT \
     145       || __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1
     146  #  undef __REDIR_TO
     147  #  undef __MATHDECL_1
     148  #  undef __MATHDECL
     149  #define __MATHDECL(type, function, args) \
     150    __MATHDECL_IMPL(type, function, args)
     151  #  define __MATHDECL_1(type, function, args) \
     152    __MATHDECL_1_IMPL(type, function, args)
     153  # endif
     154  #endif
     155  #undef	_Mdouble_
     156  #undef	__MATH_PRECNAME
     157  
     158  #if (__HAVE_DISTINCT_FLOAT16 || (__HAVE_FLOAT16 && !defined _LIBC)) \
     159       && __GLIBC_USE (IEC_60559_TYPES_EXT)
     160  # undef _Mdouble_complex_
     161  # define _Mdouble_complex_	__CFLOAT16
     162  # define _Mdouble_		_Float16
     163  # define __MATH_PRECNAME(name)	name##f16
     164  # include <bits/cmathcalls.h>
     165  # undef _Mdouble_
     166  # undef __MATH_PRECNAME
     167  # undef _Mdouble_complex_
     168  #endif
     169  
     170  #if (__HAVE_DISTINCT_FLOAT32 || (__HAVE_FLOAT32 && !defined _LIBC)) \
     171       && __GLIBC_USE (IEC_60559_TYPES_EXT)
     172  # undef _Mdouble_complex_
     173  # define _Mdouble_complex_	__CFLOAT32
     174  # define _Mdouble_		_Float32
     175  # define __MATH_PRECNAME(name)	name##f32
     176  # include <bits/cmathcalls.h>
     177  # undef _Mdouble_
     178  # undef __MATH_PRECNAME
     179  # undef _Mdouble_complex_
     180  #endif
     181  
     182  #if (__HAVE_DISTINCT_FLOAT64 || (__HAVE_FLOAT64 && !defined _LIBC)) \
     183       && __GLIBC_USE (IEC_60559_TYPES_EXT)
     184  # undef _Mdouble_complex_
     185  # define _Mdouble_complex_	__CFLOAT64
     186  # define _Mdouble_		_Float64
     187  # define __MATH_PRECNAME(name)	name##f64
     188  # include <bits/cmathcalls.h>
     189  # undef _Mdouble_
     190  # undef __MATH_PRECNAME
     191  # undef _Mdouble_complex_
     192  #endif
     193  
     194  #if (__HAVE_DISTINCT_FLOAT128 || (__HAVE_FLOAT128 && !defined _LIBC)) \
     195       && __GLIBC_USE (IEC_60559_TYPES_EXT)
     196  # undef _Mdouble_complex_
     197  # define _Mdouble_complex_	__CFLOAT128
     198  # define _Mdouble_		_Float128
     199  # define __MATH_PRECNAME(name)	name##f128
     200  # include <bits/cmathcalls.h>
     201  # undef _Mdouble_
     202  # undef __MATH_PRECNAME
     203  # undef _Mdouble_complex_
     204  #endif
     205  
     206  #if (__HAVE_DISTINCT_FLOAT32X || (__HAVE_FLOAT32X && !defined _LIBC)) \
     207       && __GLIBC_USE (IEC_60559_TYPES_EXT)
     208  # undef _Mdouble_complex_
     209  # define _Mdouble_complex_	__CFLOAT32X
     210  # define _Mdouble_		_Float32x
     211  # define __MATH_PRECNAME(name)	name##f32x
     212  # include <bits/cmathcalls.h>
     213  # undef _Mdouble_
     214  # undef __MATH_PRECNAME
     215  # undef _Mdouble_complex_
     216  #endif
     217  
     218  #if (__HAVE_DISTINCT_FLOAT64X || (__HAVE_FLOAT64X && !defined _LIBC)) \
     219       && __GLIBC_USE (IEC_60559_TYPES_EXT)
     220  # undef _Mdouble_complex_
     221  # define _Mdouble_complex_	__CFLOAT64X
     222  # define _Mdouble_		_Float64x
     223  # define __MATH_PRECNAME(name)	name##f64x
     224  # include <bits/cmathcalls.h>
     225  # undef _Mdouble_
     226  # undef __MATH_PRECNAME
     227  # undef _Mdouble_complex_
     228  #endif
     229  
     230  #if (__HAVE_DISTINCT_FLOAT128X || (__HAVE_FLOAT128X && !defined _LIBC)) \
     231       && __GLIBC_USE (IEC_60559_TYPES_EXT)
     232  # undef _Mdouble_complex_
     233  # define _Mdouble_complex_	__CFLOAT128X
     234  # define _Mdouble_		_Float128x
     235  # define __MATH_PRECNAME(name)	name##f128x
     236  # include <bits/cmathcalls.h>
     237  # undef _Mdouble_
     238  # undef __MATH_PRECNAME
     239  # undef _Mdouble_complex_
     240  #endif
     241  
     242  #undef	__MATHDECL_1_IMPL
     243  #undef	__MATHDECL_1
     244  #undef	__MATHDECL
     245  #undef	__MATHCALL
     246  
     247  __END_DECLS
     248  
     249  #endif /* complex.h */