Skip to content

Commit 0cd0ef0

Browse files
authored
pb foreign-function interface: refine union handling for s390x (#990)
With pb, foreign calls in general use libffi, which does not provide support for `union` arguments and results. The binding in "c/ffi.c" approximates `union` handling by constructing a `struct` description that is likely to be treated the same in the platform's ABI. The approximation was wrong for s390x in the case of `union`s that contain only floating-point fields, so add a special case for s390x. There are surely other platforms that would need similar treatment, but s390x is relevant because there's no native-code backend for that architecture.
1 parent 18045ff commit 0cd0ef0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

c/ffi.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,12 @@ ffi_type *decode_type(alloc_state *alloc, ptr type, ffi_abi abi, IBOOL *all_floa
145145
type = Scdr(type);
146146
}
147147

148+
# ifdef __s390x__
149+
/* s390x: unions containing only floats are not treated the
150+
same as structs containing only floats */
151+
union_all_float = 0;
152+
# endif
153+
148154
if (!union_all_float)
149155
*all_float = 0;
150156

0 commit comments

Comments
 (0)