summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2012-03-22 20:00:58 -0400
committerRich Felker <dalias@aerifal.cx>2012-03-22 20:00:58 -0400
commit494ba80e9a7f43be76dfee908bbd40ad0b608041 (patch)
tree23ece8505198ee14cff0b26b70d469053b24529f
parent13e400b3559666b5e584bdf6f8450aad826b43ae (diff)
downloadmusl-494ba80e9a7f43be76dfee908bbd40ad0b608041.tar.gz
simplify creal and cimag macros
-rw-r--r--include/complex.h16
1 files changed, 8 insertions, 8 deletions
diff --git a/include/complex.h b/include/complex.h
index 90496bd5..436f32f4 100644
--- a/include/complex.h
+++ b/include/complex.h
@@ -97,16 +97,16 @@ 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) __CREALIMAG(x, double, 0)
-#define crealf(x) __CREALIMAG(x, float, 0)
-#define creall(x) __CREALIMAG(x, long double, 0)
+#define creal(x) ((double)(x))
+#define crealf(x) ((float)(x))
+#define creall(x) ((long double)(x))
-#define cimag(x) __CREALIMAG(x, double, 1)
-#define cimagf(x) __CREALIMAG(x, float, 1)
-#define cimagl(x) __CREALIMAG(x, long double, 1)
+#define cimag(x) __CIMAG(x, double)
+#define cimagf(x) __CIMAG(x, float)
+#define cimagl(x) __CIMAG(x, long double)
#ifdef __cplusplus
}