mirror of https://gitlab.com/qemu-project/qemu
util/fifo8: Rename fifo8_pop_buf() -> fifo8_pop_bufptr()
Since fifo8_pop_buf() return a const buffer (which points directly into the FIFO backing store). Rename it using the 'bufptr' suffix to better reflect that it is a pointer to the internal buffer that is being returned. This will help differentiate with methods *copying* the FIFO data. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Message-Id: <20240722160745.67904-6-philmd@linaro.org>
This commit is contained in:
parent
06a16e7ba9
commit
06252bf512
|
@ -81,7 +81,7 @@ static void msmouse_chr_accept_input(Chardev *chr)
|
||||||
const uint8_t *buf;
|
const uint8_t *buf;
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
|
|
||||||
buf = fifo8_pop_buf(&mouse->outbuf, MIN(len, avail), &size);
|
buf = fifo8_pop_bufptr(&mouse->outbuf, MIN(len, avail), &size);
|
||||||
qemu_chr_be_write(chr, buf, size);
|
qemu_chr_be_write(chr, buf, size);
|
||||||
len = qemu_chr_be_can_write(chr);
|
len = qemu_chr_be_can_write(chr);
|
||||||
avail -= size;
|
avail -= size;
|
||||||
|
|
|
@ -109,7 +109,7 @@ static void goldfish_tty_cmd(GoldfishTTYState *s, uint32_t cmd)
|
||||||
len = s->data_len;
|
len = s->data_len;
|
||||||
ptr = s->data_ptr;
|
ptr = s->data_ptr;
|
||||||
while (len && !fifo8_is_empty(&s->rx_fifo)) {
|
while (len && !fifo8_is_empty(&s->rx_fifo)) {
|
||||||
const uint8_t *buf = fifo8_pop_buf(&s->rx_fifo, len, &to_copy);
|
const uint8_t *buf = fifo8_pop_bufptr(&s->rx_fifo, len, &to_copy);
|
||||||
|
|
||||||
dma_memory_write_relaxed(&address_space_memory, ptr, buf, to_copy);
|
dma_memory_write_relaxed(&address_space_memory, ptr, buf, to_copy);
|
||||||
|
|
||||||
|
|
|
@ -349,7 +349,7 @@ static void aw_emac_write(void *opaque, hwaddr offset, uint64_t value,
|
||||||
"allwinner_emac: TX length > fifo data length\n");
|
"allwinner_emac: TX length > fifo data length\n");
|
||||||
}
|
}
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
data = fifo8_pop_buf(fifo, len, &ret);
|
data = fifo8_pop_bufptr(fifo, len, &ret);
|
||||||
qemu_send_packet(nc, data, ret);
|
qemu_send_packet(nc, data, ret);
|
||||||
aw_emac_tx_reset(s, chan);
|
aw_emac_tx_reset(s, chan);
|
||||||
/* Raise TX interrupt */
|
/* Raise TX interrupt */
|
||||||
|
|
|
@ -208,7 +208,7 @@ static uint32_t esp_fifo8_pop_buf(Fifo8 *fifo, uint8_t *dest, int maxlen)
|
||||||
}
|
}
|
||||||
|
|
||||||
len = maxlen;
|
len = maxlen;
|
||||||
buf = fifo8_pop_buf(fifo, len, &n);
|
buf = fifo8_pop_bufptr(fifo, len, &n);
|
||||||
if (dest) {
|
if (dest) {
|
||||||
memcpy(dest, buf, n);
|
memcpy(dest, buf, n);
|
||||||
}
|
}
|
||||||
|
@ -217,7 +217,7 @@ static uint32_t esp_fifo8_pop_buf(Fifo8 *fifo, uint8_t *dest, int maxlen)
|
||||||
len -= n;
|
len -= n;
|
||||||
len = MIN(len, fifo8_num_used(fifo));
|
len = MIN(len, fifo8_num_used(fifo));
|
||||||
if (len) {
|
if (len) {
|
||||||
buf = fifo8_pop_buf(fifo, len, &n2);
|
buf = fifo8_pop_bufptr(fifo, len, &n2);
|
||||||
if (dest) {
|
if (dest) {
|
||||||
memcpy(&dest[n], buf, n2);
|
memcpy(&dest[n], buf, n2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,15 +63,15 @@ void fifo8_push_all(Fifo8 *fifo, const uint8_t *data, uint32_t num);
|
||||||
uint8_t fifo8_pop(Fifo8 *fifo);
|
uint8_t fifo8_pop(Fifo8 *fifo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fifo8_pop_buf:
|
* fifo8_pop_bufptr:
|
||||||
* @fifo: FIFO to pop from
|
* @fifo: FIFO to pop from
|
||||||
* @max: maximum number of bytes to pop
|
* @max: maximum number of bytes to pop
|
||||||
* @numptr: pointer filled with number of bytes returned (can be NULL)
|
* @numptr: pointer filled with number of bytes returned (can be NULL)
|
||||||
*
|
*
|
||||||
* Pop a number of elements from the FIFO up to a maximum of @max. The buffer
|
* Pop a number of elements from the FIFO up to a maximum of @max. The buffer
|
||||||
* containing the popped data is returned. This buffer points directly into
|
* containing the popped data is returned. This buffer points directly into
|
||||||
* the FIFO backing store and data is invalidated once any of the fifo8_* APIs
|
* the internal FIFO backing store and data (without checking for overflow!)
|
||||||
* are called on the FIFO.
|
* and is invalidated once any of the fifo8_* APIs are called on the FIFO.
|
||||||
*
|
*
|
||||||
* The function may return fewer bytes than requested when the data wraps
|
* The function may return fewer bytes than requested when the data wraps
|
||||||
* around in the ring buffer; in this case only a contiguous part of the data
|
* around in the ring buffer; in this case only a contiguous part of the data
|
||||||
|
@ -86,7 +86,7 @@ uint8_t fifo8_pop(Fifo8 *fifo);
|
||||||
*
|
*
|
||||||
* Returns: A pointer to popped data.
|
* Returns: A pointer to popped data.
|
||||||
*/
|
*/
|
||||||
const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr);
|
const uint8_t *fifo8_pop_bufptr(Fifo8 *fifo, uint32_t max, uint32_t *numptr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fifo8_peek_bufptr: read upto max bytes from the fifo
|
* fifo8_peek_bufptr: read upto max bytes from the fifo
|
||||||
|
@ -96,10 +96,9 @@ const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr);
|
||||||
*
|
*
|
||||||
* Peek into a number of elements from the FIFO up to a maximum of @max.
|
* Peek into a number of elements from the FIFO up to a maximum of @max.
|
||||||
* The buffer containing the data peeked into is returned. This buffer points
|
* The buffer containing the data peeked into is returned. This buffer points
|
||||||
* directly into the internal FIFO backing store (without checking for
|
* directly into the FIFO backing store. Since data is invalidated once any
|
||||||
* overflow!). Since data is invalidated once any of the fifo8_* APIs are
|
* of the fifo8_* APIs are called on the FIFO, it is the caller responsibility
|
||||||
* called on the FIFO, it is the caller responsibility to access it before
|
* to access it before doing further API calls.
|
||||||
* doing further API calls.
|
|
||||||
*
|
*
|
||||||
* The function may return fewer bytes than requested when the data wraps
|
* The function may return fewer bytes than requested when the data wraps
|
||||||
* around in the ring buffer; in this case only a contiguous part of the data
|
* around in the ring buffer; in this case only a contiguous part of the data
|
||||||
|
|
|
@ -287,7 +287,7 @@ static void kbd_send_chars(QemuTextConsole *s)
|
||||||
const uint8_t *buf;
|
const uint8_t *buf;
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
|
|
||||||
buf = fifo8_pop_buf(&s->out_fifo, MIN(len, avail), &size);
|
buf = fifo8_pop_bufptr(&s->out_fifo, MIN(len, avail), &size);
|
||||||
qemu_chr_be_write(s->chr, buf, size);
|
qemu_chr_be_write(s->chr, buf, size);
|
||||||
len = qemu_chr_be_can_write(s->chr);
|
len = qemu_chr_be_can_write(s->chr);
|
||||||
avail -= size;
|
avail -= size;
|
||||||
|
|
2
ui/gtk.c
2
ui/gtk.c
|
@ -1820,7 +1820,7 @@ static void gd_vc_send_chars(VirtualConsole *vc)
|
||||||
const uint8_t *buf;
|
const uint8_t *buf;
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
|
|
||||||
buf = fifo8_pop_buf(&vc->vte.out_fifo, MIN(len, avail), &size);
|
buf = fifo8_pop_bufptr(&vc->vte.out_fifo, MIN(len, avail), &size);
|
||||||
qemu_chr_be_write(vc->vte.chr, buf, size);
|
qemu_chr_be_write(vc->vte.chr, buf, size);
|
||||||
len = qemu_chr_be_can_write(vc->vte.chr);
|
len = qemu_chr_be_can_write(vc->vte.chr);
|
||||||
avail -= size;
|
avail -= size;
|
||||||
|
|
|
@ -97,7 +97,7 @@ const uint8_t *fifo8_peek_bufptr(Fifo8 *fifo, uint32_t max, uint32_t *numptr)
|
||||||
return fifo8_peekpop_buf(fifo, max, numptr, false);
|
return fifo8_peekpop_buf(fifo, max, numptr, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *numptr)
|
const uint8_t *fifo8_pop_bufptr(Fifo8 *fifo, uint32_t max, uint32_t *numptr)
|
||||||
{
|
{
|
||||||
return fifo8_peekpop_buf(fifo, max, numptr, true);
|
return fifo8_peekpop_buf(fifo, max, numptr, true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue