qemu-sparc queue

-----BEGIN PGP SIGNATURE-----
 
 iQFSBAABCgA8FiEEzGIauY6CIA2RXMnEW8LFb64PMh8FAmAgZQgeHG1hcmsuY2F2
 ZS1heWxhbmRAaWxhbmRlLmNvLnVrAAoJEFvCxW+uDzIfGowH/2JNIL3Uh0rLNMZ9
 wu5VPkZWPFHwXdbRiQBFZLi33JTYdkzMVl8cJ83KkUPi26hG+S9sszCRZmrPM76E
 vPPABm+jTqjSC5jQcVYcjaEhhLPCT4iq66m+F58Quw66C/StWY/c0W2LZNC6d6ul
 U6lrU8T/ycOo/IH9WrANRiDuAudbsPDC/riLZpyOUAe3muSirxAUFC0Mg40wdHMN
 vcDD4PoOruDFoUEn9vOvmuHYkKLSY8HZvmU6SVqx51ZJlPDlpp/z3GjjI81ftleL
 w6/FyEFuu9kzF4D7BJ2K8DnvUiMBXq+hC9bLfX4nQUXE2JHDIExphVurTtyPNrR+
 7V56TO4=
 =7Gso
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/mcayland/tags/qemu-sparc-20210207' into staging

qemu-sparc queue

# gpg: Signature made Sun 07 Feb 2021 22:09:12 GMT
# gpg:                using RSA key CC621AB98E82200D915CC9C45BC2C56FAE0F321F
# gpg:                issuer "mark.cave-ayland@ilande.co.uk"
# gpg: Good signature from "Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>" [full]
# Primary key fingerprint: CC62 1AB9 8E82 200D 915C  C9C4 5BC2 C56F AE0F 321F

* remotes/mcayland/tags/qemu-sparc-20210207:
  utils/fifo8: add VMSTATE_FIFO8_TEST macro
  utils/fifo8: change fatal errors from abort() to assert()

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2021-02-08 09:23:53 +00:00
commit 2766043345
2 changed files with 14 additions and 18 deletions

View File

@ -148,12 +148,16 @@ uint32_t fifo8_num_used(Fifo8 *fifo);
extern const VMStateDescription vmstate_fifo8;
#define VMSTATE_FIFO8(_field, _state) { \
.name = (stringify(_field)), \
.size = sizeof(Fifo8), \
.vmsd = &vmstate_fifo8, \
.flags = VMS_STRUCT, \
.offset = vmstate_offset_value(_state, _field, Fifo8), \
#define VMSTATE_FIFO8_TEST(_field, _state, _test) { \
.name = (stringify(_field)), \
.field_exists = (_test), \
.size = sizeof(Fifo8), \
.vmsd = &vmstate_fifo8, \
.flags = VMS_STRUCT, \
.offset = vmstate_offset_value(_state, _field, Fifo8), \
}
#define VMSTATE_FIFO8(_field, _state) \
VMSTATE_FIFO8_TEST(_field, _state, NULL)
#endif /* QEMU_FIFO8_H */

View File

@ -31,9 +31,7 @@ void fifo8_destroy(Fifo8 *fifo)
void fifo8_push(Fifo8 *fifo, uint8_t data)
{
if (fifo->num == fifo->capacity) {
abort();
}
assert(fifo->num < fifo->capacity);
fifo->data[(fifo->head + fifo->num) % fifo->capacity] = data;
fifo->num++;
}
@ -42,9 +40,7 @@ void fifo8_push_all(Fifo8 *fifo, const uint8_t *data, uint32_t num)
{
uint32_t start, avail;
if (fifo->num + num > fifo->capacity) {
abort();
}
assert(fifo->num + num <= fifo->capacity);
start = (fifo->head + fifo->num) % fifo->capacity;
@ -63,9 +59,7 @@ uint8_t fifo8_pop(Fifo8 *fifo)
{
uint8_t ret;
if (fifo->num == 0) {
abort();
}
assert(fifo->num > 0);
ret = fifo->data[fifo->head++];
fifo->head %= fifo->capacity;
fifo->num--;
@ -76,9 +70,7 @@ const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *num)
{
uint8_t *ret;
if (max == 0 || max > fifo->num) {
abort();
}
assert(max > 0 && max <= fifo->num);
*num = MIN(fifo->capacity - fifo->head, max);
ret = &fifo->data[fifo->head];
fifo->head += *num;