From owner-svn-src-head@FreeBSD.ORG Sat Mar 14 18:24:15 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E0EB8106564A; Sat, 14 Mar 2009 18:24:15 +0000 (UTC) (envelope-from das@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CEE038FC14; Sat, 14 Mar 2009 18:24:15 +0000 (UTC) (envelope-from das@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n2EIOFfr003865; Sat, 14 Mar 2009 18:24:15 GMT (envelope-from das@svn.freebsd.org) Received: (from das@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n2EIOFGJ003860; Sat, 14 Mar 2009 18:24:15 GMT (envelope-from das@svn.freebsd.org) Message-Id: <200903141824.n2EIOFGJ003860@svn.freebsd.org> From: David Schultz Date: Sat, 14 Mar 2009 18:24:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189803 - head/lib/msun/src X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Mar 2009 18:24:16 -0000 Author: das Date: Sat Mar 14 18:24:15 2009 New Revision: 189803 URL: http://svn.freebsd.org/changeset/base/189803 Log: Eliminate __real__ and __imag__ gccisms. Modified: head/lib/msun/src/math_private.h head/lib/msun/src/s_cimag.c head/lib/msun/src/s_cimagf.c head/lib/msun/src/s_cimagl.c Modified: head/lib/msun/src/math_private.h ============================================================================== --- head/lib/msun/src/math_private.h Sat Mar 14 18:19:50 2009 (r189802) +++ head/lib/msun/src/math_private.h Sat Mar 14 18:24:15 2009 (r189803) @@ -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 __ 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 */ Modified: head/lib/msun/src/s_cimag.c ============================================================================== --- head/lib/msun/src/s_cimag.c Sat Mar 14 18:19:50 2009 (r189802) +++ head/lib/msun/src/s_cimag.c Sat Mar 14 18:24:15 2009 (r189803) @@ -27,10 +27,12 @@ */ #include +#include "math_private.h" double cimag(double complex z) { + const double_complex z1 = { .f = z }; - return (__imag__ z); + return (IMAGPART(z1)); } Modified: head/lib/msun/src/s_cimagf.c ============================================================================== --- head/lib/msun/src/s_cimagf.c Sat Mar 14 18:19:50 2009 (r189802) +++ head/lib/msun/src/s_cimagf.c Sat Mar 14 18:24:15 2009 (r189803) @@ -27,10 +27,12 @@ */ #include +#include "math_private.h" float cimagf(float complex z) { + const float_complex z1 = { .f = z }; - return (__imag__ z); + return (IMAGPART(z1)); } Modified: head/lib/msun/src/s_cimagl.c ============================================================================== --- head/lib/msun/src/s_cimagl.c Sat Mar 14 18:19:50 2009 (r189802) +++ head/lib/msun/src/s_cimagl.c Sat Mar 14 18:24:15 2009 (r189803) @@ -27,10 +27,12 @@ */ #include +#include "math_private.h" long double cimagl(long double complex z) { + const long_double_complex z1 = { .f = z }; - return (__imag__ z); + return (IMAGPART(z1)); }