Reactos
at master 209 lines 5.6 kB view raw
1/** 2 * This file has no copyright assigned and is placed in the Public Domain. 3 * This file is part of the w64 mingw-runtime package. 4 * No warranty is given; refer to the file DISCLAIMER within this package. 5 */ 6/* 7 * complex.h 8 * 9 * This file is part of the Mingw32 package. 10 * 11 * Contributors: 12 * Created by Danny Smith <dannysmith@users.sourceforge.net> 13 * 14 * THIS SOFTWARE IS NOT COPYRIGHTED 15 * 16 * This source code is offered for use in the public domain. You may 17 * use, modify or distribute it freely. 18 * 19 * This code is distributed in the hope that it will be useful but 20 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 21 * DISCLAIMED. This includes but is not limited to warranties of 22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 23 * 24 */ 25 26#ifndef _COMPLEX_H_ 27#define _COMPLEX_H_ 28 29#include <corecrt.h> 30 31#if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) \ 32 || !defined __STRICT_ANSI__ 33 34/* These macros are specified by C99 standard */ 35 36#ifndef __cplusplus 37#define complex _Complex 38#endif 39 40#define _Complex_I (0.0F + 1.0iF) 41 42/* GCC doesn't support _Imaginary type yet, so we don't 43 define _Imaginary_I */ 44 45#define I _Complex_I 46 47#ifdef __cplusplus 48extern "C" { 49#endif 50 51#ifndef RC_INVOKED 52 53double creal (double _Complex); 54double cimag (double _Complex); 55double carg (double _Complex); 56double cabs (double _Complex); 57double _Complex conj (double _Complex); 58double _Complex cacos (double _Complex); 59double _Complex casin (double _Complex); 60double _Complex catan (double _Complex); 61double _Complex ccos (double _Complex); 62double _Complex csin (double _Complex); 63double _Complex ctan (double _Complex); 64double _Complex cacosh (double _Complex); 65double _Complex casinh (double _Complex); 66double _Complex catanh (double _Complex); 67double _Complex ccosh (double _Complex); 68double _Complex csinh (double _Complex); 69double _Complex ctanh (double _Complex); 70double _Complex cexp (double _Complex); 71double _Complex clog (double _Complex); 72double _Complex cpow (double _Complex, double _Complex); 73double _Complex csqrt (double _Complex); 74double _Complex cproj (double _Complex); 75 76float crealf (float _Complex); 77float cimagf (float _Complex); 78float cargf (float _Complex); 79float cabsf (float _Complex); 80float _Complex conjf (float _Complex); 81float _Complex cacosf (float _Complex); 82float _Complex casinf (float _Complex); 83float _Complex catanf (float _Complex); 84float _Complex ccosf (float _Complex); 85float _Complex csinf (float _Complex); 86float _Complex ctanf (float _Complex); 87float _Complex cacoshf (float _Complex); 88float _Complex casinhf (float _Complex); 89float _Complex catanhf (float _Complex); 90float _Complex ccoshf (float _Complex); 91float _Complex csinhf (float _Complex); 92float _Complex ctanhf (float _Complex); 93float _Complex cexpf (float _Complex); 94float _Complex clogf (float _Complex); 95float _Complex cpowf (float _Complex, float _Complex); 96float _Complex csqrtf (float _Complex); 97float _Complex cprojf (float _Complex); 98 99long double creall (long double _Complex); 100long double cimagl (long double _Complex); 101long double cargl (long double _Complex); 102long double cabsl (long double _Complex); 103long double _Complex conjl (long double _Complex); 104long double _Complex cacosl (long double _Complex); 105long double _Complex casinl (long double _Complex); 106long double _Complex catanl (long double _Complex); 107long double _Complex ccosl (long double _Complex); 108long double _Complex csinl (long double _Complex); 109long double _Complex ctanl (long double _Complex); 110long double _Complex cacoshl (long double _Complex); 111long double _Complex casinhl (long double _Complex); 112long double _Complex catanhl (long double _Complex); 113long double _Complex ccoshl (long double _Complex); 114long double _Complex csinhl (long double _Complex); 115long double _Complex ctanhl (long double _Complex); 116long double _Complex cexpl (long double _Complex); 117long double _Complex clogl (long double _Complex); 118long double _Complex cpowl (long double _Complex, long double _Complex); 119long double _Complex csqrtl (long double _Complex); 120long double _Complex cprojl (long double _Complex); 121 122#ifdef __GNUC__ 123 124/* double */ 125__CRT_INLINE double creal (double _Complex _Z) 126{ 127 return __real__ _Z; 128} 129 130__CRT_INLINE double cimag (double _Complex _Z) 131{ 132 return __imag__ _Z; 133} 134 135__CRT_INLINE double _Complex conj (double _Complex _Z) 136{ 137 return __extension__ ~_Z; 138} 139 140__CRT_INLINE double carg (double _Complex _Z) 141{ 142 double res; 143 __asm__ ("fpatan;" 144 : "=t" (res) : "0" (__real__ _Z), "u" (__imag__ _Z) : "st(1)"); 145 return res; 146} 147 148 149/* float */ 150__CRT_INLINE float crealf (float _Complex _Z) 151{ 152 return __real__ _Z; 153} 154 155__CRT_INLINE float cimagf (float _Complex _Z) 156{ 157 return __imag__ _Z; 158} 159 160__CRT_INLINE float _Complex conjf (float _Complex _Z) 161{ 162 return __extension__ ~_Z; 163} 164 165__CRT_INLINE float cargf (float _Complex _Z) 166{ 167 float res; 168 __asm__ ("fpatan;" 169 : "=t" (res) : "0" (__real__ _Z), "u" (__imag__ _Z) : "st(1)"); 170 return res; 171} 172 173/* long double */ 174__CRT_INLINE long double creall (long double _Complex _Z) 175{ 176 return __real__ _Z; 177} 178 179__CRT_INLINE long double cimagl (long double _Complex _Z) 180{ 181 return __imag__ _Z; 182} 183 184__CRT_INLINE long double _Complex conjl (long double _Complex _Z) 185{ 186 return __extension__ ~_Z; 187} 188 189__CRT_INLINE long double cargl (long double _Complex _Z) 190{ 191 long double res; 192 __asm__ ("fpatan;" 193 : "=t" (res) : "0" (__real__ _Z), "u" (__imag__ _Z) : "st(1)"); 194 return res; 195} 196 197#endif /* __GNUC__ */ 198 199 200#endif /* RC_INVOKED */ 201 202#ifdef __cplusplus 203} 204#endif 205 206#endif /* __STDC_VERSION__ >= 199901L */ 207 208 209#endif /* _COMPLEX_H */