]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
FFI: Handle zero-fill of struct-of-NYI.
authorMike Pall <mike>
Tue, 23 Mar 2021 01:35:07 +0000 (02:35 +0100)
committerMike Pall <mike>
Tue, 23 Mar 2021 01:35:07 +0000 (02:35 +0100)
src/lj_crecord.c

index c7b60b3aa8b5cf708143e4502a829a2c847b641b..be23cd6271577e7ee0a1d42d847c09465dda0e3c 100644 (file)
@@ -1024,8 +1024,26 @@ static void crec_alloc(jit_State *J, RecordFFData *rd, CTypeID id)
        crec_ct_tv(J, dc, dp, sp, sval);
       }
     } else if (ctype_isstruct(d->info)) {
-      CTypeID fid = d->sib;
+      CTypeID fid;
       MSize i = 1;
+      if (!J->base[1]) {  /* Handle zero-fill of struct-of-NYI. */
+       fid = d->sib;
+       while (fid) {
+         CType *df = ctype_get(cts, fid);
+         fid = df->sib;
+         if (ctype_isfield(df->info)) {
+           CType *dc;
+           if (!gcref(df->name)) continue;  /* Ignore unnamed fields. */
+           dc = ctype_rawchild(cts, df);  /* Field type. */
+           if (!(ctype_isnum(dc->info) || ctype_isptr(dc->info) ||
+                 ctype_isenum(dc->info)))
+             goto special;
+         } else if (!ctype_isconstval(df->info)) {
+           goto special;
+         }
+       }
+      }
+      fid = d->sib;
       while (fid) {
        CType *df = ctype_get(cts, fid);
        fid = df->sib;