Browse Source

Simply use __imag__ to implement cimag().

We already use this construct in cabs() to call hypot(), so I guess we
can assume our targeted compilers support this construct.
Ed Schouten 10 years ago
parent
commit
a249c5ebb3
3 changed files with 3 additions and 12 deletions
  1. 1 4
      src/s_cimag.c
  2. 1 4
      src/s_cimagf.c
  3. 1 4
      src/s_cimagl.c

+ 1 - 4
src/s_cimag.c

@@ -26,7 +26,6 @@
  * $FreeBSD: src/lib/msun/src/s_cimag.c,v 1.3 2009/03/14 18:24:15 das Exp $
  */
 
-#include <openlibm.h>
 #include <openlibm_complex.h>
 
 #include "math_private.h"
@@ -34,7 +33,5 @@
 DLLEXPORT double
 cimag(double complex z)
 {
-	const double_complex z1 = { .f = z };
-
-	return (IMAGPART(z1));
+	return (__imag__ z);
 }

+ 1 - 4
src/s_cimagf.c

@@ -26,7 +26,6 @@
  * $FreeBSD: src/lib/msun/src/s_cimagf.c,v 1.3 2009/03/14 18:24:15 das Exp $
  */
 
-#include <openlibm.h>
 #include <openlibm_complex.h>
 
 #include "math_private.h"
@@ -34,7 +33,5 @@
 DLLEXPORT float
 cimagf(float complex z)
 {
-	const float_complex z1 = { .f = z };
-
-	return (IMAGPART(z1));
+	return (__imag__ z);
 }

+ 1 - 4
src/s_cimagl.c

@@ -26,7 +26,6 @@
  * $FreeBSD: src/lib/msun/src/s_cimagl.c,v 1.3 2009/03/14 18:24:15 das Exp $
  */
 
-#include <openlibm.h>
 #include <openlibm_complex.h>
 
 #include "math_private.h"
@@ -34,7 +33,5 @@
 DLLEXPORT long double
 cimagl(long double complex z)
 {
-	const long_double_complex z1 = { .f = z };
-
-	return (IMAGPART(z1));
+	return (__imag__ z);
 }