summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-05-10 19:41:27 -0700
committerKaz Kylheku <kaz@kylheku.com>2022-05-10 19:41:27 -0700
commit494d677fbaf8977d0c6a2f165df0a69f0339077e (patch)
tree64feebd3eda719e63460bf872ee0032bf26f6f57
parentb2aa22f43a731b866b14681ba703826222ffb9e0 (diff)
downloadtxr-494d677fbaf8977d0c6a2f165df0a69f0339077e.tar.gz
txr-494d677fbaf8977d0c6a2f165df0a69f0339077e.tar.bz2
txr-494d677fbaf8977d0c6a2f165df0a69f0339077e.zip
ffi: fix broken on RISC-V.
* ffi.c (pad_retval): Remove the special case of zero mapping to zero, which occurs when the return type is void. It's not clear whether this is correct at all, on any platform. It hasn't showed up as a problem until now, but on RISC-V, we have hit a situation in which ffi_call writes a value into that zero-byte space for the void return value, causing that to overwrite values[0]: the first element of the argument array. For reasons not understood, this happens in the qsort test cases in which which the callback function performs a block return. It is strange because the block return is handled entirely in the closure dispatching function.
-rw-r--r--ffi.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/ffi.c b/ffi.c
index 2bb52d29..636db408 100644
--- a/ffi.c
+++ b/ffi.c
@@ -75,7 +75,7 @@
#define alignof(type) offsetof(struct {char x; type y;}, y)
-#define pad_retval(size) (!(size) || convert(size_t, size) > sizeof (ffi_arg) \
+#define pad_retval(size) (convert(size_t, size) > sizeof (ffi_arg) \
? convert(size_t, size) \
: sizeof (ffi_arg))