Lines Matching refs:tail
100 lws_ring_get_count_waiting_elements(struct lws_ring *ring, uint32_t *tail) in lws_ring_get_count_waiting_elements() argument
103 if (!tail) in lws_ring_get_count_waiting_elements()
104 tail = &ring->oldest_tail; in lws_ring_get_count_waiting_elements()
114 if (ring->head == *tail) in lws_ring_get_count_waiting_elements()
117 if (ring->head > *tail) in lws_ring_get_count_waiting_elements()
118 f = (int)(ring->head - *tail); in lws_ring_get_count_waiting_elements()
120 f = (int)((ring->buflen - *tail) + ring->head); in lws_ring_get_count_waiting_elements()
199 lws_ring_consume(struct lws_ring *ring, uint32_t *tail, void *dest, in lws_ring_consume() argument
203 void *orig_tail = tail; in lws_ring_consume()
207 if (!tail) { in lws_ring_consume()
209 tail = &fake_tail; in lws_ring_consume()
213 n = (int)(lws_ring_get_count_waiting_elements(ring, tail) * in lws_ring_consume()
221 *tail = ((*tail) + (unsigned int)n) % ring->buflen; in lws_ring_consume()
223 lws_ring_update_oldest_tail(ring, *tail); in lws_ring_consume()
227 if (*tail + (unsigned int)n > ring->buflen) { in lws_ring_consume()
234 m = (int32_t)(ring->buflen - *tail); in lws_ring_consume()
235 memcpy(dest, ((uint8_t *)ring->buf) + *tail, (size_t)m); in lws_ring_consume()
237 *tail = 0; in lws_ring_consume()
245 memcpy(dest, ((uint8_t *)ring->buf) + *tail, (size_t)n); in lws_ring_consume()
247 *tail = ((*tail) + (unsigned int)n) % ring->buflen; in lws_ring_consume()
249 lws_ring_update_oldest_tail(ring, *tail); in lws_ring_consume()
255 lws_ring_get_element(struct lws_ring *ring, uint32_t *tail) in lws_ring_get_element() argument
257 if (!tail) in lws_ring_get_element()
258 tail = &ring->oldest_tail; in lws_ring_get_element()
260 if (*tail == ring->head) in lws_ring_get_element()
263 return ((uint8_t *)ring->buf) + *tail; in lws_ring_get_element()
267 lws_ring_update_oldest_tail(struct lws_ring *ring, uint32_t tail) in lws_ring_update_oldest_tail() argument
270 ring->oldest_tail = tail; in lws_ring_update_oldest_tail()
274 while (ring->oldest_tail != tail) { in lws_ring_update_oldest_tail()
288 lws_ring_dump(struct lws_ring *ring, uint32_t *tail) in lws_ring_dump() argument
290 if (tail == NULL) in lws_ring_dump()
291 tail = &ring->oldest_tail; in lws_ring_dump()
296 (int)lws_ring_get_count_free_elements(ring), (int)*tail, in lws_ring_dump()
297 (int)lws_ring_get_count_waiting_elements(ring, tail)); in lws_ring_dump()