1 /* fast int primitives. min,max,abs,samesign
3 * WARNING: Assumes 2's complement arithmetic.
7 #define fabsshift ((8*sizeof(unsigned int))-1)
9 static __inline__ int intmax( int x, int y )
18 static __inline__ int intmin( int x, int y )
27 static __inline__ int intabs( int x )
32 : "+r" (x) : "r" (neg)
38 static __inline__ int intabs(int x)
40 return ((x)-(((unsigned int)(x))>>fabsshift)) ^ ((x)>>fabsshift);
43 static __inline__ int intmax(int x, int y)
45 return (((x-y)>>fabsshift) & y) | ((~((x-y)>>fabsshift)) & x);
48 static __inline__ int intmin(int x,int y)
50 return (((y-x)>>fabsshift) & y) | ((~((y-x)>>fabsshift)) & x);
55 #define signmask(x) (((int)x)>>fabsshift)
56 static __inline__ int intsamesign(int x, int y)
58 return (y+(signmask(x) & -(y<<1)));