master
  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
 78extern float complex cacosf(float complex);
 79extern double complex cacos(double complex);
 80extern long double complex cacosl(long double complex);
 81
 82extern float complex casinf(float complex);
 83extern double complex casin(double complex);
 84extern long double complex casinl(long double complex);
 85
 86extern float complex catanf(float complex);
 87extern double complex catan(double complex);
 88extern long double complex catanl(long double complex);
 89
 90extern float complex ccosf(float complex);
 91extern double complex ccos(double complex);
 92extern long double complex ccosl(long double complex);
 93
 94extern float complex csinf(float complex);
 95extern double complex csin(double complex);
 96extern long double complex csinl(long double complex);
 97
 98extern float complex ctanf(float complex);
 99extern double complex ctan(double complex);
100extern long double complex ctanl(long double complex);
101
102extern float complex cacoshf(float complex);
103extern double complex cacosh(double complex);
104extern long double complex cacoshl(long double complex);
105
106extern float complex casinhf(float complex);
107extern double complex casinh(double complex);
108extern long double complex casinhl(long double complex);
109
110extern float complex catanhf(float complex);
111extern double complex catanh(double complex);
112extern long double complex catanhl(long double complex);
113
114extern float complex ccoshf(float complex);
115extern double complex ccosh(double complex);
116extern long double complex ccoshl(long double complex);
117
118extern float complex csinhf(float complex);
119extern double complex csinh(double complex);
120extern long double complex csinhl(long double complex);
121
122extern float complex ctanhf(float complex);
123extern double complex ctanh(double complex);
124extern long double complex ctanhl(long double complex);
125
126extern float complex cexpf(float complex);
127extern double complex cexp(double complex);
128extern long double complex cexpl(long double complex);
129
130extern float complex clogf(float complex);
131extern double complex clog(double complex);
132extern long double complex clogl(long double complex);
133
134extern float cabsf(float complex);
135extern double cabs(double complex);
136extern long double cabsl(long double complex);
137
138extern float complex cpowf(float complex, float complex);
139extern double complex cpow(double complex, double complex);
140extern long double complex cpowl(long double complex, long double complex);
141
142extern float complex csqrtf(float complex);
143extern double complex csqrt(double complex);
144extern long double complex csqrtl(long double complex);
145
146extern float cargf(float complex);
147extern double carg(double complex);
148extern long double cargl(long double complex);
149
150extern float cimagf(float complex);
151extern double cimag(double complex);
152extern long double cimagl(long double complex);
153
154extern float complex conjf(float complex);
155extern double complex conj(double complex);
156extern long double complex conjl(long double complex);
157
158extern float complex cprojf(float complex);
159extern double complex cproj(double complex);
160extern long double complex cprojl(long double complex);
161
162extern float crealf(float complex);
163extern double creal(double complex);
164extern long double creall(long double complex);
165__END_DECLS
166
167#endif /* __COMPLEX_H__ */