#include "db_config.h"
#include "db_int.h"
u_int32_t
__db_tablesize(n_buckets)
u_int32_t n_buckets;
{
#define HASH_SIZE(power, prime) { \
if ((power) >= n_buckets) \
return (prime); \
}
HASH_SIZE(32, 37);
HASH_SIZE(64, 67);
HASH_SIZE(128, 131);
HASH_SIZE(256, 257);
HASH_SIZE(512, 521);
HASH_SIZE(1024, 1031);
HASH_SIZE(2048, 2053);
HASH_SIZE(4096, 4099);
HASH_SIZE(8192, 8191);
HASH_SIZE(16384, 16381);
HASH_SIZE(32768, 32771);
HASH_SIZE(65536, 65537);
HASH_SIZE(131072, 131071);
HASH_SIZE(262144, 262147);
HASH_SIZE(393216, 393209);
HASH_SIZE(524288, 524287);
HASH_SIZE(786432, 786431);
HASH_SIZE(1048576, 1048573);
HASH_SIZE(1572864, 1572869);
HASH_SIZE(2097152, 2097169);
HASH_SIZE(3145728, 3145721);
HASH_SIZE(4194304, 4194301);
HASH_SIZE(6291456, 6291449);
HASH_SIZE(8388608, 8388617);
HASH_SIZE(12582912, 12582917);
HASH_SIZE(16777216, 16777213);
HASH_SIZE(25165824, 25165813);
HASH_SIZE(33554432, 33554393);
HASH_SIZE(50331648, 50331653);
HASH_SIZE(67108864, 67108859);
HASH_SIZE(100663296, 100663291);
HASH_SIZE(134217728, 134217757);
HASH_SIZE(201326592, 201326611);
HASH_SIZE(268435456, 268435459);
HASH_SIZE(402653184, 402653189);
HASH_SIZE(536870912, 536870909);
HASH_SIZE(805306368, 805306357);
HASH_SIZE(1073741824, 1073741827);
return (1073741827);
}
void
__db_hashinit(begin, nelements)
void *begin;
u_int32_t nelements;
{
u_int32_t i;
SH_TAILQ_HEAD(hash_head) *headp;
headp = (struct hash_head *)begin;
for (i = 0; i < nelements; i++, headp++)
SH_TAILQ_INIT(headp);
}