pike.git / src / stuff.c

version» Context lines:

pike.git/src/stuff.c:22:    "0000000000000000"    "0000000000000000"    "1011110101100010"    "1011011001101110"    "1111111111111111"    "1111111011111111"    "1111111111111111"    "1111111011111111";      /* Not all of these are primes, but they should be adequate */ - PMOD_EXPORT const INT32 hashprimes[32] = + const INT32 hashprimes[32] =   {    31, /* ~ 2^0 = 1 */    31, /* ~ 2^1 = 2 */    31, /* ~ 2^2 = 4 */    31, /* ~ 2^3 = 8 */    31, /* ~ 2^4 = 16 */    31, /* ~ 2^5 = 32 */    61, /* ~ 2^6 = 64 */    127, /* ~ 2^7 = 128 */    251, /* ~ 2^8 = 256 */
pike.git/src/stuff.c:104:    if((tmp=(x>>16)))    {    if((x=(tmp>>8))) return bit[x]+24;    return bit[tmp]+16;    }    if((tmp=(x>>8))) return bit[tmp]+8;    return bit[x];   }       + #if 0   /* Return the number of bits in a 32-bit integer */   PMOD_EXPORT int count_bits(unsigned INT32 x)   {   #define B(X) X+0,X+1,X+1,X+2,\    X+1,X+2,X+2,X+3,\    X+1,X+2,X+2,X+3,\    X+2,X+3,X+3,X+4    static const char bits[256] =    {    B(0), B(1), B(1), B(2),    B(1), B(2), B(2), B(3),    B(1), B(2), B(2), B(3),    B(2), B(3), B(3), B(4)    };       return (bits[x & 255] +    bits[(x>>8) & 255] +    bits[(x>>16) & 255] +    bits[(x>>24) & 255]);   } -  + #endif    - /* Return true for integers with more than one bit set */ - PMOD_EXPORT int is_more_than_one_bit(unsigned INT32 x) - { -  return !!(x & (x-1)); - } -  +    PMOD_EXPORT double my_strtod(char *nptr, char **endptr)   {    double tmp=STRTOD(nptr,endptr);    if(*endptr>nptr)    {    if(endptr[0][-1]=='.')    endptr[0]--;    }    return tmp;   }
pike.git/src/stuff.c:158:    {    x<<=1; s=b+y; y>>=1;    if(n>=s)    {    x|=1; y|=b; n-=s;    }    }    return x;   }    + #if 0   /* This routine basically finds a prime number    * which is larger than 'x'    */   unsigned long find_good_hash_size(unsigned long num)   {    static const unsigned long primes[] =    {    37UL, 37UL, 37UL, 37UL,    37UL, 37UL, 41UL, 41UL,    41UL, 41UL, 43UL, 43UL,
pike.git/src/stuff.c:423:    /* For really large numbers, produce a number which is not    * a prime, but hopefully good for hash tables, although I    * seriously doubt anybody will use hashtables larger than    * 1<<32 entries... /Hubbe    */    y = (y<<5)|(x&31);    if(y >= NELEM(primes)) return num|7;       return primes[y];   } + #endif      /*    * This rounds an integer up to the next power of two. For x a power    * of two, this will just return the same again.    */   unsigned INT32 find_next_power(unsigned INT32 x)   {    x--;    x |= x >> 1;    x |= x >> 2;    x |= x >> 4;    x |= x >> 8;    x |= x >> 16;    x++;    return x;   }