X-Git-Url: http://nsz.repo.hu/git/?p=musl;a=blobdiff_plain;f=include%2Fcomplex.h;h=13a45c57c200e9f671f738f66efb8ea6cf5945a9;hp=90496bd5d397737ecc1f6f87d416a8371e49225c;hb=ae0c1de530bc3b27069008b8b247171d08dbe80b;hpb=13e400b3559666b5e584bdf6f8450aad826b43ae diff --git a/include/complex.h b/include/complex.h index 90496bd5..13a45c57 100644 --- a/include/complex.h +++ b/include/complex.h @@ -6,7 +6,11 @@ extern "C" { #endif #define complex _Complex +#ifdef __GNUC__ +#define _Complex_I (__extension__ 1.0fi) +#else #define _Complex_I 1.0fi +#endif #define I _Complex_I double complex cacos(double complex); @@ -97,16 +101,23 @@ double creal(double complex); float crealf(float complex); long double creall(long double complex); -#define __CREALIMAG(x, t, i) \ - ((union { _Complex t __z; t __xy[2]; }){(_Complex t)(x)}.__xy[i]) +#define __CIMAG(x, t) \ + ((union { _Complex t __z; t __xy[2]; }){(_Complex t)(x)}.__xy[1]) + +#define creal(x) ((double)(x)) +#define crealf(x) ((float)(x)) +#define creall(x) ((long double)(x)) + +#define cimag(x) __CIMAG(x, double) +#define cimagf(x) __CIMAG(x, float) +#define cimagl(x) __CIMAG(x, long double) -#define creal(x) __CREALIMAG(x, double, 0) -#define crealf(x) __CREALIMAG(x, float, 0) -#define creall(x) __CREALIMAG(x, long double, 0) +#define __CMPLX(x, y, t) \ + ((union { _Complex t __z; t __xy[2]; }){.__xy = {(x),(y)}}.__z) -#define cimag(x) __CREALIMAG(x, double, 1) -#define cimagf(x) __CREALIMAG(x, float, 1) -#define cimagl(x) __CREALIMAG(x, long double, 1) +#define CMPLX(x, y) __CMPLX(x, y, double) +#define CMPLXF(x, y) __CMPLX(x, y, float) +#define CMPLXL(x, y) __CMPLX(x, y, long double) #ifdef __cplusplus }