pike.git / src / stuff.c

version» Context lines:

pike.git/src/stuff.c:62:    536870911, /* ~ 2^29 = 536870912 */    1073741823,/* ~ 2^30 = 1073741824 */    2147483647,/* ~ 2^31 = 2147483648 */   };      /* same thing as (int)floor(log((double)x) / log(2.0)) */   /* Except a bit quicker :) (hopefully) */      PMOD_EXPORT int my_log2(size_t x)   { -  if( x == 0 ) return 0; +    #if (defined(__x86_64) || defined(__i386__)) && defined(__GNUC__) -  +  if( x == 0 ) return 0;   #if SIZEOF_CHAR_P > 4    asm("bsrq %1, %0" :"+r"(x) :"rm"(x));   #else    asm("bsrl %1, %0" :"+r"(x) :"rm"(x));   #endif /* sizeof(char*) */    return x+1;   #elif defined(HAS___BUILTIN_CLZL) -  +  if( x == 0 ) return 0;    return ((sizeof(unsigned long)*8)-__builtin_clzl(x))-1;   #elif defined(HAS___BUILTIN_CLZ)    /* on arm32 only this one exists. Happily enough sizeof(int) is    * sizeof(size_t).    */ -  +  if( x == 0 ) return 0;    return ((sizeof(int)*8)-__builtin_clz(x))-1;   #else    static const signed char bit[256] =    {    -1, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,    4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,    5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,    6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,    6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
pike.git/src/stuff.c:98:    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,    7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,    };    register size_t tmp; +  if( x == 0 ) return 0;   #if SIZEOF_CHAR_P > 4    if((tmp=(x>>32)))    {    if((x=(tmp>>16))) {    if((tmp=(x>>8))) return bit[tmp]+56;    return bit[x]+48;    }    if((x=(tmp>>8))) return bit[x]+40;    return bit[tmp]+32;    }