summaryrefslogtreecommitdiffstats
path: root/lib/msun
diff options
context:
space:
mode:
authordas <das@FreeBSD.org>2009-03-14 18:24:15 +0000
committerdas <das@FreeBSD.org>2009-03-14 18:24:15 +0000
commitfa12b26b661e096786094626306fd95ff506ac20 (patch)
treea4247d26e72ccf2c49cb3317cb6a07631b1e2832 /lib/msun
parent4cd01fc223701ae9a3fc4907d8c8e835ca6193d6 (diff)
downloadFreeBSD-src-fa12b26b661e096786094626306fd95ff506ac20.zip
FreeBSD-src-fa12b26b661e096786094626306fd95ff506ac20.tar.gz
Eliminate __real__ and __imag__ gccisms.
Diffstat (limited to 'lib/msun')
-rw-r--r--lib/msun/src/math_private.h45
-rw-r--r--lib/msun/src/s_cimag.c4
-rw-r--r--lib/msun/src/s_cimagf.c4
-rw-r--r--lib/msun/src/s_cimagl.c4
4 files changed, 42 insertions, 15 deletions
diff --git a/lib/msun/src/math_private.h b/lib/msun/src/math_private.h
index 46d65cc..49553db 100644
--- a/lib/msun/src/math_private.h
+++ b/lib/msun/src/math_private.h
@@ -190,6 +190,27 @@ do { \
void _scan_nan(uint32_t *__words, int __num_words, const char *__s);
#ifdef _COMPLEX_H
+
+/*
+ * C99 specifies that complex numbers have the same representation as
+ * an array of two elements, where the first element is the real part
+ * and the second element is the imaginary part.
+ */
+typedef union {
+ float complex f;
+ float a[2];
+} float_complex;
+typedef union {
+ double complex f;
+ double a[2];
+} double_complex;
+typedef union {
+ long double complex f;
+ long double a[2];
+} long_double_complex;
+#define REALPART(z) ((z).a[0])
+#define IMAGPART(z) ((z).a[1])
+
/*
* Inline functions that can be used to construct complex values.
*
@@ -203,31 +224,31 @@ void _scan_nan(uint32_t *__words, int __num_words, const char *__s);
static __inline float complex
cpackf(float x, float y)
{
- float complex z;
+ float_complex z;
- __real__ z = x;
- __imag__ z = y;
- return (z);
+ REALPART(z) = x;
+ IMAGPART(z) = y;
+ return (z.f);
}
static __inline double complex
cpack(double x, double y)
{
- double complex z;
+ double_complex z;
- __real__ z = x;
- __imag__ z = y;
- return (z);
+ REALPART(z) = x;
+ IMAGPART(z) = y;
+ return (z.f);
}
static __inline long double complex
cpackl(long double x, long double y)
{
- long double complex z;
+ long_double_complex z;
- __real__ z = x;
- __imag__ z = y;
- return (z);
+ REALPART(z) = x;
+ IMAGPART(z) = y;
+ return (z.f);
}
#endif /* _COMPLEX_H */
diff --git a/lib/msun/src/s_cimag.c b/lib/msun/src/s_cimag.c
index aa25423..cbf6720 100644
--- a/lib/msun/src/s_cimag.c
+++ b/lib/msun/src/s_cimag.c
@@ -27,10 +27,12 @@
*/
#include <complex.h>
+#include "math_private.h"
double
cimag(double complex z)
{
+ const double_complex z1 = { .f = z };
- return (__imag__ z);
+ return (IMAGPART(z1));
}
diff --git a/lib/msun/src/s_cimagf.c b/lib/msun/src/s_cimagf.c
index 6bd00d9..4e483a2 100644
--- a/lib/msun/src/s_cimagf.c
+++ b/lib/msun/src/s_cimagf.c
@@ -27,10 +27,12 @@
*/
#include <complex.h>
+#include "math_private.h"
float
cimagf(float complex z)
{
+ const float_complex z1 = { .f = z };
- return (__imag__ z);
+ return (IMAGPART(z1));
}
diff --git a/lib/msun/src/s_cimagl.c b/lib/msun/src/s_cimagl.c
index 581f443..c50e967 100644
--- a/lib/msun/src/s_cimagl.c
+++ b/lib/msun/src/s_cimagl.c
@@ -27,10 +27,12 @@
*/
#include <complex.h>
+#include "math_private.h"
long double
cimagl(long double complex z)
{
+ const long_double_complex z1 = { .f = z };
- return (__imag__ z);
+ return (IMAGPART(z1));
}
OpenPOWER on IntegriCloud