From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8303 invoked by alias); 7 Nov 2014 15:30:59 -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 8237 invoked by uid 89); 7 Nov 2014 15:30:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 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-wi0-f176.google.com Received: from mail-wi0-f176.google.com (HELO mail-wi0-f176.google.com) (209.85.212.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Fri, 07 Nov 2014 15:30:57 +0000 Received: by mail-wi0-f176.google.com with SMTP id h11so4934202wiw.3 for ; Fri, 07 Nov 2014 07:30:54 -0800 (PST) X-Received: by 10.180.98.169 with SMTP id ej9mr6143617wib.1.1415374254471; Fri, 07 Nov 2014 07:30:54 -0800 (PST) Received: from pike.twiddle.home.com ([87.111.149.167]) by mx.google.com with ESMTPSA id p1sm12186731wjy.22.2014.11.07.07.30.53 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Nov 2014 07:30:54 -0800 (PST) From: Richard Henderson To: libffi-discuss@sourceware.org Subject: [PATCH 02/13] x86: Remove some conditional compilation Date: Fri, 07 Nov 2014 15:30:00 -0000 Message-Id: <1415374240-1792-3-git-send-email-rth@twiddle.net> In-Reply-To: <1415374240-1792-1-git-send-email-rth@twiddle.net> References: <1415374240-1792-1-git-send-email-rth@twiddle.net> X-SW-Source: 2014/txt/msg00190.txt.bz2 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