1 /* 2 * Copyright (c) 2002-2013 Apple Inc. All rights reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * The contents of this file constitute Original Code as defined in and 7 * are subject to the Apple Public Source License Version 1.1 (the 8 * "License"). You may not use this file except in compliance with the 9 * License. Please obtain a copy of the License at 10 * http://www.apple.com/publicsource and read it before using this file. 11 * 12 * This Original Code and all software distributed under the License are 13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER 14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the 17 * License for the specific language governing rights and limitations 18 * under the License. 19 * 20 * @APPLE_LICENSE_HEADER_END@ 21 */ 22 23 /****************************************************************************** 24 * * 25 * File: complex.h * 26 * * 27 * Contains: prototypes and macros germane to C99 complex math. * 28 * * 29 ******************************************************************************/ 30 31 #ifndef __COMPLEX_H__ 32 #define __COMPLEX_H__ 33 34 #include <sys/cdefs.h> 35 36 #undef complex 37 #define complex _Complex 38 #undef _Complex_I 39 /* Constant expression of type const float _Complex */ 40 #define _Complex_I (__extension__ 1.0iF) 41 #undef I 42 #define I _Complex_I 43 44 #if (__STDC_VERSION__ > 199901L || __DARWIN_C_LEVEL >= __DARWIN_C_FULL) \ 45 && defined __clang__ 46 47 /* Complex initializer macros. These are a C11 feature, but are also provided 48 as an extension in C99 so long as strict POSIX conformance is not 49 requested. They are available only when building with the llvm-clang 50 compiler, as there is no way to support them with the gcc-4.2 frontend. 51 These may be used for static initialization of complex values, like so: 52 53 static const float complex someVariable = CMPLXF(1.0, INFINITY); 54 55 they may, of course, be used outside of static contexts as well. */ 56 57 #define CMPLX(__real,__imag) \ 58 _Pragma("clang diagnostic push") \ 59 _Pragma("clang diagnostic ignored \"-Wcomplex-component-init\"") \ 60 (double _Complex){(__real),(__imag)} \ 61 _Pragma("clang diagnostic pop") 62 63 #define CMPLXF(__real,__imag) \ 64 _Pragma("clang diagnostic push") \ 65 _Pragma("clang diagnostic ignored \"-Wcomplex-component-init\"") \ 66 (float _Complex){(__real),(__imag)} \ 67 _Pragma("clang diagnostic pop") 68 69 #define CMPLXL(__real,__imag) \ 70 _Pragma("clang diagnostic push") \ 71 _Pragma("clang diagnostic ignored \"-Wcomplex-component-init\"") \ 72 (long double _Complex){(__real),(__imag)} \ 73 _Pragma("clang diagnostic pop") 74 75 #endif /* End C11 features. */ 76 77 __BEGIN_DECLS 78 extern float complex cacosf(float complex); 79 extern double complex cacos(double complex); 80 extern long double complex cacosl(long double complex); 81 82 extern float complex casinf(float complex); 83 extern double complex casin(double complex); 84 extern long double complex casinl(long double complex); 85 86 extern float complex catanf(float complex); 87 extern double complex catan(double complex); 88 extern long double complex catanl(long double complex); 89 90 extern float complex ccosf(float complex); 91 extern double complex ccos(double complex); 92 extern long double complex ccosl(long double complex); 93 94 extern float complex csinf(float complex); 95 extern double complex csin(double complex); 96 extern long double complex csinl(long double complex); 97 98 extern float complex ctanf(float complex); 99 extern double complex ctan(double complex); 100 extern long double complex ctanl(long double complex); 101 102 extern float complex cacoshf(float complex); 103 extern double complex cacosh(double complex); 104 extern long double complex cacoshl(long double complex); 105 106 extern float complex casinhf(float complex); 107 extern double complex casinh(double complex); 108 extern long double complex casinhl(long double complex); 109 110 extern float complex catanhf(float complex); 111 extern double complex catanh(double complex); 112 extern long double complex catanhl(long double complex); 113 114 extern float complex ccoshf(float complex); 115 extern double complex ccosh(double complex); 116 extern long double complex ccoshl(long double complex); 117 118 extern float complex csinhf(float complex); 119 extern double complex csinh(double complex); 120 extern long double complex csinhl(long double complex); 121 122 extern float complex ctanhf(float complex); 123 extern double complex ctanh(double complex); 124 extern long double complex ctanhl(long double complex); 125 126 extern float complex cexpf(float complex); 127 extern double complex cexp(double complex); 128 extern long double complex cexpl(long double complex); 129 130 extern float complex clogf(float complex); 131 extern double complex clog(double complex); 132 extern long double complex clogl(long double complex); 133 134 extern float cabsf(float complex); 135 extern double cabs(double complex); 136 extern long double cabsl(long double complex); 137 138 extern float complex cpowf(float complex, float complex); 139 extern double complex cpow(double complex, double complex); 140 extern long double complex cpowl(long double complex, long double complex); 141 142 extern float complex csqrtf(float complex); 143 extern double complex csqrt(double complex); 144 extern long double complex csqrtl(long double complex); 145 146 extern float cargf(float complex); 147 extern double carg(double complex); 148 extern long double cargl(long double complex); 149 150 extern float cimagf(float complex); 151 extern double cimag(double complex); 152 extern long double cimagl(long double complex); 153 154 extern float complex conjf(float complex); 155 extern double complex conj(double complex); 156 extern long double complex conjl(long double complex); 157 158 extern float complex cprojf(float complex); 159 extern double complex cproj(double complex); 160 extern long double complex cprojl(long double complex); 161 162 extern float crealf(float complex); 163 extern double creal(double complex); 164 extern long double creall(long double complex); 165 __END_DECLS 166 167 #endif /* __COMPLEX_H__ */