public inbox for libffi-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Dominik Vogt <vogt@linux.vnet.ibm.com>
To: libffi-discuss@sourceware.org
Subject: [RFC][PATCH 1/3] Complex type support (FFI_TYPE_COMPLEX)
Date: Tue, 22 Jul 2014 09:35:00 -0000	[thread overview]
Message-ID: <20140722093534.GA30068@linux.vnet.ibm.com> (raw)
In-Reply-To: <20140722092734.GA23937@linux.vnet.ibm.com>

[-- Attachment #1: Type: text/plain, Size: 689 bytes --]

ChangeLog:

--
2014-07-22  Dominik Vogt  <vogt@linux.vnet.ibm.com>

	* 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

[-- Attachment #2: 0001-Somewhat-reduce-the-macro-hell.patch --]
[-- Type: text/x-diff, Size: 5086 bytes --]

From 3d67e987080a73847034d1b700c7e8bf0e717ded Mon Sep 17 00:00:00 2001
From: Dominik Vogt <vogt@de.ibm.com>
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


  reply	other threads:[~2014-07-22  9:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-22  9:27 [RFC][PATCH 0/3] " Dominik Vogt
2014-07-22  9:35 ` Dominik Vogt [this message]
2014-07-23  8:41   ` [RFC][PATCH 1/3] " Dominik Vogt
2014-07-22  9:36 ` [RFC][PATCH 3/3] " Dominik Vogt
2014-07-22  9:36 ` [RFC][PATCH 2/3] " Dominik Vogt
2014-09-23 13:17   ` Alan Lawrence
2014-08-20  6:57 ` [PING][RFC][PATCH 0/3] " Dominik Vogt
2014-09-20 10:31 ` [RFC][PATCH " Anthony Green
2014-09-29 10:24   ` Dominik Vogt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140722093534.GA30068@linux.vnet.ibm.com \
    --to=vogt@linux.vnet.ibm.com \
    --cc=libffi-discuss@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).