~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina4/src/sys/sys_gen.h

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2 *
  3 * sys_gen.h
  4 * 
  5 * general data types and macros
  6 * 
  7 */ 
  8 
  9 #ifndef SYSGEN_HEADS_DEFINED
 10 #define SYSGEN_HEADS_DEFINED
 11 
 12 #ifdef IBM
 13 #undef NULL
 14 #define NULL 0
 15 #elif _PCC
 16 #undef NULL
 17 #define NULL 0
 18 #endif
 19 
 20 /* next line added by JULIAN 19/10/93 to ensure NULL alway 0 NOT (void*)0 */
 21 /* quelle twat. removed
 22 #undef NULL
 23 #ifndef NULL
 24 #define NULL 0
 25 #endif
 26 */
 27 
 28 /** absolute value macro */
 29 
 30 #ifndef ABS
 31 #define ABS(x) ((x) < 0 ? -(x): (x))
 32 #endif
 33 
 34 /** sign macros */
 35 
 36 #ifndef SGN
 37 #define SGN(x) ((x) < 0 ? -1: 1)
 38 #endif
 39 
 40 #ifndef SAME_SIGN
 41 #define SAME_SIGN(x, y) ((x)<0 ? (y)<0 : (y)>=0)
 42 #endif
 43 
 44 #ifndef DIFF_SIGN
 45 #define DIFF_SIGN(x, y) ((x)<0 ? (y)>=0 : (y)<0)
 46 #endif
 47 
 48 /** round to nearest integer **/
 49 #define ROUND(x) ((x) > 0? (int) ((x)+0.5): -(int)(0.5-(x)))
 50 
 51 /** sqr macro */
 52 
 53 #ifndef SQR
 54 #define SQR(x) ((x)*(x))
 55 #endif
 56 
 57 /** macro to swap arbitrary types **/
 58 
 59 #ifndef SWAP    
 60 #define SWAP(var,x,y) { var temp; temp = (x); (x) = (y); (y) = temp; }
 61 #endif
 62 
 63 /** macro to order arbitrary types **/
 64 
 65 #ifndef ORDER
 66 #define ORDER(var,x,y) if ((y)<(x)) { var temp; temp = (x); (x) = (y); (y) = temp; }
 67 #endif
 68 
 69 /** maximum and minimum macros for pairs and triples **/
 70 
 71 #ifndef MAX
 72 #define MAX(x, y) ((x) >= (y) ? (x) : (y))
 73 #endif
 74 
 75 #ifndef MIN
 76 #define MIN(x, y) ((x) <= (y) ? (x) : (y))
 77 #endif
 78 
 79 #define MAX3(x, y, z) MAX((x), MAX((y), (z)))
 80 #define MIN3(x, y, z) MIN((x), MIN((y), (z)))
 81 
 82 #define MAX4(x, y, z, w) MAX(MAX((x), (y)), MAX((z), (w)))
 83 #define MIN4(x, y, z, w) MIN(MIN((x), (y)), MIN((z), (w)))
 84 
 85 /** macros to allow switches over pairs of -small- ints or enums **/
 86 
 87 #define OPAIR(s1, s2)    (1000*(int) (s1)+(int) (s2))
 88 #define PAIR(s1, s2)     MIN(OPAIR(s1, s2), OPAIR(s2, s1))
 89 
 90 /** between macros **/
 91 
 92 #define BETWEEN(x,a,b) ( ((x)>(a) && (x)<(b)) || ((x)<(a) && (x)>(b)) )
 93 
 94 #define OVERLAPPED(a1,a2,b1,b2) ((a2)>=(b1) && (a1)<=(b2))
 95 
 96 #endif /* SYSGEN_HEADS_DEFINED */
 97 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.