qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Fam Zheng <famz@redhat.com>, qemu-devel@nongnu.org
Cc: kwolf@redhat.com, mjt@tls.msk.ru, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH 1/6] build-sys: Move fifio8 to hw/
Date: Wed, 20 Aug 2014 15:33:28 +0200	[thread overview]
Message-ID: <53F4A3A8.7070003@redhat.com> (raw)
In-Reply-To: <1408528887-22200-2-git-send-email-famz@redhat.com>

Typo in the subject, and please set up git to do rename detection
correctly.  I still could review the patch by checking the hashes in the
"index" lines, so:

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

Il 20/08/2014 12:01, Fam Zheng ha scritto:
> Since it has a dependency on vmstate and is only used by device
> emulation, moving out from util will make the archive more independent.
> 
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
>  hw/Makefile.objs   |   1 +
>  hw/fifo8.c         | 125 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  util/Makefile.objs |   1 -
>  util/fifo8.c       | 125 -----------------------------------------------------
>  4 files changed, 126 insertions(+), 126 deletions(-)
>  create mode 100644 hw/fifo8.c
>  delete mode 100644 util/fifo8.c
> 
> diff --git a/hw/Makefile.objs b/hw/Makefile.objs
> index 52a1464..bc77dd3 100644
> --- a/hw/Makefile.objs
> +++ b/hw/Makefile.objs
> @@ -33,3 +33,4 @@ devices-dirs-$(CONFIG_MEM_HOTPLUG) += mem/
>  devices-dirs-y += core/
>  common-obj-y += $(devices-dirs-y)
>  obj-y += $(devices-dirs-y)
> +obj-y += fifo8.o
> diff --git a/hw/fifo8.c b/hw/fifo8.c
> new file mode 100644
> index 0000000..0ea5ad9
> --- /dev/null
> +++ b/hw/fifo8.c
> @@ -0,0 +1,125 @@
> +/*
> + * Generic FIFO component, implemented as a circular buffer.
> + *
> + * Copyright (c) 2012 Peter A. G. Crosthwaite
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation; either version
> + * 2 of the License, or (at your option) any later version.
> + *
> + * You should have received a copy of the GNU General Public License along
> + * with this program; if not, see <http://www.gnu.org/licenses/>.
> + */
> +
> +#include "qemu-common.h"
> +#include "qemu/fifo8.h"
> +
> +void fifo8_create(Fifo8 *fifo, uint32_t capacity)
> +{
> +    fifo->data = g_new(uint8_t, capacity);
> +    fifo->capacity = capacity;
> +    fifo->head = 0;
> +    fifo->num = 0;
> +}
> +
> +void fifo8_destroy(Fifo8 *fifo)
> +{
> +    g_free(fifo->data);
> +}
> +
> +void fifo8_push(Fifo8 *fifo, uint8_t data)
> +{
> +    if (fifo->num == fifo->capacity) {
> +        abort();
> +    }
> +    fifo->data[(fifo->head + fifo->num) % fifo->capacity] = data;
> +    fifo->num++;
> +}
> +
> +void fifo8_push_all(Fifo8 *fifo, const uint8_t *data, uint32_t num)
> +{
> +    uint32_t start, avail;
> +
> +    if (fifo->num + num > fifo->capacity) {
> +        abort();
> +    }
> +
> +    start = (fifo->head + fifo->num) % fifo->capacity;
> +
> +    if (start + num <= fifo->capacity) {
> +        memcpy(&fifo->data[start], data, num);
> +    } else {
> +        avail = fifo->capacity - start;
> +        memcpy(&fifo->data[start], data, avail);
> +        memcpy(&fifo->data[0], &data[avail], num - avail);
> +    }
> +
> +    fifo->num += num;
> +}
> +
> +uint8_t fifo8_pop(Fifo8 *fifo)
> +{
> +    uint8_t ret;
> +
> +    if (fifo->num == 0) {
> +        abort();
> +    }
> +    ret = fifo->data[fifo->head++];
> +    fifo->head %= fifo->capacity;
> +    fifo->num--;
> +    return ret;
> +}
> +
> +const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *num)
> +{
> +    uint8_t *ret;
> +
> +    if (max == 0 || max > fifo->num) {
> +        abort();
> +    }
> +    *num = MIN(fifo->capacity - fifo->head, max);
> +    ret = &fifo->data[fifo->head];
> +    fifo->head += *num;
> +    fifo->head %= fifo->capacity;
> +    fifo->num -= *num;
> +    return ret;
> +}
> +
> +void fifo8_reset(Fifo8 *fifo)
> +{
> +    fifo->num = 0;
> +    fifo->head = 0;
> +}
> +
> +bool fifo8_is_empty(Fifo8 *fifo)
> +{
> +    return (fifo->num == 0);
> +}
> +
> +bool fifo8_is_full(Fifo8 *fifo)
> +{
> +    return (fifo->num == fifo->capacity);
> +}
> +
> +uint32_t fifo8_num_free(Fifo8 *fifo)
> +{
> +    return fifo->capacity - fifo->num;
> +}
> +
> +uint32_t fifo8_num_used(Fifo8 *fifo)
> +{
> +    return fifo->num;
> +}
> +
> +const VMStateDescription vmstate_fifo8 = {
> +    .name = "Fifo8",
> +    .version_id = 1,
> +    .minimum_version_id = 1,
> +    .fields = (VMStateField[]) {
> +        VMSTATE_VBUFFER_UINT32(data, Fifo8, 1, NULL, 0, capacity),
> +        VMSTATE_UINT32(head, Fifo8),
> +        VMSTATE_UINT32(num, Fifo8),
> +        VMSTATE_END_OF_LIST()
> +    }
> +};
> diff --git a/util/Makefile.objs b/util/Makefile.objs
> index 6b3c83b..65a36f6 100644
> --- a/util/Makefile.objs
> +++ b/util/Makefile.objs
> @@ -3,7 +3,6 @@ util-obj-$(CONFIG_WIN32) += oslib-win32.o qemu-thread-win32.o event_notifier-win
>  util-obj-$(CONFIG_POSIX) += oslib-posix.o qemu-thread-posix.o event_notifier-posix.o qemu-openpty.o
>  util-obj-y += envlist.o path.o host-utils.o module.o
>  util-obj-y += bitmap.o bitops.o hbitmap.o
> -util-obj-y += fifo8.o
>  util-obj-y += acl.o
>  util-obj-y += error.o qemu-error.o
>  util-obj-$(CONFIG_POSIX) += compatfd.o
> diff --git a/util/fifo8.c b/util/fifo8.c
> deleted file mode 100644
> index 0ea5ad9..0000000
> --- a/util/fifo8.c
> +++ /dev/null
> @@ -1,125 +0,0 @@
> -/*
> - * Generic FIFO component, implemented as a circular buffer.
> - *
> - * Copyright (c) 2012 Peter A. G. Crosthwaite
> - *
> - * This program is free software; you can redistribute it and/or
> - * modify it under the terms of the GNU General Public License
> - * as published by the Free Software Foundation; either version
> - * 2 of the License, or (at your option) any later version.
> - *
> - * You should have received a copy of the GNU General Public License along
> - * with this program; if not, see <http://www.gnu.org/licenses/>.
> - */
> -
> -#include "qemu-common.h"
> -#include "qemu/fifo8.h"
> -
> -void fifo8_create(Fifo8 *fifo, uint32_t capacity)
> -{
> -    fifo->data = g_new(uint8_t, capacity);
> -    fifo->capacity = capacity;
> -    fifo->head = 0;
> -    fifo->num = 0;
> -}
> -
> -void fifo8_destroy(Fifo8 *fifo)
> -{
> -    g_free(fifo->data);
> -}
> -
> -void fifo8_push(Fifo8 *fifo, uint8_t data)
> -{
> -    if (fifo->num == fifo->capacity) {
> -        abort();
> -    }
> -    fifo->data[(fifo->head + fifo->num) % fifo->capacity] = data;
> -    fifo->num++;
> -}
> -
> -void fifo8_push_all(Fifo8 *fifo, const uint8_t *data, uint32_t num)
> -{
> -    uint32_t start, avail;
> -
> -    if (fifo->num + num > fifo->capacity) {
> -        abort();
> -    }
> -
> -    start = (fifo->head + fifo->num) % fifo->capacity;
> -
> -    if (start + num <= fifo->capacity) {
> -        memcpy(&fifo->data[start], data, num);
> -    } else {
> -        avail = fifo->capacity - start;
> -        memcpy(&fifo->data[start], data, avail);
> -        memcpy(&fifo->data[0], &data[avail], num - avail);
> -    }
> -
> -    fifo->num += num;
> -}
> -
> -uint8_t fifo8_pop(Fifo8 *fifo)
> -{
> -    uint8_t ret;
> -
> -    if (fifo->num == 0) {
> -        abort();
> -    }
> -    ret = fifo->data[fifo->head++];
> -    fifo->head %= fifo->capacity;
> -    fifo->num--;
> -    return ret;
> -}
> -
> -const uint8_t *fifo8_pop_buf(Fifo8 *fifo, uint32_t max, uint32_t *num)
> -{
> -    uint8_t *ret;
> -
> -    if (max == 0 || max > fifo->num) {
> -        abort();
> -    }
> -    *num = MIN(fifo->capacity - fifo->head, max);
> -    ret = &fifo->data[fifo->head];
> -    fifo->head += *num;
> -    fifo->head %= fifo->capacity;
> -    fifo->num -= *num;
> -    return ret;
> -}
> -
> -void fifo8_reset(Fifo8 *fifo)
> -{
> -    fifo->num = 0;
> -    fifo->head = 0;
> -}
> -
> -bool fifo8_is_empty(Fifo8 *fifo)
> -{
> -    return (fifo->num == 0);
> -}
> -
> -bool fifo8_is_full(Fifo8 *fifo)
> -{
> -    return (fifo->num == fifo->capacity);
> -}
> -
> -uint32_t fifo8_num_free(Fifo8 *fifo)
> -{
> -    return fifo->capacity - fifo->num;
> -}
> -
> -uint32_t fifo8_num_used(Fifo8 *fifo)
> -{
> -    return fifo->num;
> -}
> -
> -const VMStateDescription vmstate_fifo8 = {
> -    .name = "Fifo8",
> -    .version_id = 1,
> -    .minimum_version_id = 1,
> -    .fields = (VMStateField[]) {
> -        VMSTATE_VBUFFER_UINT32(data, Fifo8, 1, NULL, 0, capacity),
> -        VMSTATE_UINT32(head, Fifo8),
> -        VMSTATE_UINT32(num, Fifo8),
> -        VMSTATE_END_OF_LIST()
> -    }
> -};
> 

  reply	other threads:[~2014-08-20 13:33 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-20 10:01 [Qemu-devel] [PATCH 0/6] build-sys: Fix iscsi module loading failure Fam Zheng
2014-08-20 10:01 ` [Qemu-devel] [PATCH 1/6] build-sys: Move fifio8 to hw/ Fam Zheng
2014-08-20 13:33   ` Paolo Bonzini [this message]
2014-08-20 14:23   ` Peter Crosthwaite
2014-08-20 14:52     ` Fam Zheng
2014-08-20 10:01 ` [Qemu-devel] [PATCH 2/6] stubs: Add iohandler.c Fam Zheng
2014-08-20 13:25   ` Paolo Bonzini
2014-08-20 10:01 ` [Qemu-devel] [PATCH 3/6] stubs: Add openpty.c Fam Zheng
2014-08-20 13:26   ` Paolo Bonzini
2014-08-20 10:01 ` [Qemu-devel] [PATCH 4/6] stubs: Add timer.c Fam Zheng
2014-08-20 13:27   ` Paolo Bonzini
2014-08-20 10:01 ` [Qemu-devel] [PATCH 5/6] build-sys: Change libqemuutil.a to qemuutil.o and link whole object Fam Zheng
2014-08-20 13:29   ` Paolo Bonzini
2014-08-21  3:02     ` Fam Zheng
2014-08-21  9:04       ` Paolo Bonzini
2014-08-20 10:01 ` [Qemu-devel] [PATCH 6/6] iscsi: Move iqn generation code to util Fam Zheng
2014-08-20 13:32   ` Paolo Bonzini
2014-08-20 15:03     ` Fam Zheng
2014-08-21  3:54     ` Fam Zheng
2014-08-21  9:02       ` Paolo Bonzini
2014-08-21  9:12         ` Fam Zheng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53F4A3A8.7070003@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=famz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mjt@tls.msk.ru \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).