Branch: Tag:

2017-11-06

2017-11-06 18:43:21 by Martin Nilsson <nilsson@fastmail.com>

Moved my_log2 from stuff to cpulib.

59:   }      #endif /* HAVE_IA32_ASM */ +  + /* 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 + */ +  + PMOD_EXPORT int my_log2(UINT64 x) + { +  if( x == 0 ) return 0; +  if(x & ~((UINT64)0xffffffffUL)) { +  return 32 + log2_u32((unsigned INT32)(x>>32)); +  } +  return log2_u32((unsigned INT32)x); + }