From debbugs-submit-bounces@debbugs.gnu.org Sat Dec 03 06:18:15 2011 Received: (at submit) by debbugs.gnu.org; 3 Dec 2011 11:18:15 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RWnbi-0005OF-Pt for submit@debbugs.gnu.org; Sat, 03 Dec 2011 06:18:14 -0500 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RWnbg-0005O8-KL for submit@debbugs.gnu.org; Sat, 03 Dec 2011 06:18:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RWnbL-0002dU-Bp for submit@debbugs.gnu.org; Sat, 03 Dec 2011 06:17:52 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([140.186.70.17]:42048) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RWnbL-0002dN-AM for submit@debbugs.gnu.org; Sat, 03 Dec 2011 06:17:51 -0500 Received: from eggs.gnu.org ([140.186.70.92]:56059) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RWnbK-00026R-H8 for bug-guile@gnu.org; Sat, 03 Dec 2011 06:17:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RWnbI-0002cn-K0 for bug-guile@gnu.org; Sat, 03 Dec 2011 06:17:50 -0500 Received: from mail-out.m-online.net ([212.18.0.9]:54019) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RWnbI-0002cV-A3 for bug-guile@gnu.org; Sat, 03 Dec 2011 06:17:48 -0500 Received: from frontend1.mail.m-online.net (unknown [192.168.8.180]) by mail-out.m-online.net (Postfix) with ESMTP id D55BF1C0C17E for ; Sat, 3 Dec 2011 12:17:46 +0100 (CET) X-Auth-Info: Zvb7ruJpj726w+ueGxibOV+UOGlx+zEt07A/1fnXmlQ= Received: from igel.home (ppp-93-104-149-66.dynamic.mnet-online.de [93.104.149.66]) by mail.mnet-online.de (Postfix) with ESMTPA id 8F6DD1C000BA for ; Sat, 3 Dec 2011 12:17:46 +0100 (CET) Received: by igel.home (Postfix, from userid 501) id 30658CA29C; Sat, 3 Dec 2011 12:17:46 +0100 (CET) From: Andreas Schwab To: bug-guile@gnu.org Subject: [PATCH] FFI: Properly unpack small integer return values in closure call X-Yow: LOU GRANT froze my ASSETS!! Date: Sat, 03 Dec 2011 12:17:46 +0100 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.17 X-Spam-Score: -4.6 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.6 (----) * libguile/foreign.c (unpack): Add parameter return_value_p. Properly store integer return values smaller than int. (scm_i_foreign_call): Update call to unpack. (invoke_closure): Likewise. --- libguile/foreign.c | 40 +++++++++++++++++++++++++++++++--------- 1 files changed, 31 insertions(+), 9 deletions(-) diff --git a/libguile/foreign.c b/libguile/foreign.c index bb88cf5..8351ae1 100644 --- a/libguile/foreign.c +++ b/libguile/foreign.c @@ -910,7 +910,7 @@ cif_to_procedure (SCM cif, SCM func_ptr) /* Set *LOC to the foreign representation of X with TYPE. */ static void -unpack (const ffi_type *type, void *loc, SCM x) +unpack (const ffi_type *type, void *loc, SCM x, int return_value_p) #define FUNC_NAME "scm_i_foreign_call" { switch (type->type) @@ -921,23 +921,45 @@ unpack (const ffi_type *type, void *loc, SCM x) case FFI_TYPE_DOUBLE: *(double *) loc = scm_to_double (x); break; + + /* For integer return values smaller than `int', libffi expects the + result in an `ffi_arg'-long buffer. */ + case FFI_TYPE_UINT8: - *(scm_t_uint8 *) loc = scm_to_uint8 (x); + if (return_value_p) + *(ffi_arg *) loc = scm_to_uint8 (x); + else + *(scm_t_uint8 *) loc = scm_to_uint8 (x); break; case FFI_TYPE_SINT8: - *(scm_t_int8 *) loc = scm_to_int8 (x); + if (return_value_p) + *(ffi_arg *) loc = scm_to_int8 (x); + else + *(scm_t_int8 *) loc = scm_to_int8 (x); break; case FFI_TYPE_UINT16: - *(scm_t_uint16 *) loc = scm_to_uint16 (x); + if (return_value_p) + *(ffi_arg *) loc = scm_to_uint16 (x); + else + *(scm_t_uint16 *) loc = scm_to_uint16 (x); break; case FFI_TYPE_SINT16: - *(scm_t_int16 *) loc = scm_to_int16 (x); + if (return_value_p) + *(ffi_arg *) loc = scm_to_int16 (x); + else + *(scm_t_int16 *) loc = scm_to_int16 (x); break; case FFI_TYPE_UINT32: - *(scm_t_uint32 *) loc = scm_to_uint32 (x); + if (return_value_p) + *(ffi_arg *) loc = scm_to_uint32 (x); + else + *(scm_t_uint32 *) loc = scm_to_uint32 (x); break; case FFI_TYPE_SINT32: - *(scm_t_int32 *) loc = scm_to_int32 (x); + if (return_value_p) + *(ffi_arg *) loc = scm_to_int32 (x); + else + *(scm_t_int32 *) loc = scm_to_int32 (x); break; case FFI_TYPE_UINT64: *(scm_t_uint64 *) loc = scm_to_uint64 (x); @@ -1073,7 +1095,7 @@ scm_i_foreign_call (SCM foreign, const SCM *argv) args[i] = (void *) ROUND_UP ((scm_t_uintptr) data + off, cif->arg_types[i]->alignment); assert ((scm_t_uintptr) args[i] % cif->arg_types[i]->alignment == 0); - unpack (cif->arg_types[i], args[i], argv[i]); + unpack (cif->arg_types[i], args[i], argv[i], 0); } /* Prepare space for the return value. On some platforms, such as @@ -1112,7 +1134,7 @@ invoke_closure (ffi_cif *cif, void *ret, void **args, void *data) result = scm_call_n (proc, argv, cif->nargs); - unpack (cif->rtype, ret, result); + unpack (cif->rtype, ret, result, 1); } SCM_DEFINE (scm_procedure_to_pointer, "procedure->pointer", 3, 0, 0, -- 1.7.7.4 -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." From debbugs-submit-bounces@debbugs.gnu.org Sun Dec 18 19:15:27 2011 Received: (at 10203-done) by debbugs.gnu.org; 19 Dec 2011 00:15:27 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RcQt5-0002Hi-B5 for submit@debbugs.gnu.org; Sun, 18 Dec 2011 19:15:27 -0500 Received: from mail4-relais-sop.national.inria.fr ([192.134.164.105]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RcQt1-0002HY-Vb for 10203-done@debbugs.gnu.org; Sun, 18 Dec 2011 19:15:25 -0500 X-IronPort-AV: E=Sophos;i="4.71,373,1320620400"; d="scan'208";a="123841483" Received: from reverse-83.fdn.fr (HELO pluto) ([80.67.176.83]) by mail4-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES128-SHA; 19 Dec 2011 01:13:32 +0100 From: ludo@gnu.org (Ludovic =?iso-8859-1?Q?Court=E8s?=) To: Andreas Schwab Subject: Re: bug#10203: [PATCH] FFI: Properly unpack small integer return values in closure call References: X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 29 Frimaire an 220 de la =?iso-8859-1?Q?R=E9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 83C4 F8E5 10A3 3B4C 5BEA D15D 77DD 95E2 EA52 ECF4 X-OS: x86_64-unknown-linux-gnu Date: Mon, 19 Dec 2011 01:13:31 +0100 In-Reply-To: (Andreas Schwab's message of "Sat, 03 Dec 2011 12:17:46 +0100") Message-ID: <87zkepfmfo.fsf@gnu.org> User-Agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.90 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -9.2 (---------) X-Debbugs-Envelope-To: 10203-done Cc: 10203-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -9.2 (---------) Hi Andreas, Andreas Schwab skribis: > * libguile/foreign.c (unpack): Add parameter return_value_p. > Properly store integer return values smaller than int. > (scm_i_foreign_call): Update call to unpack. > (invoke_closure): Likewise. Applied, thank you! Did you actually observe a problem on m68k or something? Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 19 04:36:37 2011 Received: (at 10203-done) by debbugs.gnu.org; 19 Dec 2011 09:36:37 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RcZe9-00070v-7o for submit@debbugs.gnu.org; Mon, 19 Dec 2011 04:36:37 -0500 Received: from mail-out.m-online.net ([212.18.0.9]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RcZe7-00070p-Q7 for 10203-done@debbugs.gnu.org; Mon, 19 Dec 2011 04:36:36 -0500 Received: from frontend1.mail.m-online.net (unknown [192.168.8.180]) by mail-out.m-online.net (Postfix) with ESMTP id 26A861C0C0CD; Mon, 19 Dec 2011 10:34:42 +0100 (CET) X-Auth-Info: VTFUuiRS03nqbXwovXtd40eezs0dZ0D6mWC2WUV3L8A= Received: from igel.home (ppp-88-217-120-127.dynamic.mnet-online.de [88.217.120.127]) by mail.mnet-online.de (Postfix) with ESMTPA id 3535E1C001E2; Mon, 19 Dec 2011 10:34:05 +0100 (CET) Received: by igel.home (Postfix, from userid 501) id E4088CA29C; Mon, 19 Dec 2011 10:34:04 +0100 (CET) From: Andreas Schwab To: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: bug#10203: [PATCH] FFI: Properly unpack small integer return values in closure call References: <87zkepfmfo.fsf@gnu.org> X-Yow: I can see you GUYS an' GALS need a LOT of HELP...You're all very STUPID!! I used to be STUPID, too..before I started watching UHF-TV!! Date: Mon, 19 Dec 2011 10:34:03 +0100 In-Reply-To: <87zkepfmfo.fsf@gnu.org> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?= =?utf-8?Q?s?= message of "Mon, 19 Dec 2011 01:13:31 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.92 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.6 (--) X-Debbugs-Envelope-To: 10203-done Cc: 10203-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) ludo@gnu.org (Ludovic Courtès) writes: > Did you actually observe a problem on m68k or something? Any big endian system qualifies. Andreas. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different." From debbugs-submit-bounces@debbugs.gnu.org Mon Dec 19 12:21:42 2011 Received: (at 10203-done) by debbugs.gnu.org; 19 Dec 2011 17:21:42 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RcguE-0001eq-8G for submit@debbugs.gnu.org; Mon, 19 Dec 2011 12:21:42 -0500 Received: from mail1-relais-roc.national.inria.fr ([192.134.164.82]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RcguC-0001ei-Cq for 10203-done@debbugs.gnu.org; Mon, 19 Dec 2011 12:21:41 -0500 X-IronPort-AV: E=Sophos;i="4.71,377,1320620400"; d="scan'208";a="136060767" Received: from unknown (HELO pluto) ([193.50.110.208]) by mail1-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES128-SHA; 19 Dec 2011 18:19:45 +0100 From: ludo@gnu.org (Ludovic =?iso-8859-1?Q?Court=E8s?=) To: Andreas Schwab Subject: Re: bug#10203: [PATCH] FFI: Properly unpack small integer return values in closure call References: <87zkepfmfo.fsf@gnu.org> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 29 Frimaire an 220 de la =?iso-8859-1?Q?R=E9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 83C4 F8E5 10A3 3B4C 5BEA D15D 77DD 95E2 EA52 ECF4 X-OS: x86_64-unknown-linux-gnu Date: Mon, 19 Dec 2011 18:19:45 +0100 In-Reply-To: (Andreas Schwab's message of "Mon, 19 Dec 2011 10:34:03 +0100") Message-ID: <87hb0wfphq.fsf@gnu.org> User-Agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.90 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -8.6 (--------) X-Debbugs-Envelope-To: 10203-done Cc: 10203-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -8.7 (--------) Hi, Andreas Schwab skribis: > ludo@gnu.org (Ludovic Court=C3=A8s) writes: > >> Did you actually observe a problem on m68k or something? > > Any big endian system qualifies. Hmm strangely, I fixed the dual of your patch on SPARC64 IIRC, which was happy after that. Anyway, thanks! Ludo=E2=80=99. From unknown Thu Aug 14 22:17:59 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Tue, 17 Jan 2012 12:24:03 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator