pike.git / src / stuff.c

version» Context lines:

pike.git/src/stuff.c:1:   /*\   ||| This file a part of Pike, and is copyright by Fredrik Hubinette   ||| Pike is distributed as GPL (General Public License)   ||| See the files COPYING and DISCLAIMER for more information.   \*/      /* -  * $Id: stuff.c,v 1.11 2000/07/28 17:16:55 hubbe Exp $ +  * $Id: stuff.c,v 1.12 2000/08/10 09:20:00 grubba Exp $    */   #include "global.h"   #include "stuff.h"   #include "stralloc.h"      /* Not all of these are primes, but they should be adequate */   PMOD_EXPORT INT32 hashprimes[32] =   {    31, /* ~ 2^0 = 1 */    31, /* ~ 2^1 = 2 */
pike.git/src/stuff.c:44:    134217727, /* ~ 2^27 = 134217728 */    268435455, /* ~ 2^28 = 268435456 */    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(unsigned INT32 x) + PMOD_EXPORT int my_log2(size_t x)   {    static 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,    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,    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 unsigned int tmp; +  register size_t tmp; + #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; +  } + #endif /* SIZEOF_CHAP_P > 4 */    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];   }