💾 Archived View for gmi.noulin.net › gitRepositories › tuyau › file › rateLimiter › hashtable.c.gmi captured on 2023-07-10 at 18:13:53. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-01-29)
-=-=-=-=-=-=-
hashtable.c (465B)
1 2 #include "libsheepyObject.h" 3 4 u32 ilog2Hashtable(u32 value); 5 6 u32 ilog2Hashtable(u32 value) { 7 //u32 n = (__builtin_clz(value) ^ 31) + 1; 8 if (!value) return 4; 9 // compute log2 of value 10 u32 n; 11 asm ("bsrl %1, %0" : "=r" (n) : "r" (value)); 12 n++; 13 // keep size at 16 for values under 17 14 if (n <= 4) n = 4; 15 // if value is a power of 2, keep the size down 16 else if ((value & (value-1)) == 0) n--; 17 /*else if (value == (1<<(n-1))) n--;*/ 18 return n; 19 } 20