kit

kit
git clone https://git.ryansepassi.com/git/kit.git
Log | Files | Refs | README

call_indirect_arg_struct_byval.c (577B)


      1 /* Big struct (>16 bytes) passed via ABI_ARG_INDIRECT (byval) from an
      2  * OPK_INDIRECT source. The caller must compute `base + ind.ofs` and
      3  * pass that pointer in the first int-arg slot. */
      4 typedef struct {
      5   int a[8];
      6 } Big;
      7 typedef struct {
      8   Big big;
      9   int x;
     10 } Row;
     11 
     12 int sink(Big b) { return b.a[0] + b.a[7]; }
     13 
     14 int call_big(Row* row, int i) { return sink(row[i].big); }
     15 
     16 int test_main(void) {
     17   Row rows[2];
     18   rows[0].big.a[0] = 20;
     19   rows[0].big.a[7] = 22;
     20   rows[0].x = 0;
     21   rows[1].big.a[0] = 99;
     22   rows[1].big.a[7] = 99;
     23   rows[1].x = 0;
     24   return call_big(rows, 0);
     25 }