librnr/hash.c
static void init_hash_sizes(hash_t *hash,
                             hashcount_t minsize,
                             hashcount_t maxsize)
{
  size_t    numbits, rshift, lshift;

  // number of bits in hashcount_t
  numbits = sizeof(hashcount_t) * 8;

  // round down to the closest power of two value
  for(rshift=0, lshift=0; rshift<numbits; ++rshift)
  {
    if( minsize & 0x01 )
    {
      lshift = rshift;
    }
    minsize >>= 1;
  }
  minsize = lshift>0? (((hashcount_t)(0x01)) << lshift):
                      (hashcount_t)HASH_MIN_SIZE;

  // absolute minimum
  if( minsize < HASH_MIN_SIZE )
  {
    minsize = HASH_MIN_SIZE;
  }

  if( maxsize < minsize )
  {
    maxsize = minsize;
  }

  hash->minsize       = minsize;
  hash->maxsize       = maxsize;
  hash->lowmark       = minsize / 2;
  hash->highmark      = minsize * 2;

  LOGDIAG4("minsize=%lu, maxsize=%lu, lowmark=%lu, highmark=%lu",
      hash->minsize, hash->maxsize, hash->lowmark, hash->highmark);
}
/*!
 * \brief Initialize the table size values.
 *
 * The minimum size is adjusted to be a power of two and is guaranteed to be
 * at least \ref HASH_MIN_SIZE. 
 *
 * The maximum size adjusted to be >= minsize.
 *
 * \param hash      Hash table.
 * \param minsize   Desired minimum and initial size.
 * \param maxsize   Desired maximum size.
 */
\brief Initialize the table size values.
The minimum size is adjusted to be a power of two and is guaranteed to be
at least \ref HASH_MIN_SIZE.

The maximum size adjusted to be >= minsize.

\param hash      Hash table.
\param minsize   Desired minimum and initial size.
\param maxsize   Desired maximum size.
\ brief Initialize the table size values . The minimum size is adjusted to be a power of two and is guaranteed to be at least \ ref HASH_MIN_SIZE . The maximum size adjusted to be > = minsize . \ param hash Hash table . \ param minsize Desired minimum and initial size . \ param maxsize Desired maximum size .
static void init_hash_sizes(hash_t *hash,
                             hashcount_t minsize,
                             hashcount_t maxsize)
{
  size_t    numbits, rshift, lshift;
  numbits = sizeof(hashcount_t) * 8;
  for(rshift=0, lshift=0; rshift<numbits; ++rshift)
  {
    if( minsize & 0x01 )
    {
      lshift = rshift;
    }
    minsize >>= 1;
  }
  minsize = lshift>0? (((hashcount_t)(0x01)) << lshift):
                      (hashcount_t)HASH_MIN_SIZE;
  if( minsize < HASH_MIN_SIZE )
  {
    minsize = HASH_MIN_SIZE;
  }
  if( maxsize < minsize )
  {
    maxsize = minsize;
  }
  hash->minsize       = minsize;
  hash->maxsize       = maxsize;
  hash->lowmark       = minsize / 2;
  hash->highmark      = minsize * 2;
  LOGDIAG4("minsize=%lu, maxsize=%lu, lowmark=%lu, highmark=%lu",
      hash->minsize, hash->maxsize, hash->lowmark, hash->highmark);
}
static void init_hash_sizes ( hash_t * hash , hashcount_t minsize , hashcount_t maxsize ) { size_t numbits , rshift , lshift ; numbits = sizeof ( hashcount_t ) * 8 ; for ( rshift = 0 , lshift = 0 ; rshift < numbits ; ++ rshift ) { if ( minsize & 0x01 ) { lshift = rshift ; } minsize >>= 1 ; } minsize = lshift > 0 ? ( ( ( hashcount_t ) ( 0x01 ) ) << lshift ) : ( hashcount_t ) HASH_MIN_SIZE ; if ( minsize < HASH_MIN_SIZE ) { minsize = HASH_MIN_SIZE ; } if ( maxsize < minsize ) { maxsize = minsize ; } hash -> minsize = minsize ; hash -> maxsize = maxsize ; hash -> lowmark = minsize / 2 ; hash -> highmark = minsize * 2 ; LOGDIAG4 ( " " , hash -> minsize , hash -> maxsize , hash -> lowmark , hash -> highmark ) ; }
\brief Initialize the table size values.
\ brief Initialize the table size values .
// number of bits in hashcount_t // round down to the closest power of two value // absolute minimum