MCPcopy Create free account
hub / github.com/apache/httpd / h2_log2

Function h2_log2

modules/http2/h2_util.c:35–62  ·  view source on GitHub ↗

h2_log2(n) iff n is a power of 2 */

Source from the content-addressed store, hash-verified

33
34/* h2_log2(n) iff n is a power of 2 */
35unsigned char h2_log2(unsigned int n)
36{
37 int lz = 0;
38 if (!n) {
39 return 0;
40 }
41 if (!(n & 0xffff0000u)) {
42 lz += 16;
43 n = (n << 16);
44 }
45 if (!(n & 0xff000000u)) {
46 lz += 8;
47 n = (n << 8);
48 }
49 if (!(n & 0xf0000000u)) {
50 lz += 4;
51 n = (n << 4);
52 }
53 if (!(n & 0xc0000000u)) {
54 lz += 2;
55 n = (n << 2);
56 }
57 if (!(n & 0x80000000u)) {
58 lz += 1;
59 }
60
61 return 31 - lz;
62}
63
64size_t h2_util_hex_dump(char *buffer, size_t maxlen,
65 const char *data, size_t datalen)

Callers 1

h2_push_diary_digest_getFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected