Example #1
0
int SetTotalBaseCache(int mb)
    {
    int i, j;
    mb = 1 << BSR(mb);
    TBCacheCount = mb << 2;
    for (i = 0; i < 4; i++)
        if (CacheInfo[i])
            free(CacheInfo[i]);
    for (i = 0; i < 4; i++)
        if (TotalBase_Cache[i])
            {
            for (j = 0; j < TotalBaseCache << 2; j++)
                if (TotalBase_Cache[i][j])
                    free(TotalBase_Cache[i][j]);
            free(TotalBase_Cache[i]);
            }
    CacheInfo[0] = malloc(TBCacheCount * sizeof(uint64));
    CacheInfo[1] = malloc(TBCacheCount * sizeof(uint64));
    CacheInfo[2] = malloc(TBCacheCount * sizeof(uint64));
    CacheInfo[3] = malloc(TBCacheCount * sizeof(uint64));
    TotalBase_Cache[0] = malloc(TBCacheCount * sizeof(uint8 *));
    TotalBase_Cache[1] = malloc(TBCacheCount * sizeof(uint8 *));
    TotalBase_Cache[2] = malloc(TBCacheCount * sizeof(uint8 *));
    TotalBase_Cache[3] = malloc(TBCacheCount * sizeof(uint8 *));
    for (j = 0; j < 4; j++)
        for (i = 0; i < TBCacheCount; i++)
            TotalBase_Cache[j][i] = NULL;
    for (j = 0; j < 4; j++)
        for (i = 0; i < TBCacheCount; i++)
            CacheInfo[j][i] = 0xffffffff;
	if (VerboseRobboBases)
		Send("info string TotalBase Cache is %dmb + (1mb)\n", mb);
    TotalBaseCache = mb;
    return mb;
    }
Example #2
0
/**
 * bsr():
 *
 * Return the most-significant bit set in a register.
 */
__inline__ int8_t	bsr(uint32_t	r)
{
  uint32_t		index;
  uint32_t		zf;

  /* Call the Bit Search Reverse instruction. */
  BSR(r, &index, &zf);

  /* If a bit set has been found, return its index. */
  if (!zf)
    {
      return index;
    }

  /* The register contains only 0, then return -1. */
  return ERR_UNKNOWN;
}