From owner-svn-src-all@FreeBSD.ORG Fri Jan 6 19:04:59 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CAC531065675; Fri, 6 Jan 2012 19:04:59 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 9B6DA8FC0C; Fri, 6 Jan 2012 19:04:59 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q06J4xGY003068; Fri, 6 Jan 2012 19:04:59 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q06J4xCE003066; Fri, 6 Jan 2012 19:04:59 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <201201061904.q06J4xCE003066@svn.freebsd.org> From: Ed Schouten Date: Fri, 6 Jan 2012 19:04:59 +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: r229716 - head/include X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Jan 2012 19:04:59 -0000 Author: ed Date: Fri Jan 6 19:04:59 2012 New Revision: 229716 URL: http://svn.freebsd.org/changeset/base/229716 Log: Last attempt at : do enable the new code for C11 compilers. I was thinking by myself, if the new code doesn't work with GCC 4.2, why not simply turn it into an efficient version for C11 compilers? By changing the code to use _Generic() directly in that case, I can build the tgmath regression test in a matter of milliseconds with Clang, instead of the 8 seconds it used to take. So by the time C11 becomes the default, it will pick up the new code automatically. And now I will refrain from making more changes to . Modified: head/include/tgmath.h Modified: head/include/tgmath.h ============================================================================== --- head/include/tgmath.h Fri Jan 6 18:37:49 2012 (r229715) +++ head/include/tgmath.h Fri Jan 6 19:04:59 2012 (r229716) @@ -53,19 +53,23 @@ * Note that these macros cannot be implemented with C's ?: operator, * because the return type of the whole expression would incorrectly be long * double complex regardless of the argument types. + * + * The structure of the C11 implementation of these macros can in + * principle be reused for non-C11 compilers, but due to an integer + * promotion bug for complex types in GCC 4.2, simply let non-C11 + * compilers use an inefficient yet reliable version. */ -#ifndef __generic -#error " not implemented for this compiler" -#endif - -#if 0 /* XXX: Much shorter and faster to compile, but broken with GCC 4.2. */ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L #define __tg_generic(x, cfnl, cfn, cfnf, fnl, fn, fnf) \ - __generic(x, long double _Complex, cfnl, \ - __generic(x, double _Complex, cfn, \ - __generic(x, float _Complex, cfnf, \ - __generic(x, long double, fnl, \ - __generic(x, float, fnf, fn))))) + _Generic(x, \ + long double _Complex: cfnl, \ + double _Complex: cfn, \ + float _Complex: cfnf, \ + long double: fnl, \ + default: fn, \ + float: fnf \ + ) #define __tg_type(x) \ __tg_generic(x, (long double _Complex)0, (double _Complex)0, \ (float _Complex)0, (long double)0, (double)0, (float)0) @@ -77,7 +81,7 @@ __tg_generic( \ __tg_type(x) + __tg_type(y), \ cfnl, cfn, cfnf, fnl, fn, fnf)(__VA_ARGS__) -#else +#elif defined(__generic) #define __tg_generic_simple(x, fnl, fn, fnf) \ __generic(x, long double _Complex, fnl, \ __generic(x, double _Complex, fn, \ @@ -113,6 +117,8 @@ __tg_generic_full(y, cfnl, cfn , cfn , fnl , fn , fn ), \ __tg_generic_full(y, cfnl, cfn , cfnf, fnl , fn , fnf )) \ (__VA_ARGS__) +#else +#error " not implemented for this compiler" #endif /* Macros to save lots of repetition below */