From: Richard Henderson <rth@twiddle.net>
To: libffi-discuss@sourceware.org
Subject: [PATCH 02/10] arm: Deref ffi_align argument
Date: Wed, 29 Oct 2014 20:06:00 -0000 [thread overview]
Message-ID: <1414613147-10917-3-git-send-email-rth@twiddle.net> (raw)
In-Reply-To: <1414613147-10917-1-git-send-email-rth@twiddle.net>
---
src/arm/ffi.c | 41 +++++++++++++++--------------------------
1 file changed, 15 insertions(+), 26 deletions(-)
diff --git a/src/arm/ffi.c b/src/arm/ffi.c
index c5fd831..7d86e94 100644
--- a/src/arm/ffi.c
+++ b/src/arm/ffi.c
@@ -40,30 +40,19 @@ static void layout_vfp_args (ffi_cif *);
int ffi_prep_args_SYSV (char *stack, extended_cif *ecif, float *vfp_space);
int ffi_prep_args_VFP (char *stack, extended_cif *ecif, float *vfp_space);
-static char *
-ffi_align (ffi_type **p_arg, char *argp)
+static void *
+ffi_align (ffi_type *ty, void *p)
{
/* Align if necessary */
- register size_t alignment = (*p_arg)->alignment;
- if (alignment < 4)
- {
- alignment = 4;
- }
+ size_t alignment;
#ifdef _WIN32_WCE
- if (alignment > 4)
- {
- alignment = 4;
- }
+ alignment = 4;
+#else
+ alignment = ty->alignment;
+ if (alignment < 4)
+ alignment = 4;
#endif
- if ((alignment - 1) & (unsigned) argp)
- {
- argp = (char *) ALIGN (argp, alignment);
- }
- if ((*p_arg)->type == FFI_TYPE_STRUCT)
- {
- argp = (char *) ALIGN (argp, 4);
- }
- return argp;
+ return (void *) ALIGN (p, alignment);
}
static size_t
@@ -148,7 +137,7 @@ ffi_prep_args_SYSV (char *stack, extended_cif *ecif, float *vfp_space)
for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types;
(i != 0); i--, p_arg++, p_argv++)
{
- argp = ffi_align (p_arg, argp);
+ argp = ffi_align (*p_arg, argp);
argp += ffi_put_arg (p_arg, p_argv, argp);
}
@@ -199,7 +188,7 @@ ffi_prep_args_VFP (char *stack, extended_cif * ecif, float *vfp_space)
/* Try allocating in core registers. */
else if (!done_with_regs && !is_vfp_type)
{
- char *tregp = ffi_align (p_arg, regp);
+ char *tregp = ffi_align (*p_arg, regp);
size_t size = (*p_arg)->size;
size = (size < 4) ? 4 : size; // pad
/* Check if there is space left in the aligned register
@@ -226,7 +215,7 @@ ffi_prep_args_VFP (char *stack, extended_cif * ecif, float *vfp_space)
}
/* Base case, arguments are passed on the stack */
stack_used = 1;
- argp = ffi_align (p_arg, argp);
+ argp = ffi_align (*p_arg, argp);
argp += ffi_put_arg (p_arg, p_argv, argp);
}
/* Indicate the VFP registers used. */
@@ -440,7 +429,7 @@ ffi_prep_incoming_args_SYSV (char *stack, void **rvalue,
{
size_t z;
- argp = ffi_align (p_arg, argp);
+ argp = ffi_align (*p_arg, argp);
z = (*p_arg)->size;
@@ -495,7 +484,7 @@ ffi_prep_incoming_args_VFP (char *stack, void **rvalue,
}
else if (!done_with_regs && !is_vfp_type)
{
- char *tregp = ffi_align (p_arg, regp);
+ char *tregp = ffi_align (*p_arg, regp);
z = (*p_arg)->size;
z = (z < 4) ? 4 : z; // pad
@@ -530,7 +519,7 @@ ffi_prep_incoming_args_VFP (char *stack, void **rvalue,
}
stack_used = 1;
- argp = ffi_align (p_arg, argp);
+ argp = ffi_align (*p_arg, argp);
z = (*p_arg)->size;
--
1.9.3
next prev parent reply other threads:[~2014-10-29 20:06 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-29 20:05 [PATCH 00/10] Go closures for arm Richard Henderson
2014-10-29 20:06 ` [PATCH 01/10] arm: Reindent arm/ffi.c Richard Henderson
2014-10-29 20:06 ` [PATCH 09/10] arm: Add argument space for the hidden struct return pointer Richard Henderson
2014-10-29 20:06 ` [PATCH 06/10] arm: Rewrite ffi_closure Richard Henderson
2014-10-29 20:06 ` [PATCH 07/10] arm: Remove internal FFI_TYPE constants Richard Henderson
2014-10-29 20:06 ` [PATCH 03/10] arm: Deref ffi_put_arg arguments Richard Henderson
2014-10-29 20:06 ` [PATCH 05/10] arm: Rewrite ffi_call Richard Henderson
2014-10-29 20:06 ` [PATCH 04/10] arm: Rewrite vfp_type_p Richard Henderson
2014-10-29 20:06 ` [PATCH 10/10] arm: Add support for Go closures Richard Henderson
2014-10-29 20:06 ` Richard Henderson [this message]
2014-10-29 20:06 ` [PATCH 08/10] arm: Add support for complex types 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=1414613147-10917-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).