From: Richard Henderson <rth@twiddle.net>
To: libffi-discuss@sourceware.org
Subject: [PATCH 02/13] x86: Remove some conditional compilation
Date: Fri, 07 Nov 2014 15:30:00 -0000 [thread overview]
Message-ID: <1415374240-1792-3-git-send-email-rth@twiddle.net> (raw)
In-Reply-To: <1415374240-1792-1-git-send-email-rth@twiddle.net>
Removal of ifdefs made possible to due to ffi_abi unification.
---
src/x86/ffi.c | 81 +++++++++++++++++++++++------------------------------------
1 file changed, 32 insertions(+), 49 deletions(-)
diff --git a/src/x86/ffi.c b/src/x86/ffi.c
index 90e3f79..98aa008 100644
--- a/src/x86/ffi.c
+++ b/src/x86/ffi.c
@@ -217,34 +217,25 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
case FFI_TYPE_STRUCT:
#ifndef X86
+ /* ??? This should be a different ABI rather than an ifdef. */
if (cif->rtype->size == 1)
- {
- cif->flags = FFI_TYPE_SMALL_STRUCT_1B; /* same as char size */
- }
+ cif->flags = FFI_TYPE_SMALL_STRUCT_1B; /* same as char size */
else if (cif->rtype->size == 2)
- {
- cif->flags = FFI_TYPE_SMALL_STRUCT_2B; /* same as short size */
- }
+ cif->flags = FFI_TYPE_SMALL_STRUCT_2B; /* same as short size */
else if (cif->rtype->size == 4)
- {
- cif->flags = FFI_TYPE_INT; /* same as int type */
- }
+ cif->flags = FFI_TYPE_INT; /* same as int type */
else if (cif->rtype->size == 8)
- {
- cif->flags = FFI_TYPE_SINT64; /* same as int64 type */
- }
+ cif->flags = FFI_TYPE_SINT64; /* same as int64 type */
else
#endif
- {
-#ifdef X86_WIN32
- if (cif->abi == FFI_MS_CDECL)
- cif->flags = FFI_TYPE_MS_STRUCT;
- else
-#endif
- cif->flags = FFI_TYPE_STRUCT;
- /* allocate space for return value pointer */
- cif->bytes += ALIGN(sizeof(void*), FFI_SIZEOF_ARG);
- }
+ {
+ if (cif->abi == FFI_MS_CDECL)
+ cif->flags = FFI_TYPE_MS_STRUCT;
+ else
+ cif->flags = FFI_TYPE_STRUCT;
+ /* Allocate space for return value pointer. */
+ cif->bytes += ALIGN(sizeof(void*), FFI_SIZEOF_ARG);
+ }
break;
default:
@@ -259,10 +250,8 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
cif->bytes += (unsigned)ALIGN((*ptr)->size, FFI_SIZEOF_ARG);
}
-#ifndef X86_WIN32
if (cif->abi == FFI_SYSV)
- cif->bytes = (cif->bytes + 15) & ~0xF;
-#endif
+ cif->bytes = ALIGN (cif->bytes, 15);
return FFI_OK;
}
@@ -577,14 +566,12 @@ ffi_prep_closure_loc (ffi_closure* closure,
&ffi_closure_STDCALL,
(void*)codeloc);
}
-#ifdef X86_WIN32
else if (cif->abi == FFI_MS_CDECL)
{
FFI_INIT_TRAMPOLINE (&closure->tramp[0],
&ffi_closure_SYSV,
(void*)codeloc);
}
-#endif /* X86_WIN32 */
else
{
return FFI_BAD_ABI;
@@ -610,40 +597,36 @@ ffi_prep_raw_closure_loc (ffi_raw_closure* closure,
{
int i;
- if (cif->abi != FFI_SYSV
-#ifdef X86_WIN32
- && cif->abi != FFI_THISCALL
-#endif
- )
- return FFI_BAD_ABI;
-
- /* we currently don't support certain kinds of arguments for raw
+ /* We currently don't support certain kinds of arguments for raw
closures. This should be implemented by a separate assembly
language routine, since it would require argument processing,
something we don't do now for performance. */
-
for (i = cif->nargs-1; i >= 0; i--)
{
FFI_ASSERT (cif->arg_types[i]->type != FFI_TYPE_STRUCT);
FFI_ASSERT (cif->arg_types[i]->type != FFI_TYPE_LONGDOUBLE);
}
-
-#ifdef X86_WIN32
- if (cif->abi == FFI_SYSV)
+
+ switch (cif->abi)
{
-#endif
- FFI_INIT_TRAMPOLINE (&closure->tramp[0], &ffi_closure_raw_SYSV,
- codeloc);
#ifdef X86_WIN32
- }
- else if (cif->abi == FFI_THISCALL)
- {
- FFI_INIT_TRAMPOLINE_RAW_THISCALL (&closure->tramp[0], &ffi_closure_raw_THISCALL, codeloc, cif->bytes);
- }
+ case FFI_THISCALL:
+ FFI_INIT_TRAMPOLINE_RAW_THISCALL (&closure->tramp[0],
+ &ffi_closure_raw_THISCALL,
+ codeloc, cif->bytes);
+ break;
#endif
- closure->cif = cif;
+ case FFI_SYSV:
+ FFI_INIT_TRAMPOLINE (&closure->tramp[0], &ffi_closure_raw_SYSV,
+ codeloc);
+ break;
+ default:
+ return FFI_BAD_ABI;
+ }
+
+ closure->cif = cif;
+ closure->fun = fun;
closure->user_data = user_data;
- closure->fun = fun;
return FFI_OK;
}
--
1.9.3
next prev parent reply other threads:[~2014-11-07 15:30 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-07 15:30 [PATCH 00/13] Go closures for i686 Richard Henderson
2014-11-07 15:30 ` Richard Henderson [this message]
2014-11-07 15:31 ` [PATCH 11/13] x86: Use win32 name mangling for fastcall functions Richard Henderson
2014-11-07 15:31 ` [PATCH 09/13] x86: Add support for Complex Richard Henderson
2014-11-07 15:31 ` [PATCH 07/13] x86: Rewrite closures Richard Henderson
2014-11-07 15:31 ` [PATCH 10/13] x86: Add support for Go closures Richard Henderson
2014-11-07 15:31 ` [PATCH 12/13] testsuite: Add two dg-do run markers Richard Henderson
2014-11-07 15:31 ` [PATCH 05/13] ffi_cif: Add cfa_escape Richard Henderson
2014-11-07 15:31 ` [PATCH 06/13] x86: Rewrite ffi_call Richard Henderson
2014-11-07 15:31 ` [PATCH 08/13] testsuite: Fix return_complex2 vs excessive precision Richard Henderson
2014-11-07 15:31 ` [PATCH 01/13] x86: Tidy ffi_abi Richard Henderson
2014-11-07 15:31 ` [PATCH 13/13] x86: Work around two clang assembler bugs Richard Henderson
2014-11-07 15:31 ` [PATCH 03/13] x86: Force FFI_TYPE_LONGDOUBLE different from FFI_TYPE_DOUBLE Richard Henderson
2014-11-07 15:31 ` [PATCH 04/13] x86: Convert to gas generated unwind info Richard Henderson
2014-11-07 16:09 ` [PATCH 00/13] Go closures for i686 Richard Henderson
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=1415374240-1792-3-git-send-email-rth@twiddle.net \
--to=rth@twiddle.net \
--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).