on master help sign in
Merge pull request #3605 from XeFias/master

Implement second part of FORCE_ALIGNMENT fix for arduino targets.

commitc86bf981c0519834c91c922f24b075468d865626 authorAhmad Salim Al-Sibahi <asal@itu.dk> dateThu 12 Jan 2017, 22:10 (10 years ago) parent8f7d9a45e85ce3
3 files changed+15−10
rts/idris_gc.c+2−1 rts/idris_heap.c+12−8 rts/idris_heap.h+1−1
rts/idris_gc.c+2−1
@@ -1,3 +1,4 @@
1+#include "idris_heap.h"
12#include "idris_rts.h"
23#include "idris_gc.h"
34#include "idris_bitstring.h"
@@ -73,7 +74,7 @@ VAL copy(VM* vm, VAL x) {
7374void cheney(VM *vm) {
7475 int i;
7576 int ar;
76− char* scan = vm->heap.heap;
77+ char* scan = aligned_heap_pointer(vm->heap.heap);
7778
7879 while(scan < vm->heap.next) {
7980 size_t inc = *((size_t*)scan);
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.
rts/idris_heap.h+1−1
@@ -98,7 +98,7 @@ typedef struct {
9898
9999void alloc_heap(Heap * heap, size_t heap_size, size_t growth, char * old);
100100void free_heap(Heap * heap);
101−
101+char* aligned_heap_pointer(char * heap);
102102
103103#ifdef IDRIS_DEBUG
104104void heap_check_all(Heap * heap);