e576bb2002-10-11Martin Nilsson /* || 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. */
24ddc71998-03-28Henrik Grubbström (Grubba) 
ad42b81999-02-27Henrik Grubbström (Grubba) #include "global.h"
5267b71995-08-09Fredrik Hübinette (Hubbe) #include "stuff.h"
c5c2292015-09-13Martin Nilsson #include "bitvector.h"
31874d2015-09-28Martin Nilsson #include "pike_cpulib.h"
21f9f52016-01-04Tobias S. Josefowitz #include "pike_memory.h"
5267b71995-08-09Fredrik Hübinette (Hubbe) 
5e6dc22017-01-10Martin Nilsson /* Used by isidchar in pike_macros.h. */ PMOD_EXPORT const char Pike_isidchar_vector[] =
559b5f2004-11-14Martin Stjernholm  "0000000000000000" "0000000000000000" "0000000000000000" "1111111111000000" "0111111111111111" "1111111111100001" "0111111111111111" "1111111111100000" "0000000000000000" "0000000000000000"
f64c4f2017-01-10Martin Nilsson  "0011110101100010"
559b5f2004-11-14Martin Stjernholm  "1011011001101110" "1111111111111111" "1111111011111111" "1111111111111111" "1111111011111111";
5f90062017-01-10Martin Nilsson const unsigned char hexdecode[256] = { 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, /* '0' - '9' */ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 16,16,16,16,16,16,16, /* 'A' - 'F' */ 10, 11, 12, 13, 14, 15, 16,16,16,16,16,16,16,16,16,16,16,16,16, 16,16,16,16,16,16,16,16,16,16,16,16,16, /* 'a' - 'f' */ 10, 11, 12, 13, 14, 15, 16,16,16,16,16,16,16,16,16, 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, };
75920f1997-12-28Fredrik Hübinette (Hubbe) 
002ec12015-09-13Martin Nilsson /* Same thing as (int)floor(log((double)x) / log(2.0)), except a bit quicker. Number of log2 per second: log(x)/log(2.0) 50,000,000 log2(x) 75,000,000 Table lookup 3,000,000,000 Intrinsic 30,000,000,000,000,000 */
5267b71995-08-09Fredrik Hübinette (Hubbe) 
50674c2016-04-20Henrik Grubbström (Grubba) PMOD_EXPORT int my_log2(UINT64 x)
5267b71995-08-09Fredrik Hübinette (Hubbe) {
520d142014-06-20Henrik Grubbström (Grubba)  if( x == 0 ) return 0;
50674c2016-04-20Henrik Grubbström (Grubba)  if(x & ~((UINT64)0xffffffffUL)) { return 32 + log2_u32((unsigned INT32)(x>>32)); } return log2_u32((unsigned INT32)x);
5267b71995-08-09Fredrik Hübinette (Hubbe) }
1f21332000-07-28Fredrik Hübinette (Hubbe) PMOD_EXPORT double my_strtod(char *nptr, char **endptr)
5740881998-01-01Fredrik Hübinette (Hubbe) {
7661da2014-09-03Martin Nilsson  double tmp=strtod(nptr,endptr);
5740881998-01-01Fredrik Hübinette (Hubbe)  if(*endptr>nptr) { if(endptr[0][-1]=='.') endptr[0]--; } return tmp; }