1 /* $OpenBSD: complex.h,v 1.5 2014/03/16 18:38:30 guenther Exp $ */ 2 /* 3 * Copyright (c) 2008 Martynas Venckus <martynas@openbsd.org> 4 * 5 * Permission to use, copy, modify, and distribute this software for any 6 * purpose with or without fee is hereby granted, provided that the above 7 * copyright notice and this permission notice appear in all copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16 */ 17 18 #ifndef _COMPLEX_H_ 19 #define _COMPLEX_H_ 20 21 #include <sys/cdefs.h> 22 23 /* 24 * C99 25 */ 26 #ifdef __GNUC__ 27 #if __STDC_VERSION__ < 199901 28 #define _Complex __complex__ 29 #endif 30 #define _Complex_I 1.0fi 31 #endif 32 33 #define complex _Complex 34 35 /* XXX switch to _Imaginary_I */ 36 #undef I 37 #define I _Complex_I 38 39 #if __ISO_C_VISIBLE >= 2011 40 #if __GNUC_PREREQ__(4, 7) 41 #define CMPLX(x, y) __builtin_complex((double)(x), (double)(y)) 42 #define CMPLXF(x, y) __builtin_complex((float)(x), (float)(y)) 43 #define CMPLXL(x, y) __builtin_complex((long double)(x), (long double)(y)) 44 #elif defined __clang__ 45 #define CMPLX(x, y) ((double complex){ x, y }) 46 #define CMPLXF(x, y) ((float complex){ x, y }) 47 #define CMPLXL(x, y) ((long double complex){ x, y }) 48 #endif 49 #endif /* __ISO_C_VISIBLE >= 2011 */ 50 51 __BEGIN_DECLS 52 /* 53 * Double versions of C99 functions 54 */ 55 double complex cacos(double complex); 56 double complex casin(double complex); 57 double complex catan(double complex); 58 double complex ccos(double complex); 59 double complex csin(double complex); 60 double complex ctan(double complex); 61 double complex cacosh(double complex); 62 double complex casinh(double complex); 63 double complex catanh(double complex); 64 double complex ccosh(double complex); 65 double complex csinh(double complex); 66 double complex ctanh(double complex); 67 double complex cexp(double complex); 68 double complex clog(double complex); 69 double cabs(double complex); 70 double complex cpow(double complex, double complex); 71 double complex csqrt(double complex); 72 double carg(double complex); 73 double cimag(double complex); 74 double complex conj(double complex); 75 double complex cproj(double complex); 76 double creal(double complex); 77 78 /* 79 * Float versions of C99 functions 80 */ 81 float complex cacosf(float complex); 82 float complex casinf(float complex); 83 float complex catanf(float complex); 84 float complex ccosf(float complex); 85 float complex csinf(float complex); 86 float complex ctanf(float complex); 87 float complex cacoshf(float complex); 88 float complex casinhf(float complex); 89 float complex catanhf(float complex); 90 float complex ccoshf(float complex); 91 float complex csinhf(float complex); 92 float complex ctanhf(float complex); 93 float complex cexpf(float complex); 94 float complex clogf(float complex); 95 float cabsf(float complex); 96 float complex cpowf(float complex, float complex); 97 float complex csqrtf(float complex); 98 float cargf(float complex); 99 float cimagf(float complex); 100 float complex conjf(float complex); 101 float complex cprojf(float complex); 102 float crealf(float complex); 103 104 /* 105 * Long double versions of C99 functions 106 */ 107 long double complex cacosl(long double complex); 108 long double complex casinl(long double complex); 109 long double complex catanl(long double complex); 110 long double complex ccosl(long double complex); 111 long double complex csinl(long double complex); 112 long double complex ctanl(long double complex); 113 long double complex cacoshl(long double complex); 114 long double complex casinhl(long double complex); 115 long double complex catanhl(long double complex); 116 long double complex ccoshl(long double complex); 117 long double complex csinhl(long double complex); 118 long double complex ctanhl(long double complex); 119 long double complex cexpl(long double complex); 120 long double complex clogl(long double complex); 121 long double cabsl(long double complex); 122 long double complex cpowl(long double complex, 123 long double complex); 124 long double complex csqrtl(long double complex); 125 long double cargl(long double complex); 126 long double cimagl(long double complex); 127 long double complex conjl(long double complex); 128 long double complex cprojl(long double complex); 129 long double creall(long double complex); 130 __END_DECLS 131 132 #endif /* !_COMPLEX_H_ */ 133