Lines Matching refs:len
31 return idx >= ws->len ? idx - ws->len : idx; in idx_mod()
37 return idx_mod(ws, a + (ws->len - b)); in idx_sub()
41 const char *data, uint32_t len) in sys_winstream_write() argument
43 uint32_t len0 = len, suffix; in sys_winstream_write()
50 if (len > ws->len - 1) { in sys_winstream_write()
52 len = ws->len - 1; in sys_winstream_write()
58 len = MIN(len, ws->len); in sys_winstream_write()
60 uint32_t avail = (ws->len - 1) - idx_sub(ws, end, start); in sys_winstream_write()
62 if (len > avail) { in sys_winstream_write()
63 ws->start = idx_mod(ws, start + (len - avail)); in sys_winstream_write()
69 if (len < len0) { in sys_winstream_write()
71 data += len0 - len; in sys_winstream_write()
74 suffix = MIN(len, ws->len - end); in sys_winstream_write()
76 if (len > suffix) { in sys_winstream_write()
77 MEMCPY(&ws->data[0], data + suffix, len - suffix); in sys_winstream_write()
80 ws->end = idx_mod(ws, end + len); in sys_winstream_write()
88 uint32_t seq0 = *seq, start, end, wseq, len, behind, copy, suffix; in sys_winstream_read() local
112 len = MIN(buflen, behind); in sys_winstream_read()
113 suffix = MIN(len, ws->len - copy); in sys_winstream_read()
115 if (len > suffix) { in sys_winstream_read()
116 MEMCPY(buf + suffix, &ws->data[0], len - suffix); in sys_winstream_read()
118 *seq = seq0 + len; in sys_winstream_read()
128 return len; in sys_winstream_read()