00001
00002
00003
00004
00005
00006
00007 #define fabsshift ((8*sizeof(unsigned int))-1)
00008 #ifdef P6_CPU
00009 static __inline__ int intmax( register int x, register int y )
00010 {
00011 asm( "cmpl %1, %0\n"
00012 "cmovl %1, %0\n"
00013 : "+r" (x) : "r" (y)
00014 );
00015 return x;
00016 }
00017
00018 static __inline__ int intmin( register int x, register int y )
00019 {
00020 asm( "cmpl %1, %0\n"
00021 "cmovg %1, %0\n"
00022 : "+r" (x) : "rm" (y)
00023 );
00024 return x;
00025 }
00026
00027 static __inline__ int intabs( register int x )
00028 {
00029 register int neg = -x;
00030 asm( "cmpl %1, %0\n"
00031 "cmovl %1, %0\n"
00032 : "+r" (x) : "r" (neg)
00033 );
00034 return x;
00035 }
00036 #else
00037
00038 static __inline__ int intabs(int x)
00039 {
00040 return ((x)-(((unsigned int)(x))>>fabsshift)) ^ ((x)>>fabsshift);
00041 }
00042
00043 static __inline__ int intmax(int x, int y)
00044 {
00045 return (((x-y)>>fabsshift) & y) | ((~((x-y)>>fabsshift)) & x);
00046 }
00047
00048 static __inline__ int intmin(int x,int y)
00049 {
00050 return (((y-x)>>fabsshift) & y) | ((~((y-x)>>fabsshift)) & x);
00051 }
00052
00053 #endif
00054
00055 #define signmask(x) (((int)x)>>fabsshift)
00056 static __inline__ int intsamesign(int x, int y)
00057 {
00058 return (y+(signmask(x) & -(y<<1)));
00059 }
00060 #undef signmask
00061 #undef fabsshift
00062