add creal/cimag macros in complex.h (and use them in the functions defs)

This commit is contained in:
Rich Felker 2012-03-22 15:54:55 -04:00
commit 13e400b355
8 changed files with 20 additions and 20 deletions

View file

@ -2,6 +2,5 @@
double (cimag)(double complex z)
{
union dcomplex u = {z};
return u.a[1];
return cimag(z);
}

View file

@ -2,6 +2,5 @@
float (cimagf)(float complex z)
{
union fcomplex u = {z};
return u.a[1];
return cimagf(z);
}

View file

@ -2,6 +2,5 @@
long double (cimagl)(long double complex z)
{
union lcomplex u = {z};
return u.a[1];
return cimagl(z);
}

View file

@ -1,6 +1,6 @@
#include <complex.h>
double creal(double complex z)
double (creal)(double complex z)
{
return z;
return creal(z);
}

View file

@ -1,6 +1,6 @@
#include <complex.h>
float crealf(float complex z)
float (crealf)(float complex z)
{
return z;
return crealf(z);
}

View file

@ -1,6 +1,6 @@
#include <complex.h>
long double creall(long double complex z)
long double (creall)(long double complex z)
{
return z;
return creall(z);
}

View file

@ -173,14 +173,6 @@ union lcomplex {
long double a[2];
};
// FIXME: move to complex.h ?
#define creal(z) ((double)(z))
#define crealf(z) ((float)(z))
#define creall(z) ((long double)(z))
#define cimag(z) ((union dcomplex){(z)}.a[1])
#define cimagf(z) ((union fcomplex){(z)}.a[1])
#define cimagl(z) ((union lcomplex){(z)}.a[1])
/* x + y*I is not supported properly by gcc */
#define cpack(x,y) ((union dcomplex){.a={(x),(y)}}.z)
#define cpackf(x,y) ((union fcomplex){.a={(x),(y)}}.z)