This is the mail archive of the
libffi-discuss@sourceware.org
mailing list for the libffi project.
[RFC][PATCH 3/3] Complex type support (FFI_TYPE_COMPLEX)
- From: Dominik Vogt <vogt at linux dot vnet dot ibm dot com>
- To: libffi-discuss at sourceware dot org
- Date: Tue, 22 Jul 2014 10:36:35 +0100
- Subject: [RFC][PATCH 3/3] Complex type support (FFI_TYPE_COMPLEX)
- Authentication-results: sourceware.org; auth=none
- References: <20140722092734 dot GA23937 at linux dot vnet dot ibm dot com>
- Reply-to: vogt at linux dot vnet dot ibm dot com
ChangeLog:
--
2014-07-22 Dominik Vogt <vogt@linux.vnet.ibm.com>
* src/s390/ffitarget.h (FFI_TARGET_HAS_COMPLEX_TYPE): Define to provide
FFI_TYPE_COMPLEX support.
* src/s390/ffi.c (ffi_check_struct_type): Implement FFI_TYPE_COMPLEX
(ffi_prep_args): Ditto.
(ffi_prep_cif_machdep): Ditto.
(ffi_closure_helper_SYSV): Ditto.
--
Ciao
Dominik ^_^ ^_^
--
Dominik Vogt
IBM Germany
>From 2fce72b95c240c35248df92e541d8596369ece53 Mon Sep 17 00:00:00 2001
From: Dominik Vogt <vogt@de.ibm.com>
Date: Tue, 22 Jul 2014 10:04:41 +0100
Subject: [PATCH 3/3] S390: Implement FFI_TYPE_COMPLEX
---
src/s390/ffi.c | 25 ++++++++++++++++++-------
src/s390/ffitarget.h | 1 +
2 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/src/s390/ffi.c b/src/s390/ffi.c
index 8adb5bc..520ec7c 100644
--- a/src/s390/ffi.c
+++ b/src/s390/ffi.c
@@ -215,9 +215,12 @@ ffi_prep_args (unsigned char *stack, extended_cif *ecif)
#endif
/* Check how a structure type is passed. */
- if (type == FFI_TYPE_STRUCT)
+ if (type == FFI_TYPE_STRUCT || type == FFI_TYPE_COMPLEX)
{
- type = ffi_check_struct_type (*ptr);
+ if (type == FFI_TYPE_COMPLEX)
+ type = FFI_TYPE_POINTER;
+ else
+ type = ffi_check_struct_type (*ptr);
/* If we pass the struct via pointer, copy the data. */
if (type == FFI_TYPE_POINTER)
@@ -356,8 +359,9 @@ ffi_prep_cif_machdep(ffi_cif *cif)
cif->flags = FFI390_RET_VOID;
break;
- /* Structures are returned via a hidden pointer. */
+ /* Structures and complex are returned via a hidden pointer. */
case FFI_TYPE_STRUCT:
+ case FFI_TYPE_COMPLEX:
cif->flags = FFI390_RET_STRUCT;
n_gpr++; /* We need one GPR to pass the pointer. */
break;
@@ -420,9 +424,12 @@ ffi_prep_cif_machdep(ffi_cif *cif)
#endif
/* Check how a structure type is passed. */
- if (type == FFI_TYPE_STRUCT)
+ if (type == FFI_TYPE_STRUCT || type == FFI_TYPE_COMPLEX)
{
- type = ffi_check_struct_type (*ptr);
+ if (type == FFI_TYPE_COMPLEX)
+ type = FFI_TYPE_POINTER;
+ else
+ type = ffi_check_struct_type (*ptr);
/* If we pass the struct via pointer, we must reserve space
to copy its data for proper call-by-value semantics. */
@@ -588,9 +595,12 @@ ffi_closure_helper_SYSV (ffi_closure *closure,
#endif
/* Check how a structure type is passed. */
- if (type == FFI_TYPE_STRUCT)
+ if (type == FFI_TYPE_STRUCT || type == FFI_TYPE_COMPLEX)
{
- type = ffi_check_struct_type (*ptr);
+ if (type == FFI_TYPE_COMPLEX)
+ type = FFI_TYPE_POINTER;
+ else
+ type = ffi_check_struct_type (*ptr);
/* If we pass the struct via pointer, remember to
retrieve the pointer later. */
@@ -687,6 +697,7 @@ ffi_closure_helper_SYSV (ffi_closure *closure,
/* Void is easy, and so is struct. */
case FFI_TYPE_VOID:
case FFI_TYPE_STRUCT:
+ case FFI_TYPE_COMPLEX:
#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
case FFI_TYPE_LONGDOUBLE:
#endif
diff --git a/src/s390/ffitarget.h b/src/s390/ffitarget.h
index 7700f26..0e4868a 100644
--- a/src/s390/ffitarget.h
+++ b/src/s390/ffitarget.h
@@ -53,6 +53,7 @@ typedef enum ffi_abi {
#endif
#define FFI_TARGET_SPECIFIC_STACK_SPACE_ALLOCATION
+#define FFI_TARGET_HAS_COMPLEX_TYPE
/* ---- Definitions for closures ----------------------------------------- */
--
1.8.4.2