static inline bool first_access_ro(struct kr_cache_top_context *ctx, kru_hash_t hash)
{
// struct kr_cache_top_context { uint32_t bloom[32]; }
- static_assert(sizeof(((struct kr_cache_top_context *)0)->bloom[0]) * 8 == 32);
- static_assert(sizeof(((struct kr_cache_top_context *)0)->bloom) * 8 == 32 * 32);
+ static_assert(sizeof(((struct kr_cache_top_context *)0)->bloom[0]) * 8 == 32, "");
+ static_assert(sizeof(((struct kr_cache_top_context *)0)->bloom) * 8 == 32 * 32, "");
// expected around 40 unique cache accesses per request context, possibly up to ~200;
// prob. of collision of 50th unique access with the preceeding ones: ~0.1 %;
// 75th: ~0.4 %; 100th: ~1.1 %; 150th: ~3.9 %; 200th: ~8.7 %; 300th: ~23 %; 400th: ~39 %
// -> collision means not counting the cache access in KRU while it should be
uint8_t *h = (uint8_t *)&hash;
- static_assert(sizeof(kru_hash_t) >= 8);
+ static_assert(sizeof(kru_hash_t) >= 8, "bad size of kru_hash_t");
bool accessed = 1u &
(ctx->bloom[h[0] % 32] >> (h[1] % 32)) &
if (!first_access_ro(ctx, hash)) return false;
uint8_t *h = (uint8_t *)&hash;
- static_assert(sizeof(kru_hash_t) >= 8);
+ static_assert(sizeof(kru_hash_t) >= 8, "bad size of kru_hash_t");
ctx->bloom[h[0] % 32] |= 1u << (h[1] % 32);
ctx->bloom[h[2] % 32] |= 1u << (h[3] % 32);
{
// Obtain hash of *buf.
kru_hash_t hash;
- static_assert(sizeof(kru_hash_t) * 8 <= 64);
+ static_assert(sizeof(kru_hash_t) * 8 <= 64, "bad size of kru_hash_t");
#if !USE_AES
hash = SipHash(&kru->hash_key, SIPHASH_RC, SIPHASH_RF, key, 16);
#else
{
// Obtain hash of *buf.
kru_hash_t hash;
- static_assert(sizeof(kru_hash_t) * 8 <= 64);
+ static_assert(sizeof(kru_hash_t) * 8 <= 64, "bad size of kru_hash_t");
#if !USE_AES
{
{
// Obtain hash of *buf.
kru_hash_t hash;
- static_assert(sizeof(kru_hash_t) * 8 <= 64);
+ static_assert(sizeof(kru_hash_t) * 8 <= 64, "bad size of kru_hash_t");
// We use SipHash even for otherwise optimized KRU variant, which has diffent type of hash_key.
- static_assert(sizeof(kru->hash_key) >= sizeof(SIPHASH_KEY));
+ static_assert(sizeof(kru->hash_key) >= sizeof(SIPHASH_KEY), "bad size of kru::hash_key");
SIPHASH_KEY *hash_key = (void *)&kru->hash_key;
hash = SipHash(hash_key, SIPHASH_RC, SIPHASH_RF, key, key_size);
// evict all expired before any non-expired (incl. RTT)
res = res / 2 + 65; // 65..97
}
- static_assert(CATEGORIES - 1 > 97);
+ static_assert(CATEGORIES - 1 > 97, "inssuficient CATEGORIES number");
if (!kr_log_is_debug(CACHE, NULL)) // skip these computations if not needed
goto finish;