Browse Source

FFI: Fix calling conventions for ARM hard-float EABI.

Properly classify nested (non-transparent) structs.
Mike Pall 12 years ago
parent
commit
1c7650f782
1 changed files with 6 additions and 2 deletions
  1. 6 2
      src/lj_ccall.c

+ 6 - 2
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);
   unsigned int r = 0, n = 0, isu = (ct->info & CTF_UNION);
   if ((ctf->info & CTF_VARARG)) goto noth;
   if ((ctf->info & CTF_VARARG)) goto noth;
   while (ct->sib) {
   while (ct->sib) {
+    CType *sct;
     ct = ctype_get(cts, ct->sib);
     ct = ctype_get(cts, ct->sib);
     if (ctype_isfield(ct->info)) {
     if (ctype_isfield(ct->info)) {
-      CType *sct = ctype_rawchild(cts, ct);
+      sct = ctype_rawchild(cts, ct);
       if (ctype_isfp(sct->info)) {
       if (ctype_isfp(sct->info)) {
 	r |= sct->size;
 	r |= sct->size;
 	if (!isu) n++; else if (n == 0) n = 1;
 	if (!isu) n++; else if (n == 0) n = 1;
       } else if (ctype_iscomplex(sct->info)) {
       } else if (ctype_iscomplex(sct->info)) {
 	r |= (sct->size >> 1);
 	r |= (sct->size >> 1);
 	if (!isu) n += 2; else if (n < 2) n = 2;
 	if (!isu) n += 2; else if (n < 2) n = 2;
+      } else if (ctype_isstruct(sct->info)) {
+	goto substruct;
       } else {
       } else {
 	goto noth;
 	goto noth;
       }
       }
     } else if (ctype_isbitfield(ct->info)) {
     } else if (ctype_isbitfield(ct->info)) {
       goto noth;
       goto noth;
     } else if (ctype_isxattrib(ct->info, CTA_SUBTYPE)) {
     } else if (ctype_isxattrib(ct->info, CTA_SUBTYPE)) {
-      CType *sct = ctype_rawchild(cts, ct);
+      sct = ctype_rawchild(cts, ct);
+    substruct:
       if (sct->size > 0) {
       if (sct->size > 0) {
 	unsigned int s = ccall_classify_struct(cts, sct, ctf);
 	unsigned int s = ccall_classify_struct(cts, sct, ctf);
 	if (s <= 1) goto noth;
 	if (s <= 1) goto noth;