From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14415 invoked by alias); 13 Nov 2014 07:11:48 -0000 Mailing-List: contact libffi-discuss-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libffi-discuss-owner@sourceware.org Received: (qmail 14402 invoked by uid 89); 13 Nov 2014 07:11:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: e06smtp14.uk.ibm.com Received: from e06smtp14.uk.ibm.com (HELO e06smtp14.uk.ibm.com) (195.75.94.110) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Thu, 13 Nov 2014 07:11:45 +0000 Received: from /spool/local by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 13 Nov 2014 07:11:41 -0000 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 13 Nov 2014 07:11:39 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id EF0A61B08040 for ; Thu, 13 Nov 2014 07:11:48 +0000 (GMT) Received: from d06av07.portsmouth.uk.ibm.com (d06av07.portsmouth.uk.ibm.com [9.149.37.248]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id sAD7Bdpr18874686 for ; Thu, 13 Nov 2014 07:11:39 GMT Received: from d06av07.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av07.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id sAD7BdIc017856 for ; Thu, 13 Nov 2014 02:11:39 -0500 Received: from bl3ahm9f.de.ibm.com (dyn-9-152-212-241.boeblingen.de.ibm.com [9.152.212.241]) by d06av07.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id sAD7BcwX017844 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Thu, 13 Nov 2014 02:11:39 -0500 Received: from dvogt by bl3ahm9f.de.ibm.com with local (Exim 4.76) (envelope-from ) id 1XooZ8-0003FN-E3; Thu, 13 Nov 2014 08:11:38 +0100 Date: Thu, 13 Nov 2014 07:11:00 -0000 From: Dominik Vogt To: libffi-discuss@sourceware.org Subject: [PATCH] Detect compiler's _Complex support with a configure check. Message-ID: <20141113071138.GB10649@linux.vnet.ibm.com> Reply-To: libffi-discuss@sourceware.org Mail-Followup-To: libffi-discuss@sourceware.org MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="T4sUOijqQbZv57TR" Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14111307-0017-0000-0000-000001D1CAEC X-IsSubscribed: yes X-SW-Source: 2014/txt/msg00222.txt.bz2 --T4sUOijqQbZv57TR Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 543 Fixes the build issue for compilers without C99 complex type support as discussed. Detection uses a configure test because checking macros and compiler versions seemed too hairy. Tested on s390x. As a slight safety measure, the patched code uses " _Complex" instead of "_Complex " as in the examples of the C99 standard document, just in case there's some odd compiler out there that requires that specific order (although the standard demands that any order is allowed). Ciao Dominik ^_^ ^_^ -- Dominik Vogt IBM Germany --T4sUOijqQbZv57TR Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-Detect-compiler-s-_Complex-support-with-a-configure-.patch" Content-length: 2424 >From c023e2248275d360ee1d0d26552c10b43cd13272 Mon Sep 17 00:00:00 2001 From: Dominik Vogt Date: Tue, 11 Nov 2014 13:55:22 +0100 Subject: [PATCH] Detect compiler's _Complex support with a configure check. This is needed in types.c to initialise the ffi_type_complex_... structs. --- configure.ac | 9 +++++++++ src/types.c | 21 ++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 4a44bff..cb44dbf 100644 --- a/configure.ac +++ b/configure.ac @@ -363,6 +363,15 @@ fi AC_SUBST(HAVE_LONG_DOUBLE) AC_SUBST(HAVE_LONG_DOUBLE_VARIANT) +# detect c99 complex type support +AH_TEMPLATE([HAVE_COMPLEX_TYPES],[Compiler supports C99 complex types]) +AC_MSG_CHECKING([whether compiler supports C99 complex types]) +AC_TRY_COMPILE(, + [float _Complex cf;], + AC_DEFINE(HAVE_COMPLEX_TYPES) + AC_MSG_RESULT(yes), + AC_MSG_RESULT([no[,] guess their size and alignment])) + AC_C_BIGENDIAN GCC_AS_CFI_PSEUDO_OP diff --git a/src/types.c b/src/types.c index ef4f151..e16153b 100644 --- a/src/types.c +++ b/src/types.c @@ -44,13 +44,14 @@ maybe_const ffi_type ffi_type_##name = { \ id, NULL \ } +#ifdef HAVE_COMPLEX_TYPES #define FFI_COMPLEX_TYPEDEF(name, type, maybe_const) \ static ffi_type *ffi_elements_complex_##name [2] = { \ (ffi_type *)(&ffi_type_##name), NULL \ }; \ struct struct_align_complex_##name { \ char c; \ - _Complex type x; \ + type _Complex x; \ }; \ maybe_const ffi_type ffi_type_complex_##name = { \ sizeof(_Complex type), \ @@ -58,6 +59,24 @@ maybe_const ffi_type ffi_type_complex_##name = { \ FFI_TYPE_COMPLEX, \ (ffi_type **)ffi_elements_complex_##name \ } +#else +/* Bogus definition for compilers without C99 complex support. */ +#define FFI_COMPLEX_TYPEDEF(name, type, maybe_const) \ +static ffi_type *ffi_elements_complex_##name [2] = { \ + (ffi_type *)(&ffi_type_##name), NULL \ +}; \ +struct struct_align_complex_##name { \ + char c; \ + type x; \ + type y; \ +}; \ +maybe_const ffi_type ffi_type_complex_##name = { \ + 2 * sizeof(type), \ + offsetof(struct struct_align_complex_##name, x), \ + FFI_TYPE_COMPLEX, \ + (ffi_type **)ffi_elements_complex_##name \ +} +#endif /* Size and alignment are fake here. They must not be 0. */ const ffi_type ffi_type_void = { -- 1.8.4.2 --T4sUOijqQbZv57TR--