From cfbaba79a2dd380e580a247b8fd36af60c878e8f Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Tue, 13 Nov 2012 01:31:49 +0100 Subject: complex: add C11 CMPLX macros and replace cpack with them --- src/internal/libm.h | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) (limited to 'src/internal') diff --git a/src/internal/libm.h b/src/internal/libm.h index a71c4c05..dfecd836 100644 --- a/src/internal/libm.h +++ b/src/internal/libm.h @@ -170,25 +170,12 @@ long double __p1evll(long double, const long double *, int); #define STRICT_ASSIGN(type, lval, rval) ((lval) = (type)(rval)) #endif - /* complex */ -union dcomplex { - double complex z; - double a[2]; -}; -union fcomplex { - float complex z; - float a[2]; -}; -union lcomplex { - long double complex z; - long double a[2]; -}; - -/* 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) -#define cpackl(x,y) ((union lcomplex){.a={(x),(y)}}.z) +#ifndef CMPLX +#define CMPLX(x, y) __CMPLX(x, y, double) +#define CMPLXF(x, y) __CMPLX(x, y, float) +#define CMPLXL(x, y) __CMPLX(x, y, long double) +#endif #endif -- cgit v1.2.1 From 6d3f1a39c14b12026df84f386875b094e3652990 Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Tue, 13 Nov 2012 19:59:02 +0100 Subject: math: turn off the STRICT_ASSIGN workaround by default the volatile hack in STRICT_ASSIGN is only needed if assignment is not respected and excess precision is kept. gcc -fexcess-precision=standard and -ffloat-store both respect assignment and musl use these flags by default. i kept the macro for now so the workaround may be used for bad compilers in the future. --- src/internal/libm.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/internal') diff --git a/src/internal/libm.h b/src/internal/libm.h index dfecd836..46c4b564 100644 --- a/src/internal/libm.h +++ b/src/internal/libm.h @@ -157,16 +157,14 @@ long double __tanl(long double, long double, int); long double __polevll(long double, const long double *, int); long double __p1evll(long double, const long double *, int); -// FIXME: not needed when -fexcess-precision=standard is supported (>=gcc4.5) -/* - * Attempt to get strict C99 semantics for assignment with non-C99 compilers. - */ -#if 1 +#if 0 +/* Attempt to get strict C99 semantics for assignment with non-C99 compilers. */ #define STRICT_ASSIGN(type, lval, rval) do { \ volatile type __v = (rval); \ (lval) = __v; \ } while (0) #else +/* Should work with -fexcess-precision=standard (>=gcc-4.5) or -ffloat-store */ #define STRICT_ASSIGN(type, lval, rval) ((lval) = (type)(rval)) #endif -- cgit v1.2.1