From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 116297 invoked by alias); 16 Jun 2016 15:04:08 -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 116279 invoked by uid 89); 16 Jun 2016 15:04:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY autolearn=no version=3.3.2 spammy=H*r:sk:libffi-, 4242, cif, H*MI:1020704 X-HELO: mail3-relais-sop.national.inria.fr Received: from mail3-relais-sop.national.inria.fr (HELO mail3-relais-sop.national.inria.fr) (192.134.164.104) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 16 Jun 2016 15:03:57 +0000 Received: from wencory.loria.fr ([152.81.3.42]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/AES256-GCM-SHA384; 16 Jun 2016 17:03:50 +0200 Received: from localhost ([127.0.0.1]) by wencory.loria.fr with esmtp (Exim 4.87) (envelope-from ) id 1bDYpi-0001RC-D1 for libffi-discuss@sourceware.org; Thu, 16 Jun 2016 17:03:50 +0200 To: libffi-discuss@sourceware.org From: =?UTF-8?Q?St=c3=a9phane_Glondu?= Subject: Function returning uint16 Message-ID: <5762BFD6.1020704@glondu.net> Date: Thu, 16 Jun 2016 15:04:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.6.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-SW-Source: 2016/txt/msg00028.txt.bz2 Hello, I am trying to debug https://github.com/ocamllabs/ocaml-ctypes/issues/404 and I realized that the following code (on amd64): #include #include #include uint16_t retrieve() { return 0x4242; } int main() { uint16_t r[2] = { 0xdead, 0xbeef }; ffi_cif cif; printf("r = {%x, %x}\n", r[0], r[1]); ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 0, &ffi_type_uint16, NULL); ffi_call(&cif, FFI_FN(retrieve), &r[0], NULL); printf("r = {%x, %x}\n", r[0], r[1]); return 0; } returns: r = {dead, beef} r = {4242, 0} Is that expected? I don't expect r[1] to be overwritten... Cheers, -- Stéphane