From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26436 invoked by alias); 22 Jul 2014 09:35:47 -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 26401 invoked by uid 89); 22 Jul 2014 09:35:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: e06smtp17.uk.ibm.com Received: from e06smtp17.uk.ibm.com (HELO e06smtp17.uk.ibm.com) (195.75.94.113) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Tue, 22 Jul 2014 09:35:42 +0000 Received: from /spool/local by e06smtp17.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 22 Jul 2014 10:35:39 +0100 Received: from d06dlp01.portsmouth.uk.ibm.com (9.149.20.13) by e06smtp17.uk.ibm.com (192.168.101.147) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 22 Jul 2014 10:35:36 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (d06relay12.portsmouth.uk.ibm.com [9.149.109.197]) by d06dlp01.portsmouth.uk.ibm.com (Postfix) with ESMTP id 14EEB17D805A for ; Tue, 22 Jul 2014 10:37:15 +0100 (BST) Received: from d06av05.portsmouth.uk.ibm.com (d06av05.portsmouth.uk.ibm.com [9.149.37.229]) by b06cxnps4075.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id s6M9ZZRY33685514 for ; Tue, 22 Jul 2014 09:35:35 GMT Received: from d06av05.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av05.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id s6M9ZZEP027072 for ; Tue, 22 Jul 2014 03:35:35 -0600 Received: from bl3ahm9f.de.ibm.com (dyn-9-152-212-179.boeblingen.de.ibm.com [9.152.212.179]) by d06av05.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id s6M9ZZUq027066 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Tue, 22 Jul 2014 03:35:35 -0600 Received: from dvogt by bl3ahm9f.de.ibm.com with local (Exim 4.76) (envelope-from ) id 1X9WTv-0007rS-0m; Tue, 22 Jul 2014 11:35:35 +0200 Date: Tue, 22 Jul 2014 09:35:00 -0000 From: Dominik Vogt To: libffi-discuss@sourceware.org Subject: [RFC][PATCH 1/3] Complex type support (FFI_TYPE_COMPLEX) Message-ID: <20140722093534.GA30068@linux.vnet.ibm.com> Reply-To: vogt@linux.vnet.ibm.com References: <20140722092734.GA23937@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="C7zPtVaVf+AK4Oqc" Content-Disposition: inline In-Reply-To: <20140722092734.GA23937@linux.vnet.ibm.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14072209-0542-0000-0000-0000001E9C20 X-IsSubscribed: yes X-SW-Source: 2014/txt/msg00072.txt.bz2 --C7zPtVaVf+AK4Oqc Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 689 ChangeLog: -- 2014-07-22 Dominik Vogt * src/types.c (FFI_TYPEDEF, FFI_NONCONST_TYPEDEF): Merge the macros by adding another argument that controls whether the result is const or not (FFI_LDBL_CONST): Temporary macro to reduce ifdef confusion * src/prep_cif.c (ffi_prep_cif_core): Replace list of systems with new macro FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION * src/pa/ffitarget.h (FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION): Define. * src/s390/ffitarget.h (FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION): Define. * src/x86/ffitarget.h (FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION): Define. -- Ciao Dominik ^_^ ^_^ -- Dominik Vogt IBM Germany --C7zPtVaVf+AK4Oqc Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-Somewhat-reduce-the-macro-hell.patch" Content-length: 5087 >From 3d67e987080a73847034d1b700c7e8bf0e717ded Mon Sep 17 00:00:00 2001 From: Dominik Vogt Date: Tue, 22 Jul 2014 09:59:35 +0100 Subject: [PATCH 1/3] Somewhat reduce the macro hell. --- src/pa/ffitarget.h | 2 ++ src/prep_cif.c | 4 ++-- src/s390/ffitarget.h | 1 + src/types.c | 49 ++++++++++++++++++++----------------------------- src/x86/ffitarget.h | 2 ++ 5 files changed, 27 insertions(+), 31 deletions(-) diff --git a/src/pa/ffitarget.h b/src/pa/ffitarget.h index 5e364d3..fff4c6b 100644 --- a/src/pa/ffitarget.h +++ b/src/pa/ffitarget.h @@ -62,6 +62,8 @@ typedef enum ffi_abi { } ffi_abi; #endif +#define FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION + /* ---- Definitions for closures ----------------------------------------- */ #define FFI_CLOSURES 1 diff --git a/src/prep_cif.c b/src/prep_cif.c index 55ceed8..955bac1 100644 --- a/src/prep_cif.c +++ b/src/prep_cif.c @@ -140,7 +140,7 @@ ffi_status FFI_HIDDEN ffi_prep_cif_core(ffi_cif *cif, ffi_abi abi, FFI_ASSERT_VALID_TYPE(cif->rtype); /* x86, x86-64 and s390 stack space allocation is handled in prep_machdep. */ -#if !defined M68K && !defined X86_ANY && !defined S390 && !defined PA +#if !defined FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION /* Make space for the return structure pointer */ if (cif->rtype->type == FFI_TYPE_STRUCT #ifdef SPARC @@ -170,7 +170,7 @@ ffi_status FFI_HIDDEN ffi_prep_cif_core(ffi_cif *cif, ffi_abi abi, check after the initialization. */ FFI_ASSERT_VALID_TYPE(*ptr); -#if !defined X86_ANY && !defined S390 && !defined PA +#if !defined FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION #ifdef SPARC if (((*ptr)->type == FFI_TYPE_STRUCT && ((*ptr)->size > 16 || cif->abi != FFI_V9)) diff --git a/src/s390/ffitarget.h b/src/s390/ffitarget.h index 97fa5c4..7700f26 100644 --- a/src/s390/ffitarget.h +++ b/src/s390/ffitarget.h @@ -52,6 +52,7 @@ typedef enum ffi_abi { } ffi_abi; #endif +#define FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION /* ---- Definitions for closures ----------------------------------------- */ diff --git a/src/types.c b/src/types.c index 0de5994..e32e111 100644 --- a/src/types.c +++ b/src/types.c @@ -33,23 +33,12 @@ /* Type definitions */ -#define FFI_TYPEDEF(name, type, id) \ +#define FFI_TYPEDEF(name, type, id, maybe_const)\ struct struct_align_##name { \ char c; \ type x; \ }; \ -const ffi_type ffi_type_##name = { \ - sizeof(type), \ - offsetof(struct struct_align_##name, x), \ - id, NULL \ -} - -#define FFI_NONCONST_TYPEDEF(name, type, id) \ -struct struct_align_##name { \ - char c; \ - type x; \ -}; \ -ffi_type ffi_type_##name = { \ +maybe_const ffi_type ffi_type_##name = { \ sizeof(type), \ offsetof(struct struct_align_##name, x), \ id, NULL \ @@ -60,19 +49,25 @@ const ffi_type ffi_type_void = { 1, 1, FFI_TYPE_VOID, NULL }; -FFI_TYPEDEF(uint8, UINT8, FFI_TYPE_UINT8); -FFI_TYPEDEF(sint8, SINT8, FFI_TYPE_SINT8); -FFI_TYPEDEF(uint16, UINT16, FFI_TYPE_UINT16); -FFI_TYPEDEF(sint16, SINT16, FFI_TYPE_SINT16); -FFI_TYPEDEF(uint32, UINT32, FFI_TYPE_UINT32); -FFI_TYPEDEF(sint32, SINT32, FFI_TYPE_SINT32); -FFI_TYPEDEF(uint64, UINT64, FFI_TYPE_UINT64); -FFI_TYPEDEF(sint64, SINT64, FFI_TYPE_SINT64); +FFI_TYPEDEF(uint8, UINT8, FFI_TYPE_UINT8, const); +FFI_TYPEDEF(sint8, SINT8, FFI_TYPE_SINT8, const); +FFI_TYPEDEF(uint16, UINT16, FFI_TYPE_UINT16, const); +FFI_TYPEDEF(sint16, SINT16, FFI_TYPE_SINT16, const); +FFI_TYPEDEF(uint32, UINT32, FFI_TYPE_UINT32, const); +FFI_TYPEDEF(sint32, SINT32, FFI_TYPE_SINT32, const); +FFI_TYPEDEF(uint64, UINT64, FFI_TYPE_UINT64, const); +FFI_TYPEDEF(sint64, SINT64, FFI_TYPE_SINT64, const); -FFI_TYPEDEF(pointer, void*, FFI_TYPE_POINTER); +FFI_TYPEDEF(pointer, void*, FFI_TYPE_POINTER, const); -FFI_TYPEDEF(float, float, FFI_TYPE_FLOAT); -FFI_TYPEDEF(double, double, FFI_TYPE_DOUBLE); +FFI_TYPEDEF(float, float, FFI_TYPE_FLOAT, const); +FFI_TYPEDEF(double, double, FFI_TYPE_DOUBLE, const); + +#if !defined HAVE_LONG_DOUBLE_VARIANT || defined __alpha__ +#define FFI_LDBL_CONST const +#else +#define FFI_LDBL_CONST +#endif #ifdef __alpha__ /* Even if we're not configured to default to 128-bit long double, @@ -84,9 +79,5 @@ FFI_TYPEDEF(double, double, FFI_TYPE_DOUBLE); # endif const ffi_type ffi_type_longdouble = { 16, 16, 4, NULL }; #elif FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE -# if HAVE_LONG_DOUBLE_VARIANT -FFI_NONCONST_TYPEDEF(longdouble, long double, FFI_TYPE_LONGDOUBLE); -# else -FFI_TYPEDEF(longdouble, long double, FFI_TYPE_LONGDOUBLE); -# endif +FFI_TYPEDEF(longdouble, long double, FFI_TYPE_LONGDOUBLE, FFI_LDBL_CONST); #endif diff --git a/src/x86/ffitarget.h b/src/x86/ffitarget.h index b2afe91..9cc53cf 100644 --- a/src/x86/ffitarget.h +++ b/src/x86/ffitarget.h @@ -49,6 +49,8 @@ #define USE_BUILTIN_FFS 0 /* not yet implemented in mingw-64 */ #endif +#define FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION + /* ---- Generic type definitions ----------------------------------------- */ #ifndef LIBFFI_ASM -- 1.8.4.2 --C7zPtVaVf+AK4Oqc--