on master help sign in
part 2 of FORCE_ALIGNMENT fix for arduino targets.

When FORCE_ALIGNMENT was introduced for pointer aligment on 8-bit arduino targets (See idris-lang@47cd264) it was not applied to the initialization of the cheney algorithm during garbage collection. The fix modifies the start of the heap location in the same way the FORCE_ALIGNMENT-define does for the initialization of the FP-heap in alloc_heap(...) in file idris_heap.c. To prevent duplicate code this logic has been put in the function aligned_heap_pointer(...).

commitab87db12c2bdf5066a1e23d50f3ce69ff2928e92 authorXeFias <xefias@gmail.com> dateMon 9 Jan 2017, 21:46 (10 years ago) parentd2a81f5
1 file changed+12−8
rts/idris_heap.c+12−8
rts/idris_heap.c+12−8
@@ -118,14 +118,7 @@ void alloc_heap(Heap * h, size_t heap_size, size_t growth, char * old)
118118 }
119119
120120 h->heap = mem;
121−#ifdef FORCE_ALIGNMENT
122− if (((i_int)(h->heap)&1) == 1) {
123− h->next = h->heap + 1;
124− } else
125−#endif
126− {
127− h->next = h->heap;
128− }
121+ h->next = aligned_heap_pointer(h->heap);
129122 h->end = h->heap + heap_size;
130123
131124 h->size = heap_size;
@@ -169,6 +162,17 @@ int ref_in_heap(Heap * heap, VAL v) {
169162 return ((VAL)heap->heap <= v) && (v < (VAL)heap->next);
170163}
171164
165+char* aligned_heap_pointer(char * heap) {
166+#ifdef FORCE_ALIGNMENT
167+ if (((i_int)heap&1) == 1) {
168+ return (heap + 1);
169+ } else
170+#endif
171+ {
172+ return heap;
173+ }
174+}
175+
172176// Checks three important properties:
173177// 1. Closure.
174178// Check if all pointers in the _heap_ points only to heap.