Skip to content

Commit a249c5e

Browse files
committed
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.
1 parent 08dbb2b commit a249c5e

3 files changed

Lines changed: 3 additions & 12 deletions

File tree

src/s_cimag.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,12 @@
2626
* $FreeBSD: src/lib/msun/src/s_cimag.c,v 1.3 2009/03/14 18:24:15 das Exp $
2727
*/
2828

29-
#include <openlibm.h>
3029
#include <openlibm_complex.h>
3130

3231
#include "math_private.h"
3332

3433
DLLEXPORT double
3534
cimag(double complex z)
3635
{
37-
const double_complex z1 = { .f = z };
38-
39-
return (IMAGPART(z1));
36+
return (__imag__ z);
4037
}

src/s_cimagf.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,12 @@
2626
* $FreeBSD: src/lib/msun/src/s_cimagf.c,v 1.3 2009/03/14 18:24:15 das Exp $
2727
*/
2828

29-
#include <openlibm.h>
3029
#include <openlibm_complex.h>
3130

3231
#include "math_private.h"
3332

3433
DLLEXPORT float
3534
cimagf(float complex z)
3635
{
37-
const float_complex z1 = { .f = z };
38-
39-
return (IMAGPART(z1));
36+
return (__imag__ z);
4037
}

src/s_cimagl.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,12 @@
2626
* $FreeBSD: src/lib/msun/src/s_cimagl.c,v 1.3 2009/03/14 18:24:15 das Exp $
2727
*/
2828

29-
#include <openlibm.h>
3029
#include <openlibm_complex.h>
3130

3231
#include "math_private.h"
3332

3433
DLLEXPORT long double
3534
cimagl(long double complex z)
3635
{
37-
const long_double_complex z1 = { .f = z };
38-
39-
return (IMAGPART(z1));
36+
return (__imag__ z);
4037
}

0 commit comments

Comments
 (0)