From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11681 invoked by alias); 18 Dec 2014 21:33:42 -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 11488 invoked by uid 89); 18 Dec 2014 21:33:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 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-qa0-f42.google.com Received: from mail-qa0-f42.google.com (HELO mail-qa0-f42.google.com) (209.85.216.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 18 Dec 2014 21:33:40 +0000 Received: by mail-qa0-f42.google.com with SMTP id n8so163448qaq.29 for ; Thu, 18 Dec 2014 13:33:38 -0800 (PST) X-Received: by 10.224.115.145 with SMTP id i17mr7985644qaq.9.1418938418007; Thu, 18 Dec 2014 13:33:38 -0800 (PST) Received: from pike.twiddle.home.com (187-254-17-144-cable.cybercable.net.mx. [187.254.17.144]) by mx.google.com with ESMTPSA id f11sm1579590qga.42.2014.12.18.13.33.36 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 18 Dec 2014 13:33:37 -0800 (PST) From: Richard Henderson To: libffi-discuss@sourceware.org Cc: Ulrich.Weigand@de.ibm.com, vogt@linux.vnet.ibm.com, krebbel@linux.vnet.ibm.com, Richard Henderson Subject: [PATCH 2/4] s390: Avoid aliasing warnings Date: Thu, 18 Dec 2014 21:33:00 -0000 Message-Id: <1418938403-15836-3-git-send-email-rth@twiddle.net> In-Reply-To: <1418938403-15836-1-git-send-email-rth@twiddle.net> References: <1418938403-15836-1-git-send-email-rth@twiddle.net> X-SW-Source: 2014/txt/msg00266.txt.bz2 From: Richard Henderson --- src/s390/ffi.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/s390/ffi.c b/src/s390/ffi.c index b0c3092..c06b79e 100644 --- a/src/s390/ffi.c +++ b/src/s390/ffi.c @@ -762,29 +762,28 @@ ffi_prep_closure_loc (ffi_closure *closure, void *user_data, void *codeloc) { - if (cif->abi != FFI_SYSV) - return FFI_BAD_ABI; - + static unsigned short const template[] = { + 0x0d10, /* basr %r1,0 */ #ifndef __s390x__ - *(short *)&closure->tramp [0] = 0x0d10; /* basr %r1,0 */ - *(short *)&closure->tramp [2] = 0x9801; /* lm %r0,%r1,6(%r1) */ - *(short *)&closure->tramp [4] = 0x1006; - *(short *)&closure->tramp [6] = 0x07f1; /* br %r1 */ - *(long *)&closure->tramp [8] = (long)codeloc; - *(long *)&closure->tramp[12] = (long)&ffi_closure_SYSV; + 0x9801, 0x1006, /* lm %r0,%r1,6(%r1) */ #else - *(short *)&closure->tramp [0] = 0x0d10; /* basr %r1,0 */ - *(short *)&closure->tramp [2] = 0xeb01; /* lmg %r0,%r1,14(%r1) */ - *(short *)&closure->tramp [4] = 0x100e; - *(short *)&closure->tramp [6] = 0x0004; - *(short *)&closure->tramp [8] = 0x07f1; /* br %r1 */ - *(long *)&closure->tramp[16] = (long)codeloc; - *(long *)&closure->tramp[24] = (long)&ffi_closure_SYSV; + 0xeb01, 0x100e, 0x0004, /* lmg %r0,%r1,14(%r1) */ #endif + 0x07f1 /* br %r1 */ + }; + + unsigned long *tramp = (unsigned long *)&closure->tramp; + + if (cif->abi != FFI_SYSV) + return FFI_BAD_ABI; + + memcpy (tramp, template, sizeof(template)); + tramp[2] = (unsigned long)codeloc; + tramp[3] = (unsigned long)&ffi_closure_SYSV; closure->cif = cif; - closure->user_data = user_data; closure->fun = fun; + closure->user_data = user_data; return FFI_OK; } -- 2.1.0