Test GCJ object creation with length-based descriptor (gctest)
authorIvan Maidanski <ivmai@mail.ru>
Mon, 5 Dec 2016 22:38:49 +0000 (01:38 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Mon, 5 Dec 2016 22:38:49 +0000 (01:38 +0300)
* tests/test.c [GC_GCJ_SUPPORT] (gcj_cons): Define new static variable
obj_cnt; increment obj_cnt on each call; if obj_cnt is odd then pass
gcj_class_struct1 to GC_GCJ_MALLOC instead of gcj_class_struct2.

tests/test.c

index 8e4c4b5..6d3dbfe 100644 (file)
@@ -340,10 +340,12 @@ sexpr gcj_cons(sexpr x, sexpr y)
 {
     GC_word * r;
     sexpr result;
+    static int obj_cnt = 0;
 
     r = (GC_word *) GC_GCJ_MALLOC(sizeof(struct SEXPR)
                                   + sizeof(struct fake_vtable*),
-                                   &gcj_class_struct2);
+                                  (++obj_cnt & 1) != 0 ? &gcj_class_struct1
+                                                       : &gcj_class_struct2);
     CHECK_OUT_OF_MEMORY(r);
     result = (sexpr)(r + 1);
     result -> sexpr_car = x;