/* File macros.h some useful macros Phil Atkin (c) Division Ltd. 1991 */ #ifdef macros_h #else #define macros_h #define degtorad(v) (((v)/(float) 180)*(float)3.1415926535) #define max_of(a,b) ((a)>(b)) ? (a) : (b) #define min_of(a,b) ((a)<(b)) ? (a) : (b) #define add_item(list,obj) do { \ if (list->head==NULL) { \ list->head=obj; \ list->tail=obj; \ } \ else { \ list->tail->next=obj; \ list->tail=obj; \ } \ } while(0) #define remove_item(list,item,TYPE) \ do { \ TYPE *__t, *__p=list->head; \ if (__p==NULL); \ else if (__p==item) { \ list->head=item->next; \ if (list->tail==item) list->tail=list->head; \ free (item); \ } \ else for (__t=__p->next; __t!=NULL; __t=__t->next ) { \ if (__t==item) { \ if (list->tail==__t) list->tail=__p; \ __p->next=__t->next; \ free(item); \ break; \ } \ __p=__t; \ } \ } while (0) #define swap_ptrs(a,b,TYPE) \ do { \ TYPE *__t=a; \ a=b; \ b=__t; \ } while(0) #define solve(point,plane) \ (point[X]*plane[X])+(point[Y]*plane[Y])+(point[Z]*plane[Z])+plane[W] #define decache(p,type) ((type) (((unsigned int) p - (unsigned int) 0x83600000) | 0xA0000000)) #undef decache #define decache(p,type) p #define recache(p,type) ((type) (((unsigned int) p & 0x0fffffff) + (unsigned int) 0x83600000)) #define inst_enable(i) (i->enable&0x1) #define tree_enable(i) (i->enable&0x2) #endif