summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-05-29 18:25:28 -0700
committerKaz Kylheku <kaz@kylheku.com>2017-05-29 18:25:28 -0700
commitad7332c5a76fb748ce9c0fd4a0e97891b93fe07f (patch)
tree2d033ab5be6289433948bc88794f836f05fdbb98
parentb5353cc4c726e60f05df3655859c096e03458e5e (diff)
downloadtxr-ad7332c5a76fb748ce9c0fd4a0e97891b93fe07f.tar.gz
txr-ad7332c5a76fb748ce9c0fd4a0e97891b93fe07f.tar.bz2
txr-ad7332c5a76fb748ce9c0fd4a0e97891b93fe07f.zip
ffi: pad retval to ffi_arg size on all platforms.
* ffi.c (pad_retval): Define same way regardless of big or little endian. For instance, we don't want to call alloca(1) for a char return value. It could be the case on little endian targets that libffi prepares an entire ffi_arg return value. Even though we just read the low order byte, we still have to prepare enough space for the whole thing.
-rw-r--r--ffi.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/ffi.c b/ffi.c
index e6d22814..55f58c01 100644
--- a/ffi.c
+++ b/ffi.c
@@ -62,18 +62,19 @@
#define alignof(type) offsetof(struct {char x; type y;}, y)
+#define pad_retval(size) ((size) > sizeof (ffi_arg) \
+ ? (size) \
+ : sizeof (ffi_arg))
+
#if HAVE_LITTLE_ENDIAN
-#define pad_retval(size) (size)
#define ifbe(expr) (0)
#define ifbe2(expr1, expr2) (expr2)
#else
-#define pad_retval(size) ((size) > sizeof (ffi_arg) \
- ? (size) \
- : sizeof (ffi_arg))
#define ifbe(expr) (expr)
#define ifbe2(expr1, expr2) (expr1)
#endif
+
val uint8_s, int8_s;
val uint16_s, int16_s;
val uint32_s, int32_s;