diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2017-05-29 18:25:28 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2017-05-29 18:25:28 -0700 |
commit | ad7332c5a76fb748ce9c0fd4a0e97891b93fe07f (patch) | |
tree | 2d033ab5be6289433948bc88794f836f05fdbb98 | |
parent | b5353cc4c726e60f05df3655859c096e03458e5e (diff) | |
download | txr-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.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -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; |