pike.git / src / stuff.c

version» Context lines:

pike.git/src/stuff.c:1:   /*   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information.   */      #include "global.h"   #include "stuff.h" + #include "bitvector.h"      /* Used by is8bitalnum in pike_macros.h. */   PMOD_EXPORT const char Pike_is8bitalnum_vector[] =    "0000000000000000"    "0000000000000000"    "0000000000000000"    "1111111111000000"    "0111111111111111"    "1111111111100001"    "0111111111111111"
pike.git/src/stuff.c:61:    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 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, -  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, -  }; -  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; +  return log2_u32(x);   } -  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]; - #endif - } +          PMOD_EXPORT double my_strtod(char *nptr, char **endptr)   {    double tmp=strtod(nptr,endptr);    if(*endptr>nptr)    {    if(endptr[0][-1]=='.')    endptr[0]--;    }