MCPcopy Create free account
hub / github.com/F-Stack/f-stack / getbits

Function getbits

freebsd/net/mppcd.c:53–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51};
52
53static uint32_t __inline
54getbits(const uint8_t *buf, const uint32_t n, uint32_t *i, uint32_t *l)
55{
56 static const uint32_t m[] = {0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff};
57 uint32_t res, ol;
58
59 ol = *l;
60 if (*l >= n) {
61 *l = (*l) - n;
62 res = (buf[*i] & m[ol]) >> (*l);
63 if (*l == 0) {
64 *l = 8;
65 (*i)++;
66 }
67 } else {
68 *l = 8 - n + (*l);
69 res = (buf[(*i)++] & m[ol]) << 8;
70 res = (res | buf[*i]) >> (*l);
71 }
72
73 return (res);
74}
75
76static uint32_t __inline
77getbyte(const uint8_t *buf, const uint32_t i, const uint32_t l)

Callers 2

kern_selectFunction · 0.85
MPPC_DecompressFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected