From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18189 invoked by alias); 29 Oct 2014 20:06:00 -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 18177 invoked by uid 89); 29 Oct 2014 20:06:00 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-qg0-f49.google.com Received: from mail-qg0-f49.google.com (HELO mail-qg0-f49.google.com) (209.85.192.49) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 29 Oct 2014 20:05:59 +0000 Received: by mail-qg0-f49.google.com with SMTP id z60so86908qgd.8 for ; Wed, 29 Oct 2014 13:05:56 -0700 (PDT) X-Received: by 10.140.109.244 with SMTP id l107mr17953419qgf.80.1414613156652; Wed, 29 Oct 2014 13:05:56 -0700 (PDT) Received: from pike.twiddle.home.com (50-194-63-110-static.hfc.comcastbusiness.net. [50.194.63.110]) by mx.google.com with ESMTPSA id a12sm5020495qai.1.2014.10.29.13.05.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Oct 2014 13:05:55 -0700 (PDT) From: Richard Henderson To: libffi-discuss@sourceware.org Subject: [PATCH 02/10] arm: Deref ffi_align argument Date: Wed, 29 Oct 2014 20:06:00 -0000 Message-Id: <1414613147-10917-3-git-send-email-rth@twiddle.net> In-Reply-To: <1414613147-10917-1-git-send-email-rth@twiddle.net> References: <1414613147-10917-1-git-send-email-rth@twiddle.net> X-SW-Source: 2014/txt/msg00161.txt.bz2 --- 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