From: "Stéphane Glondu" <steph@glondu.net>
To: libffi-discuss@sourceware.org
Subject: Function returning uint16
Date: Thu, 16 Jun 2016 15:04:00 -0000 [thread overview]
Message-ID: <5762BFD6.1020704@glondu.net> (raw)
Hello,
I am trying to debug
https://github.com/ocamllabs/ocaml-ctypes/issues/404
and I realized that the following code (on amd64):
#include <stdio.h>
#include <stdint.h>
#include <ffi.h>
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
next reply other threads:[~2016-06-16 15:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-16 15:04 Stéphane Glondu [this message]
2016-06-16 19:15 ` Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5762BFD6.1020704@glondu.net \
--to=steph@glondu.net \
--cc=libffi-discuss@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).