Mercurial > hg > CbC > old > device
view test/comp.c @ 792:3622e3f561db
struct offset alignment
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 22 Nov 2010 14:14:15 +0900 |
parents | c2c709727221 |
children | 5313ed059cee |
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); }