From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 70779 invoked by alias); 27 May 2017 16:59:40 -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 70712 invoked by uid 89); 27 May 2017 16:59:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.2 required=5.0 tests=BAYES_50,FROM_STARTS_WITH_NUMS,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=H*RU:70.79.163.252, Hx-spam-relays-external:70.79.163.252, H*r:ip*70.79.163.252, H*r:70.79.163 X-HELO: smtp-out-no.shaw.ca Received: from smtp-out-no.shaw.ca (HELO smtp-out-no.shaw.ca) (64.59.134.13) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 27 May 2017 16:59:37 +0000 Received: from kylheku.com ([70.79.163.252]) by shaw.ca with SMTP id Ef3ydGzdhETFpEf3zd1eW3; Sat, 27 May 2017 10:59:39 -0600 X-Authority-Analysis: v=2.2 cv=dZbw5Tfe c=1 sm=1 tr=0 a=95A0EdhkF1LMGt25d7h1IQ==:117 a=95A0EdhkF1LMGt25d7h1IQ==:17 a=IkcTkHD0fZMA:10 a=SMorJkV_YP8A:10 a=tJ8p9aeEuA8A:10 a=HSA7JkM5AAAA:8 a=c0pyil04e_byCgDhQH4A:9 a=fmL_s9g3-wQLF5y9:21 a=Jx09aTwsXEIs73h4:21 a=QEXdDO2ut3YA:10 a=j7xPYO-hN21jwmWY8xWy:22 Received: from www-data by kylheku.com with local (Exim 4.72) (envelope-from <382-725-6798@kylheku.com>) id 1dEf3w-00061T-TW for libffi-discuss@sourceware.org; Sat, 27 May 2017 09:59:36 -0700 To: libffi-discuss@sourceware.org Subject: Cosure return value issue on Linux PPC64 X-PHP-Originating-Script: 501:rcmail.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable Date: Sat, 27 May 2017 16:59:00 -0000 From: "Kaz Kylheku (libffi)" <382-725-6798@kylheku.com> Message-ID: <53985e874a349c551e7943677d21c766@mail.kylheku.com> X-Sender: 382-725-6798@kylheku.com User-Agent: Roundcube Webmail/0.9.2 X-CMAE-Envelope: MS4wfJMLgyMAE7mclC3/aCNkY5x3ZOj5IfzwzoAtmGEbPht0wDJufNq7aXo56ulIVc4DVaRAoG3OuE47evQhKmhPIzDmxFFq10fSu1okAs49EKtSRue/eKV2 JpZsRBtiyurjN69S4P6o6zVi8glkj546Y5Kwar887bR6Yv/mizq+zFVaBwX9TvspcHJd1f7gDpn6hg== X-IsSubscribed: yes X-SW-Source: 2017/txt/msg00004.txt.bz2 Hi all, My interpreted language's test suite failed on a PPC64 Linux box=20 (gcc110.fsffrance.org). The test in question uses the qsort C library function to sort a Lisp=20 vector, using a Lisp callback. Unfortunately, the int return value from the callback turns to garbage.=20= =20 The problem reproduces with current libffi from git. The following test patch makes the problem go away and all tests pass: diff --git a/src/powerpc/linux64_closure.S=20 b/src/powerpc/linux64_closure.S index 6487d2a..28a191a 100644 --- a/src/powerpc/linux64_closure.S +++ b/src/powerpc/linux64_closure.S @@ -27,7 +27,8 @@ #define LIBFFI_ASM #include #include - +#undef __LITTLE_ENDIAN__ +#define __LITTLE_ENDIAN__ 1 .file "linux64_closure.S" #ifdef POWERPC64 The problem is that all the big endian cases are expecting the caller to=20 place the return value at a displaced address. If the type is int, for=20 instance, the expectation is that the return value is to be stored at=20 *(int *)(retval + 4). If it is short, then at *(short *)(retval + 6)=20 and so on. Is this documented somewhere? My code is storing everything at just the retval base address,=20 regardless of size. Cheers ...