From owner-svn-src-head@FreeBSD.ORG Sat May 25 18:55:55 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id AA7E0374; Sat, 25 May 2013 18:55:55 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 9D2F4FAE; Sat, 25 May 2013 18:55:55 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r4PIttCQ052696; Sat, 25 May 2013 18:55:55 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r4PIttB7052695; Sat, 25 May 2013 18:55:55 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <201305251855.r4PIttB7052695@svn.freebsd.org> From: Ed Schouten Date: Sat, 25 May 2013 18:55:55 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r250990 - head/include X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 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, 25 May 2013 18:55:55 -0000 Author: ed Date: Sat May 25 18:55:55 2013 New Revision: 250990 URL: http://svnweb.freebsd.org/changeset/base/250990 Log: Add C11 macros CMPLX(), CMPLXF() and CMPLXL(). Clang allows us to initialize complex numbers using an array initializer, casted to a complex type. GCC has a builtin called __builtin_complex(). Modified: head/include/complex.h Modified: head/include/complex.h ============================================================================== --- head/include/complex.h Sat May 25 18:04:24 2013 (r250989) +++ head/include/complex.h Sat May 25 18:55:55 2013 (r250990) @@ -46,6 +46,18 @@ _Static_assert(__generic(_Complex_I, flo #define complex _Complex #define I _Complex_I +#if __ISO_C_VISIBLE >= 2011 +#ifdef __clang__ +#define CMPLX(x, y) ((double complex){ x, y }) +#define CMPLXF(x, y) ((float complex){ x, y }) +#define CMPLXL(x, y) ((long double complex){ x, y }) +#elif __GNUC_PREREQ__(4, 7) +#define CMPLX(x, y) __builtin_complex((double)(x), (double)(y)) +#define CMPLXF(x, y) __builtin_complex((float)(x), (float)(y)) +#define CMPLXL(x, y) __builtin_complex((long double)(x), (long double)(y)) +#endif +#endif /* __ISO_C_VISIBLE >= 2011 */ + __BEGIN_DECLS double cabs(double complex);