Mercurial > hg > CbC > old > device
view test/comp.c @ 927:b491db049d74
Added tag current-release for changeset 4e73a22327a8
author | kono |
---|---|
date | Sun, 13 Apr 2014 10:20:02 +0900 |
parents | 5313ed059cee |
children |
line wrap: on
line source
extern int printf(const char *,...); int heapsize; #if 1 #define CHECK_HEAP(b) ({int _k=(int)(b);if(_k>heapsize||_k<=0)error(-1);_k;}) #else #define CHECK_HEAP(b) (b) #endif #define car(e) (heap[(int)(CHECK_HEAP(e))]) #define cadr(e) (heap[((int)(CHECK_HEAP(e)))+1]) #define caddr(e) (heap[((int)(CHECK_HEAP(e)))+2]) #define cadddr(e) (heap[((int)(CHECK_HEAP(e)))+3]) #define caddddr(e) (heap[((int)(CHECK_HEAP(e)))+4]) #define HEAP_SIZE (1024) #if 0 int heap0[HEAP_SIZE]; int *heap = heap0; #else int heap[HEAP_SIZE]; #endif int v; void error(int v) { printf("#0033:error %d\n",v); } int main() { int j; heapsize = HEAP_SIZE; for(j=1;j<5;j++) caddr(j) = j; v = 5; for(j=0;j<5;j++) printf("#0048:%d\n",caddr(j)); for(j=1,v=5;j<5;j++,v++) caddr(v) = cadr(j); for(j=5;j<=v;j++) printf("#0054:%d\n",caddr(j)); caddr(HEAP_SIZE+5); }