Lines Matching +full:in +full:- +full:min
3 * SPDX-License-Identifier: Apache-2.0
8 /* This code may be used (e.g. for trace/logging) in very early
22 * (arm64 excepted) either promise firm ordering (x86) or are in-order
31 return idx >= ws->len ? idx - ws->len : idx; in idx_mod()
34 /* Computes modular a - b, assuming a and b are in [0:len) */
37 return idx_mod(ws, a + (ws->len - b)); in idx_sub()
44 uint32_t start = ws->start, end = ws->end, seq = ws->seq; in sys_winstream_write()
47 * (Max bytes buffered is actually len-1 because start==end is in sys_winstream_write()
50 if (len > ws->len - 1) { in sys_winstream_write()
52 len = ws->len - 1; in sys_winstream_write()
55 /* Make room in the buffer by advancing start first (note same in sys_winstream_write()
56 * len-1 from above) 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()
63 ws->start = idx_mod(ws, start + (len - avail)); in sys_winstream_write()
70 ws->start = end; in sys_winstream_write()
71 data += len0 - len; in sys_winstream_write()
74 suffix = MIN(len, ws->len - end); in sys_winstream_write()
75 MEMCPY(&ws->data[end], data, 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()
81 ws->seq += len0; /* seq represents dropped bytes too! */ in sys_winstream_write()
91 start = ws->start; end = ws->end; wseq = ws->seq; in sys_winstream_read()
94 /* No change in buffer state or empty initial stream are easy */ in sys_winstream_read()
104 behind = wseq - *seq; in sys_winstream_read()
105 if (behind > idx_sub(ws, ws->end, ws->start)) { in sys_winstream_read()
111 copy = idx_sub(ws, ws->end, behind); in sys_winstream_read()
112 len = MIN(buflen, behind); in sys_winstream_read()
113 suffix = MIN(len, ws->len - copy); in sys_winstream_read()
114 MEMCPY(buf, &ws->data[copy], suffix); in sys_winstream_read()
116 MEMCPY(buf + suffix, &ws->data[0], len - suffix); in sys_winstream_read()
126 } while (start != ws->start || wseq != ws->seq); in sys_winstream_read()