From 1c7650f782c4e6482cf496699af9136c89fe22b2 Mon Sep 17 00:00:00 2001 From: Mike Pall Date: Thu, 16 May 2013 14:47:20 +0200 Subject: [PATCH] FFI: Fix calling conventions for ARM hard-float EABI. Properly classify nested (non-transparent) structs. --- src/lj_ccall.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lj_ccall.c b/src/lj_ccall.c index 29909891..eb73604f 100644 --- a/src/lj_ccall.c +++ b/src/lj_ccall.c @@ -584,22 +584,26 @@ static unsigned int ccall_classify_struct(CTState *cts, CType *ct, CType *ctf) unsigned int r = 0, n = 0, isu = (ct->info & CTF_UNION); if ((ctf->info & CTF_VARARG)) goto noth; while (ct->sib) { + CType *sct; ct = ctype_get(cts, ct->sib); if (ctype_isfield(ct->info)) { - CType *sct = ctype_rawchild(cts, ct); + sct = ctype_rawchild(cts, ct); if (ctype_isfp(sct->info)) { r |= sct->size; if (!isu) n++; else if (n == 0) n = 1; } else if (ctype_iscomplex(sct->info)) { r |= (sct->size >> 1); if (!isu) n += 2; else if (n < 2) n = 2; + } else if (ctype_isstruct(sct->info)) { + goto substruct; } else { goto noth; } } else if (ctype_isbitfield(ct->info)) { goto noth; } else if (ctype_isxattrib(ct->info, CTA_SUBTYPE)) { - CType *sct = ctype_rawchild(cts, ct); + sct = ctype_rawchild(cts, ct); + substruct: if (sct->size > 0) { unsigned int s = ccall_classify_struct(cts, sct, ctf); if (s <= 1) goto noth;