diff options
author | Blue Swirl <blauwirbel@gmail.com> | 2009-09-12 07:36:22 +0000 |
---|---|---|
committer | Blue Swirl <blauwirbel@gmail.com> | 2009-09-12 07:36:22 +0000 |
commit | 72cf2d4f0e181d0d3a3122e04129c58a95da713e (patch) | |
tree | 4d13c505a692104406090e94dd654fd1e98ec34e | |
parent | 620150dc9c1827cdddfa64a0fada7af5f7ee405b (diff) | |
download | qemu-72cf2d4f0e181d0d3a3122e04129c58a95da713e.tar.gz qemu-72cf2d4f0e181d0d3a3122e04129c58a95da713e.tar.bz2 qemu-72cf2d4f0e181d0d3a3122e04129c58a95da713e.zip |
Fix sys-queue.h conflict for good
Problem: Our file sys-queue.h is a copy of the BSD file, but there are
some additions and it's not entirely compatible. Because of that, there have
been conflicts with system headers on BSD systems. Some hacks have been
introduced in the commits 15cc9235840a22c289edbe064a9b3c19c5f49896,
f40d753718c72693c5f520f0d9899f6e50395e94,
96555a96d724016e13190b28cffa3bc929ac60dc and
3990d09adf4463eca200ad964cc55643c33feb50 but the fixes were fragile.
Solution: Avoid the conflict entirely by renaming the functions and the
file. Revert the previous hacks.
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
65 files changed, 481 insertions, 488 deletions
@@ -64,7 +64,7 @@ qemu_acl *qemu_acl_init(const char *aclname) acl->defaultDeny = 1; acl->nentries = 0; - TAILQ_INIT(&acl->entries); + QTAILQ_INIT(&acl->entries); acls = qemu_realloc(acls, sizeof(*acls) * (nacls +1)); acls[nacls] = acl; @@ -78,7 +78,7 @@ int qemu_acl_party_is_allowed(qemu_acl *acl, { qemu_acl_entry *entry; - TAILQ_FOREACH(entry, &acl->entries, next) { + QTAILQ_FOREACH(entry, &acl->entries, next) { #ifdef CONFIG_FNMATCH if (fnmatch(entry->match, party, 0) == 0) return entry->deny ? 0 : 1; @@ -102,8 +102,8 @@ void qemu_acl_reset(qemu_acl *acl) * of "open access" while the user re-initializes the * access control list */ acl->defaultDeny = 1; - TAILQ_FOREACH(entry, &acl->entries, next) { - TAILQ_REMOVE(&acl->entries, entry, next); + QTAILQ_FOREACH(entry, &acl->entries, next) { + QTAILQ_REMOVE(&acl->entries, entry, next); free(entry->match); free(entry); } @@ -121,7 +121,7 @@ int qemu_acl_append(qemu_acl *acl, entry->match = qemu_strdup(match); entry->deny = deny; - TAILQ_INSERT_TAIL(&acl->entries, entry, next); + QTAILQ_INSERT_TAIL(&acl->entries, entry, next); acl->nentries++; return acl->nentries; @@ -147,10 +147,10 @@ int qemu_acl_insert(qemu_acl *acl, entry->match = qemu_strdup(match); entry->deny = deny; - TAILQ_FOREACH(tmp, &acl->entries, next) { + QTAILQ_FOREACH(tmp, &acl->entries, next) { i++; if (i == index) { - TAILQ_INSERT_BEFORE(tmp, entry, next); + QTAILQ_INSERT_BEFORE(tmp, entry, next); acl->nentries++; break; } @@ -165,10 +165,10 @@ int qemu_acl_remove(qemu_acl *acl, qemu_acl_entry *entry; int i = 0; - TAILQ_FOREACH(entry, &acl->entries, next) { + QTAILQ_FOREACH(entry, &acl->entries, next) { i++; if (strcmp(entry->match, match) == 0) { - TAILQ_REMOVE(&acl->entries, entry, next); + QTAILQ_REMOVE(&acl->entries, entry, next); return i; } } @@ -25,7 +25,7 @@ #ifndef __QEMU_ACL_H__ #define __QEMU_ACL_H__ -#include "sys-queue.h" +#include "qemu-queue.h" typedef struct qemu_acl_entry qemu_acl_entry; typedef struct qemu_acl qemu_acl; @@ -34,13 +34,13 @@ struct qemu_acl_entry { char *match; int deny; - TAILQ_ENTRY(qemu_acl_entry) next; + QTAILQ_ENTRY(qemu_acl_entry) next; }; struct qemu_acl { char *aclname; unsigned int nentries; - TAILQ_HEAD(,qemu_acl_entry) entries; + QTAILQ_HEAD(,qemu_acl_entry) entries; int defaultDeny; }; @@ -13,13 +13,13 @@ #include "qemu-common.h" #include "block.h" -#include "sys-queue.h" +#include "qemu-queue.h" #include "qemu_socket.h" typedef struct AioHandler AioHandler; /* The list of registered AIO handlers */ -static LIST_HEAD(, AioHandler) aio_handlers; +static QLIST_HEAD(, AioHandler) aio_handlers; /* This is a simple lock used to protect the aio_handlers list. Specifically, * it's used to ensure that no callbacks are removed while we're walking and @@ -35,14 +35,14 @@ struct AioHandler AioFlushHandler *io_flush; int deleted; void *opaque; - LIST_ENTRY(AioHandler) node; + QLIST_ENTRY(AioHandler) node; }; static AioHandler *find_aio_handler(int fd) { AioHandler *node; - LIST_FOREACH(node, &aio_handlers, node) { + QLIST_FOREACH(node, &aio_handlers, node) { if (node->fd == fd) if (!node->deleted) return node; @@ -72,7 +72,7 @@ int qemu_aio_set_fd_handler(int fd, * deleted because deleted nodes are only cleaned up after * releasing the walking_handlers lock. */ - LIST_REMOVE(node, node); + QLIST_REMOVE(node, node); qemu_free(node); } } @@ -81,7 +81,7 @@ int qemu_aio_set_fd_handler(int fd, /* Alloc and insert if it's not already there */ node = qemu_mallocz(sizeof(AioHandler)); node->fd = fd; - LIST_INSERT_HEAD(&aio_handlers, node, node); + QLIST_INSERT_HEAD(&aio_handlers, node, node); } /* Update handler with latest information */ node->io_read = io_read; @@ -109,7 +109,7 @@ void qemu_aio_flush(void) */ qemu_aio_wait(); - LIST_FOREACH(node, &aio_handlers, node) { + QLIST_FOREACH(node, &aio_handlers, node) { ret |= node->io_flush(node->opaque); } } while (qemu_bh_poll() || ret > 0); @@ -133,7 +133,7 @@ void qemu_aio_wait(void) FD_ZERO(&wrfds); /* fill fd sets */ - LIST_FOREACH(node, &aio_handlers, node) { + QLIST_FOREACH(node, &aio_handlers, node) { /* If there aren't pending AIO operations, don't invoke callbacks. * Otherwise, if there are no AIO requests, qemu_aio_wait() would * wait indefinitely. @@ -168,7 +168,7 @@ void qemu_aio_wait(void) /* we have to walk very carefully in case * qemu_aio_set_fd_handler is called while we're walking */ - node = LIST_FIRST(&aio_handlers); + node = QLIST_FIRST(&aio_handlers); while (node) { AioHandler *tmp; @@ -184,10 +184,10 @@ void qemu_aio_wait(void) } tmp = node; - node = LIST_NEXT(node, node); + node = QLIST_NEXT(node, node); if (tmp->deleted) { - LIST_REMOVE(tmp, node); + QLIST_REMOVE(tmp, node); qemu_free(tmp); } } diff --git a/audio/audio.c b/audio/audio.c index aa9ea3ea0e..e223cf3e82 100644 --- a/audio/audio.c +++ b/audio/audio.c @@ -766,8 +766,8 @@ static void audio_detach_capture (HWVoiceOut *hw) sw->rate = NULL; } - LIST_REMOVE (sw, entries); - LIST_REMOVE (sc, entries); + QLIST_REMOVE (sw, entries); + QLIST_REMOVE (sc, entries); qemu_free (sc); if (was_active) { /* We have removed soft voice from the capture: @@ -811,8 +811,8 @@ static int audio_attach_capture (HWVoiceOut *hw) qemu_free (sw); return -1; } - LIST_INSERT_HEAD (&hw_cap->sw_head, sw, entries); - LIST_INSERT_HEAD (&hw->cap_head, sc, entries); + QLIST_INSERT_HEAD (&hw_cap->sw_head, sw, entries); + QLIST_INSERT_HEAD (&hw->cap_head, sc, entries); #ifdef DEBUG_CAPTURE asprintf (&sw->name, "for %p %d,%d,%d", hw, sw->info.freq, sw->info.bits, sw->info.nchannels); @@ -1803,9 +1803,9 @@ static void audio_init (void) return; } - LIST_INIT (&s->hw_head_out); - LIST_INIT (&s->hw_head_in); - LIST_INIT (&s->cap_head); + QLIST_INIT (&s->hw_head_out); + QLIST_INIT (&s->hw_head_in); + QLIST_INIT (&s->cap_head); atexit (audio_atexit); s->ts = qemu_new_timer (vm_clock, audio_timer, s); @@ -1887,7 +1887,7 @@ static void audio_init (void) "(Audio can continue looping even after stopping the VM)\n"); } - LIST_INIT (&s->card_head); + QLIST_INIT (&s->card_head); register_savevm ("audio", 0, 1, audio_save, audio_load, s); } @@ -1896,12 +1896,12 @@ void AUD_register_card (const char *name, QEMUSoundCard *card) audio_init (); card->name = qemu_strdup (name); memset (&card->entries, 0, sizeof (card->entries)); - LIST_INSERT_HEAD (&glob_audio_state.card_head, card, entries); + QLIST_INSERT_HEAD (&glob_audio_state.card_head, card, entries); } void AUD_remove_card (QEMUSoundCard *card) { - LIST_REMOVE (card, entries); + QLIST_REMOVE (card, entries); qemu_free (card->name); } @@ -1933,7 +1933,7 @@ CaptureVoiceOut *AUD_add_capture ( cap = audio_pcm_capture_find_specific (as); if (cap) { - LIST_INSERT_HEAD (&cap->cb_head, cb, entries); + QLIST_INSERT_HEAD (&cap->cb_head, cb, entries); return cap; } else { @@ -1948,8 +1948,8 @@ CaptureVoiceOut *AUD_add_capture ( } hw = &cap->hw; - LIST_INIT (&hw->sw_head); - LIST_INIT (&cap->cb_head); + QLIST_INIT (&hw->sw_head); + QLIST_INIT (&cap->cb_head); /* XXX find a more elegant way */ hw->samples = 4096 * 4; @@ -1977,8 +1977,8 @@ CaptureVoiceOut *AUD_add_capture ( [hw->info.swap_endianness] [audio_bits_to_index (hw->info.bits)]; - LIST_INSERT_HEAD (&s->cap_head, cap, entries); - LIST_INSERT_HEAD (&cap->cb_head, cb, entries); + QLIST_INSERT_HEAD (&s->cap_head, cap, entries); + QLIST_INSERT_HEAD (&cap->cb_head, cb, entries); hw = NULL; while ((hw = audio_pcm_hw_find_any_out (hw))) { @@ -2004,7 +2004,7 @@ void AUD_del_capture (CaptureVoiceOut *cap, void *cb_opaque) for (cb = cap->cb_head.lh_first; cb; cb = cb->entries.le_next) { if (cb->opaque == cb_opaque) { cb->ops.destroy (cb_opaque); - LIST_REMOVE (cb, entries); + QLIST_REMOVE (cb, entries); qemu_free (cb); if (!cap->cb_head.lh_first) { @@ -2021,12 +2021,12 @@ void AUD_del_capture (CaptureVoiceOut *cap, void *cb_opaque) st_rate_stop (sw->rate); sw->rate = NULL; } - LIST_REMOVE (sw, entries); - LIST_REMOVE (sc, entries); + QLIST_REMOVE (sw, entries); + QLIST_REMOVE (sc, entries); qemu_free (sc); sw = sw1; } - LIST_REMOVE (cap, entries); + QLIST_REMOVE (cap, entries); qemu_free (cap); } return; diff --git a/audio/audio.h b/audio/audio.h index dec86e5f77..f234ad0f54 100644 --- a/audio/audio.h +++ b/audio/audio.h @@ -25,7 +25,7 @@ #define QEMU_AUDIO_H #include "config-host.h" -#include "sys-queue.h" +#include "qemu-queue.h" typedef void (*audio_callback_fn_t) (void *opaque, int avail); @@ -70,7 +70,7 @@ struct capture_ops { typedef struct CaptureState { void *opaque; struct capture_ops ops; - LIST_ENTRY (CaptureState) entries; + QLIST_ENTRY (CaptureState) entries; } CaptureState; typedef struct SWVoiceOut SWVoiceOut; @@ -79,7 +79,7 @@ typedef struct SWVoiceIn SWVoiceIn; typedef struct QEMUSoundCard { char *name; - LIST_ENTRY (QEMUSoundCard) entries; + QLIST_ENTRY (QEMUSoundCard) entries; } QEMUSoundCard; typedef struct QEMUAudioTimeStamp { diff --git a/audio/audio_int.h b/audio/audio_int.h index d930d0790e..ce791ee46c 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -80,10 +80,10 @@ typedef struct HWVoiceOut { struct st_sample *mix_buf; int samples; - LIST_HEAD (sw_out_listhead, SWVoiceOut) sw_head; - LIST_HEAD (sw_cap_listhead, SWVoiceCap) cap_head; + QLIST_HEAD (sw_out_listhead, SWVoiceOut) sw_head; + QLIST_HEAD (sw_cap_listhead, SWVoiceCap) cap_head; struct audio_pcm_ops *pcm_ops; - LIST_ENTRY (HWVoiceOut) entries; + QLIST_ENTRY (HWVoiceOut) entries; } HWVoiceOut; typedef struct HWVoiceIn { @@ -100,9 +100,9 @@ typedef struct HWVoiceIn { struct st_sample *conv_buf; int samples; - LIST_HEAD (sw_in_listhead, SWVoiceIn) sw_head; + QLIST_HEAD (sw_in_listhead, SWVoiceIn) sw_head; struct audio_pcm_ops *pcm_ops; - LIST_ENTRY (HWVoiceIn) entries; + QLIST_ENTRY (HWVoiceIn) entries; } HWVoiceIn; struct SWVoiceOut { @@ -119,7 +119,7 @@ struct SWVoiceOut { char *name; struct mixeng_volume vol; struct audio_callback callback; - LIST_ENTRY (SWVoiceOut) entries; + QLIST_ENTRY (SWVoiceOut) entries; }; struct SWVoiceIn { @@ -135,7 +135,7 @@ struct SWVoiceIn { char *name; struct mixeng_volume vol; struct audio_callback callback; - LIST_ENTRY (SWVoiceIn) entries; + QLIST_ENTRY (SWVoiceIn) entries; }; struct audio_driver { @@ -169,20 +169,20 @@ struct audio_pcm_ops { struct capture_callback { struct audio_capture_ops ops; void *opaque; - LIST_ENTRY (capture_callback) entries; + QLIST_ENTRY (capture_callback) entries; }; struct CaptureVoiceOut { HWVoiceOut hw; void *buf; - LIST_HEAD (cb_listhead, capture_callback) cb_head; - LIST_ENTRY (CaptureVoiceOut) entries; + QLIST_HEAD (cb_listhead, capture_callback) cb_head; + QLIST_ENTRY (CaptureVoiceOut) entries; }; struct SWVoiceCap { SWVoiceOut sw; CaptureVoiceOut *cap; - LIST_ENTRY (SWVoiceCap) entries; + QLIST_ENTRY (SWVoiceCap) entries; }; struct AudioState { @@ -190,10 +190,10 @@ struct AudioState { void *drv_opaque; QEMUTimer *ts; - LIST_HEAD (card_listhead, QEMUSoundCard) card_head; - LIST_HEAD (hw_in_listhead, HWVoiceIn) hw_head_in; - LIST_HEAD (hw_out_listhead, HWVoiceOut) hw_head_out; - LIST_HEAD (cap_listhead, CaptureVoiceOut) cap_head; + QLIST_HEAD (card_listhead, QEMUSoundCard) card_head; + QLIST_HEAD (hw_in_listhead, HWVoiceIn) hw_head_in; + QLIST_HEAD (hw_out_listhead, HWVoiceOut) hw_head_out; + QLIST_HEAD (cap_listhead, CaptureVoiceOut) cap_head; int nb_hw_voices_out; int nb_hw_voices_in; int vm_running; diff --git a/audio/audio_template.h b/audio/audio_template.h index 0ffca652f5..e65d834ac9 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -184,12 +184,12 @@ static void glue (audio_pcm_sw_fini_, TYPE) (SW *sw) static void glue (audio_pcm_hw_add_sw_, TYPE) (HW *hw, SW *sw) { - LIST_INSERT_HEAD (&hw->sw_head, sw, entries); + QLIST_INSERT_HEAD (&hw->sw_head, sw, entries); } static void glue (audio_pcm_hw_del_sw_, TYPE) (SW *sw) { - LIST_REMOVE (sw, entries); + QLIST_REMOVE (sw, entries); } static void glue (audio_pcm_hw_gc_, TYPE) (HW **hwp) @@ -201,7 +201,7 @@ static void glue (audio_pcm_hw_gc_, TYPE) (HW **hwp) #ifdef DAC audio_detach_capture (hw); #endif - LIST_REMOVE (hw, entries); + QLIST_REMOVE (hw, entries); glue (s->nb_hw_voices_, TYPE) += 1; glue (audio_pcm_hw_free_resources_ ,TYPE) (hw); glue (hw->pcm_ops->fini_, TYPE) (hw); @@ -267,9 +267,9 @@ static HW *glue (audio_pcm_hw_add_new_, TYPE) (struct audsettings *as) } hw->pcm_ops = drv->pcm_ops; - LIST_INIT (&hw->sw_head); + QLIST_INIT (&hw->sw_head); #ifdef DAC - LIST_INIT (&hw->cap_head); + QLIST_INIT (&hw->cap_head); #endif if (glue (hw->pcm_ops->init_, TYPE) (hw, as)) { goto err0; @@ -294,7 +294,7 @@ static HW *glue (audio_pcm_hw_add_new_, TYPE) (struct audsettings *as) goto err1; } - LIST_INSERT_HEAD (&s->glue (hw_head_, TYPE), hw, entries); + QLIST_INSERT_HEAD (&s->glue (hw_head_, TYPE), hw, entries); glue (s->nb_hw_voices_, TYPE) -= 1; #ifdef DAC audio_attach_capture (hw); @@ -22,11 +22,6 @@ * THE SOFTWARE. */ #include "config-host.h" -#ifdef CONFIG_BSD -/* include native header before sys-queue.h */ -#include <sys/queue.h> -#endif - #include "qemu-common.h" #include "monitor.h" #include "block_int.h" @@ -36,6 +31,7 @@ #include <sys/types.h> #include <sys/stat.h> #include <sys/ioctl.h> +#include <sys/queue.h> #ifndef __DragonFly__ #include <sys/disk.h> #endif diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index d4631c3974..54e505cbed 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -738,7 +738,7 @@ uint64_t qcow2_alloc_cluster_offset(BlockDriverState *bs, * the same cluster. In this case we need to wait until the previous * request has completed and updated the L2 table accordingly. */ - LIST_FOREACH(old_alloc, &s->cluster_allocs, next_in_flight) { + QLIST_FOREACH(old_alloc, &s->cluster_allocs, next_in_flight) { uint64_t end_offset = offset + nb_clusters * s->cluster_size; uint64_t old_offset = old_alloc->offset; @@ -769,7 +769,7 @@ uint64_t qcow2_alloc_cluster_offset(BlockDriverState *bs, abort(); } - LIST_INSERT_HEAD(&s->cluster_allocs, m, next_in_flight); + QLIST_INSERT_HEAD(&s->cluster_allocs, m, next_in_flight); /* allocate a new cluster */ diff --git a/block/qcow2.c b/block/qcow2.c index 8579e01508..a9e768268a 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -219,7 +219,7 @@ static int qcow_open(BlockDriverState *bs, const char *filename, int flags) if (qcow2_refcount_init(bs) < 0) goto fail; - LIST_INIT(&s->cluster_allocs); + QLIST_INIT(&s->cluster_allocs); /* read qcow2 extensions */ if (header.backing_file_offset) @@ -340,7 +340,7 @@ typedef struct QCowAIOCB { QEMUIOVector hd_qiov; QEMUBH *bh; QCowL2Meta l2meta; - LIST_ENTRY(QCowAIOCB) next_depend; + QLIST_ENTRY(QCowAIOCB) next_depend; } QCowAIOCB; static void qcow_aio_cancel(BlockDriverAIOCB *blockacb) @@ -503,7 +503,7 @@ static QCowAIOCB *qcow_aio_setup(BlockDriverState *bs, acb->n = 0; acb->cluster_offset = 0; acb->l2meta.nb_clusters = 0; - LIST_INIT(&acb->l2meta.dependent_requests); + QLIST_INIT(&acb->l2meta.dependent_requests); return acb; } @@ -530,12 +530,12 @@ static void run_dependent_requests(QCowL2Meta *m) /* Take the request off the list of running requests */ if (m->nb_clusters != 0) { - LIST_REMOVE(m, next_in_flight); + QLIST_REMOVE(m, next_in_flight); } /* * Restart all dependent requests. - * Can't use LIST_FOREACH here - the next link might not be the same + * Can't use QLIST_FOREACH here - the next link might not be the same * any more after the callback (request could depend on a different * request now) */ @@ -545,7 +545,7 @@ static void run_dependent_requests(QCowL2Meta *m) } /* Empty the list for the next part of the request */ - LIST_INIT(&m->dependent_requests); + QLIST_INIT(&m->dependent_requests); } static void qcow_aio_write_cb(void *opaque, int ret) @@ -590,7 +590,7 @@ static void qcow_aio_write_cb(void *opaque, int ret) /* Need to wait for another request? If so, we are done for now. */ if (!acb->cluster_offset && acb->l2meta.depends_on != NULL) { - LIST_INSERT_HEAD(&acb->l2meta.depends_on->dependent_requests, + QLIST_INSERT_HEAD(&acb->l2meta.depends_on->dependent_requests, acb, next_depend); return; } @@ -690,7 +690,7 @@ static int preallocate(BlockDriverState *bs) nb_sectors = bdrv_getlength(bs) >> 9; offset = 0; - LIST_INIT(&meta.dependent_requests); + QLIST_INIT(&meta.dependent_requests); while (nb_sectors) { num = MIN(nb_sectors, INT_MAX >> 9); diff --git a/block/qcow2.h b/block/qcow2.h index 965a2f45c1..ecc94cbfad 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -98,7 +98,7 @@ typedef struct BDRVQcowState { uint8_t *cluster_cache; uint8_t *cluster_data; uint64_t cluster_cache_offset; - LIST_HEAD(QCowClusterAlloc, QCowL2Meta) cluster_allocs; + QLIST_HEAD(QCowClusterAlloc, QCowL2Meta) cluster_allocs; uint64_t *refcount_table; uint64_t refcount_table_offset; @@ -139,9 +139,9 @@ typedef struct QCowL2Meta int nb_available; int nb_clusters; struct QCowL2Meta *depends_on; - LIST_HEAD(QCowAioDependencies, QCowAIOCB) dependent_requests; + QLIST_HEAD(QCowAioDependencies, QCowAIOCB) dependent_requests; - LIST_ENTRY(QCowL2Meta) next_in_flight; + QLIST_ENTRY(QCowL2Meta) next_in_flight; } QCowL2Meta; static inline int size_to_clusters(BDRVQcowState *s, int64_t size) diff --git a/check-qdict.c b/check-qdict.c index 19989d65a7..c37d448227 100644 --- a/check-qdict.c +++ b/check-qdict.c @@ -47,7 +47,7 @@ START_TEST(qdict_put_obj_test) qdict_put_obj(qdict, "", QOBJECT(qint_from_int(num))); fail_unless(qdict_size(qdict) == 1); - ent = LIST_FIRST(&qdict->table[12345 % QDICT_HASH_SIZE]); + ent = QLIST_FIRST(&qdict->table[12345 % QDICT_HASH_SIZE]); qi = qobject_to_qint(ent->value); fail_unless(qint_get_int(qi) == num); diff --git a/cpu-defs.h b/cpu-defs.h index b6c8b955c1..95068b5304 100644 --- a/cpu-defs.h +++ b/cpu-defs.h @@ -28,7 +28,7 @@ #include <inttypes.h> #include <signal.h> #include "osdep.h" -#include "sys-queue.h" +#include "qemu-queue.h" #include "targphys.h" #ifndef TARGET_LONG_BITS @@ -124,14 +124,14 @@ struct KVMState; typedef struct CPUBreakpoint { target_ulong pc; int flags; /* BP_* */ - TAILQ_ENTRY(CPUBreakpoint) entry; + QTAILQ_ENTRY(CPUBreakpoint) entry; } CPUBreakpoint; typedef struct CPUWatchpoint { target_ulong vaddr; target_ulong len_mask; int flags; /* BP_* */ - TAILQ_ENTRY(CPUWatchpoint) entry; + QTAILQ_ENTRY(CPUWatchpoint) entry; } CPUWatchpoint; #define CPU_TEMP_BUF_NLONGS 128 @@ -169,10 +169,10 @@ typedef struct CPUWatchpoint { \ /* from this point: preserved by CPU reset */ \ /* ice debug support */ \ - TAILQ_HEAD(breakpoints_head, CPUBreakpoint) breakpoints; \ + QTAILQ_HEAD(breakpoints_head, CPUBreakpoint) breakpoints; \ int singlestep_enabled; \ \ - TAILQ_HEAD(watchpoints_head, CPUWatchpoint) watchpoints; \ + QTAILQ_HEAD(watchpoints_head, CPUWatchpoint) watchpoints; \ CPUWatchpoint *watchpoint_hit; \ \ struct GDBRegisterState *gdb_regs; \ diff --git a/cpu-exec.c b/cpu-exec.c index bf20ada1a0..8aa92c7854 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -202,7 +202,7 @@ static void cpu_handle_debug_exception(CPUState *env) CPUWatchpoint *wp; if (!env->watchpoint_hit) - TAILQ_FOREACH(wp, &env->watchpoints, entry) + QTAILQ_FOREACH(wp, &env->watchpoints, entry) wp->flags &= ~BP_WATCHPOINT_HIT; if (debug_excp_handler) @@ -1,20 +1,19 @@ -#include <sys/queue.h> - #include <assert.h> #include <errno.h> #include <stdlib.h> #include <string.h> #include <unistd.h> +#include "qemu-queue.h" #include "envlist.h" struct envlist_entry { const char *ev_var; /* actual env value */ - LIST_ENTRY(envlist_entry) ev_link; + QLIST_ENTRY(envlist_entry) ev_link; }; struct envlist { - LIST_HEAD(, envlist_entry) el_entries; /* actual entries */ + QLIST_HEAD(, envlist_entry) el_entries; /* actual entries */ size_t el_count; /* number of entries */ }; @@ -33,7 +32,7 @@ envlist_create(void) if ((envlist = malloc(sizeof (*envlist))) == NULL) return (NULL); - LIST_INIT(&envlist->el_entries); + QLIST_INIT(&envlist->el_entries); envlist->el_count = 0; return (envlist); @@ -51,7 +50,7 @@ envlist_free(envlist_t *envlist) while (envlist->el_entries.lh_first != NULL) { entry = envlist->el_entries.lh_first; - LIST_REMOVE(entry, ev_link); + QLIST_REMOVE(entry, ev_link); free((char *)entry->ev_var); free(entry); @@ -159,7 +158,7 @@ envlist_setenv(envlist_t *envlist, const char *env) } if (entry != NULL) { - LIST_REMOVE(entry, ev_link); + QLIST_REMOVE(entry, ev_link); free((char *)entry->ev_var); free(entry); } else { @@ -172,7 +171,7 @@ envlist_setenv(envlist_t *envlist, const char *env) free(entry); return (errno); } - LIST_INSERT_HEAD(&envlist->el_entries, entry, ev_link); + QLIST_INSERT_HEAD(&envlist->el_entries, entry, ev_link); return (0); } @@ -205,7 +204,7 @@ envlist_unsetenv(envlist_t *envlist, const char *env) break; } if (entry != NULL) { - LIST_REMOVE(entry, ev_link); + QLIST_REMOVE(entry, ev_link); free((char *)entry->ev_var); free(entry); @@ -586,8 +586,8 @@ void cpu_exec_init(CPUState *env) } env->cpu_index = cpu_index; env->numa_node = 0; - TAILQ_INIT(&env->breakpoints); - TAILQ_INIT(&env->watchpoints); + QTAILQ_INIT(&env->breakpoints); + QTAILQ_INIT(&env->watchpoints); *penv = env; #if defined(CONFIG_USER_ONLY) cpu_list_unlock(); @@ -1348,9 +1348,9 @@ int cpu_watchpoint_insert(CPUState *env, target_ulong addr, target_ulong len, /* keep all GDB-injected watchpoints in front */ if (flags & BP_GDB) - TAILQ_INSERT_HEAD(&env->watchpoints, wp, entry); + QTAILQ_INSERT_HEAD(&env->watchpoints, wp, entry); else - TAILQ_INSERT_TAIL(&env->watchpoints, wp, entry); + QTAILQ_INSERT_TAIL(&env->watchpoints, wp, entry); tlb_flush_page(env, addr); @@ -1366,7 +1366,7 @@ int cpu_watchpoint_remove(CPUState *env, target_ulong addr, target_ulong len, target_ulong len_mask = ~(len - 1); CPUWatchpoint *wp; - TAILQ_FOREACH(wp, &env->watchpoints, entry) { + QTAILQ_FOREACH(wp, &env->watchpoints, entry) { if (addr == wp->vaddr && len_mask == wp->len_mask && flags == (wp->flags & ~BP_WATCHPOINT_HIT)) { cpu_watchpoint_remove_by_ref(env, wp); @@ -1379,7 +1379,7 @@ int cpu_watchpoint_remove(CPUState *env, target_ulong addr, target_ulong len, /* Remove a specific watchpoint by reference. */ void cpu_watchpoint_remove_by_ref(CPUState *env, CPUWatchpoint *watchpoint) { - TAILQ_REMOVE(&env->watchpoints, watchpoint, entry); + QTAILQ_REMOVE(&env->watchpoints, watchpoint, entry); tlb_flush_page(env, watchpoint->vaddr); @@ -1391,7 +1391,7 @@ void cpu_watchpoint_remove_all(CPUState *env, int mask) { CPUWatchpoint *wp, *next; - TAILQ_FOREACH_SAFE(wp, &env->watchpoints, entry, next) { + QTAILQ_FOREACH_SAFE(wp, &env->watchpoints, entry, next) { if (wp->flags & mask) cpu_watchpoint_remove_by_ref(env, wp); } @@ -1411,9 +1411,9 @@ int cpu_breakpoint_insert(CPUState *env, target_ulong pc, int flags, /* keep all GDB-injected breakpoints in front */ if (flags & BP_GDB) - TAILQ_INSERT_HEAD(&env->breakpoints, bp, entry); + QTAILQ_INSERT_HEAD(&env->breakpoints, bp, entry); else - TAILQ_INSERT_TAIL(&env->breakpoints, bp, entry); + QTAILQ_INSERT_TAIL(&env->breakpoints, bp, entry); breakpoint_invalidate(env, pc); @@ -1431,7 +1431,7 @@ int cpu_breakpoint_remove(CPUState *env, target_ulong pc, int flags) #if defined(TARGET_HAS_ICE) CPUBreakpoint *bp; - TAILQ_FOREACH(bp, &env->breakpoints, entry) { + QTAILQ_FOREACH(bp, &env->breakpoints, entry) { if (bp->pc == pc && bp->flags == flags) { cpu_breakpoint_remove_by_ref(env, bp); return 0; @@ -1447,7 +1447,7 @@ int cpu_breakpoint_remove(CPUState *env, target_ulong pc, int flags) void cpu_breakpoint_remove_by_ref(CPUState *env, CPUBreakpoint *breakpoint) { #if defined(TARGET_HAS_ICE) - TAILQ_REMOVE(&env->breakpoints, breakpoint, entry); + QTAILQ_REMOVE(&env->breakpoints, breakpoint, entry); breakpoint_invalidate(env, breakpoint->pc); @@ -1461,7 +1461,7 @@ void cpu_breakpoint_remove_all(CPUState *env, int mask) #if defined(TARGET_HAS_ICE) CPUBreakpoint *bp, *next; - TAILQ_FOREACH_SAFE(bp, &env->breakpoints, entry, next) { + QTAILQ_FOREACH_SAFE(bp, &env->breakpoints, entry, next) { if (bp->flags & mask) cpu_breakpoint_remove_by_ref(env, bp); } @@ -1712,13 +1712,13 @@ CPUState *cpu_copy(CPUState *env) /* Clone all break/watchpoints. Note: Once we support ptrace with hw-debug register access, make sure BP_CPU break/watchpoints are handled correctly on clone. */ - TAILQ_INIT(&env->breakpoints); - TAILQ_INIT(&env->watchpoints); + QTAILQ_INIT(&env->breakpoints); + QTAILQ_INIT(&env->watchpoints); #if defined(TARGET_HAS_ICE) - TAILQ_FOREACH(bp, &env->breakpoints, entry) { + QTAILQ_FOREACH(bp, &env->breakpoints, entry) { cpu_breakpoint_insert(new_env, bp->pc, bp->flags, NULL); } - TAILQ_FOREACH(wp, &env->watchpoints, entry) { + QTAILQ_FOREACH(wp, &env->watchpoints, entry) { cpu_watchpoint_insert(new_env, wp->vaddr, (~wp->len_mask) + 1, wp->flags, NULL); } @@ -2009,7 +2009,7 @@ int tlb_set_page_exec(CPUState *env, target_ulong vaddr, code_address = address; /* Make accesses to pages with watchpoints go via the watchpoint trap routines. */ - TAILQ_FOREACH(wp, &env->watchpoints, entry) { + QTAILQ_FOREACH(wp, &env->watchpoints, entry) { if (vaddr == (wp->vaddr & TARGET_PAGE_MASK)) { iotlb = io_mem_watch + paddr; /* TODO: The memory case can be optimized by not trapping @@ -2663,7 +2663,7 @@ static void check_watchpoint(int offset, int len_mask, int flags) return; } vaddr = (env->mem_io_vaddr & TARGET_PAGE_MASK) + offset; - TAILQ_FOREACH(wp, &env->watchpoints, entry) { + QTAILQ_FOREACH(wp, &env->watchpoints, entry) { if ((vaddr == (wp->vaddr & len_mask) || (vaddr & wp->len_mask) == wp->vaddr) && (wp->flags & flags)) { wp->flags |= BP_WATCHPOINT_HIT; @@ -3169,11 +3169,11 @@ static BounceBuffer bounce; typedef struct MapClient { void *opaque; void (*callback)(void *opaque); - LIST_ENTRY(MapClient) link; + QLIST_ENTRY(MapClient) link; } MapClient; -static LIST_HEAD(map_client_list, MapClient) map_client_list - = LIST_HEAD_INITIALIZER(map_client_list); +static QLIST_HEAD(map_client_list, MapClient) map_client_list + = QLIST_HEAD_INITIALIZER(map_client_list); void *cpu_register_map_client(void *opaque, void (*callback)(void *opaque)) { @@ -3181,7 +3181,7 @@ void *cpu_register_map_client(void *opaque, void (*callback)(void *opaque)) client->opaque = opaque; client->callback = callback; - LIST_INSERT_HEAD(&map_client_list, client, link); + QLIST_INSERT_HEAD(&map_client_list, client, link); return client; } @@ -3189,7 +3189,7 @@ void cpu_unregister_map_client(void *_client) { MapClient *client = (MapClient *)_client; - LIST_REMOVE(client, link); + QLIST_REMOVE(client, link); qemu_free(client); } @@ -3197,8 +3197,8 @@ static void cpu_notify_map_clients(void) { MapClient *client; - while (!LIST_EMPTY(&map_client_list)) { - client = LIST_FIRST(&map_client_list); + while (!QLIST_EMPTY(&map_client_list)) { + client = QLIST_FIRST(&map_client_list); client->callback(client->opaque); cpu_unregister_map_client(client); } diff --git a/hw/device-hotplug.c b/hw/device-hotplug.c index fd4cc3fb54..69779caef5 100644 --- a/hw/device-hotplug.c +++ b/hw/device-hotplug.c @@ -68,7 +68,7 @@ void destroy_bdrvs(dev_match_fn *match_fn, void *arg) DriveInfo *dinfo; struct BlockDriverState *bs; - TAILQ_FOREACH(dinfo, &drives, next) { + QTAILQ_FOREACH(dinfo, &drives, next) { bs = dinfo->bdrv; if (bs) { if (bs->private && match_fn(bs->private, arg)) { @@ -76,7 +76,7 @@ int i2c_start_transfer(i2c_bus *bus, int address, int recv) DeviceState *qdev; i2c_slave *slave = NULL; - LIST_FOREACH(qdev, &bus->qbus.children, sibling) { + QLIST_FOREACH(qdev, &bus->qbus.children, sibling) { slave = I2C_SLAVE_FROM_QDEV(qdev); if (slave->address == address) break; diff --git a/hw/pci-hotplug.c b/hw/pci-hotplug.c index 5348dd1b2e..f3dc42103d 100644 --- a/hw/pci-hotplug.c +++ b/hw/pci-hotplug.c @@ -84,7 +84,7 @@ void drive_hot_add(Monitor *mon, const QDict *qdict) switch (type) { case IF_SCSI: success = 1; - scsibus = LIST_FIRST(&dev->qdev.child_bus); + scsibus = QLIST_FIRST(&dev->qdev.child_bus); scsi_bus_legacy_add_drive(DO_UPCAST(SCSIBus, qbus, scsibus), dinfo, dinfo->unit); break; @@ -101,7 +101,7 @@ DeviceState *qdev_create(BusState *bus, const char *name) qdev_prop_set_defaults(dev, dev->info->props); qdev_prop_set_defaults(dev, dev->parent_bus->info->props); qdev_prop_set_compat(dev); - LIST_INSERT_HEAD(&bus->children, dev, sibling); + QLIST_INSERT_HEAD(&bus->children, dev, sibling); return dev; } @@ -235,7 +235,7 @@ void qdev_free(DeviceState *dev) #endif if (dev->info->reset) qemu_unregister_reset(dev->info->reset, dev); - LIST_REMOVE(dev, sibling); + QLIST_REMOVE(dev, sibling); qemu_free(dev); } @@ -321,7 +321,7 @@ BusState *qdev_get_child_bus(DeviceState *dev, const char *name) { BusState *bus; - LIST_FOREACH(bus, &dev->child_bus, sibling) { + QLIST_FOREACH(bus, &dev->child_bus, sibling) { if (strcmp(name, bus->name) == 0) { return bus; } @@ -346,8 +346,8 @@ static BusState *qbus_find_recursive(BusState *bus, const char *name, return bus; } - LIST_FOREACH(dev, &bus->children, sibling) { - LIST_FOREACH(child, &dev->child_bus, sibling) { + QLIST_FOREACH(dev, &bus->children, sibling) { + QLIST_FOREACH(child, &dev->child_bus, sibling) { ret = qbus_find_recursive(child, name, info); if (ret) { return ret; @@ -365,7 +365,7 @@ static void qbus_list_bus(DeviceState *dev, char *dest, int len) pos += snprintf(dest+pos, len-pos,"child busses at \"%s\":", dev->id ? dev->id : dev->info->name); - LIST_FOREACH(child, &dev->child_bus, sibling) { + QLIST_FOREACH(child, &dev->child_bus, sibling) { pos += snprintf(dest+pos, len-pos, "%s\"%s\"", sep, child->name); sep = ", "; } @@ -379,7 +379,7 @@ static void qbus_list_dev(BusState *bus, char *dest, int len) pos += snprintf(dest+pos, len-pos, "devices at \"%s\":", bus->name); - LIST_FOREACH(dev, &bus->children, sibling) { + QLIST_FOREACH(dev, &bus->children, sibling) { pos += snprintf(dest+pos, len-pos, "%s\"%s\"", sep, dev->info->name); if (dev->id) @@ -392,7 +392,7 @@ static BusState *qbus_find_bus(DeviceState *dev, char *elem) { BusState *child; - LIST_FOREACH(child, &dev->child_bus, sibling) { + QLIST_FOREACH(child, &dev->child_bus, sibling) { if (strcmp(child->name, elem) == 0) { return child; } @@ -410,17 +410,17 @@ static DeviceState *qbus_find_dev(BusState *bus, char *elem) * (2) driver name * (3) driver alias, if present */ - LIST_FOREACH(dev, &bus->children, sibling) { + QLIST_FOREACH(dev, &bus->children, sibling) { if (dev->id && strcmp(dev->id, elem) == 0) { return dev; } } - LIST_FOREACH(dev, &bus->children, sibling) { + QLIST_FOREACH(dev, &bus->children, sibling) { if (strcmp(dev->info->name, elem) == 0) { return dev; } } - LIST_FOREACH(dev, &bus->children, sibling) { + QLIST_FOREACH(dev, &bus->children, sibling) { if (dev->info->alias && strcmp(dev->info->alias, elem) == 0) { return dev; } @@ -478,7 +478,7 @@ static BusState *qbus_find(const char *path) qemu_error("device has no child bus (%s)\n", path); return NULL; case 1: - return LIST_FIRST(&dev->child_bus); + return QLIST_FIRST(&dev->child_bus); default: qbus_list_bus(dev, msg, sizeof(msg)); qemu_error("device has multiple child busses (%s)\n%s\n", @@ -532,9 +532,9 @@ BusState *qbus_create(BusInfo *info, DeviceState *parent, const char *name) bus->name = buf; } - LIST_INIT(&bus->children); + QLIST_INIT(&bus->children); if (parent) { - LIST_INSERT_HEAD(&parent->child_bus, bus, sibling); + QLIST_INSERT_HEAD(&parent->child_bus, bus, sibling); parent->num_child_bus++; } return bus; @@ -575,7 +575,7 @@ static void qdev_print(Monitor *mon, DeviceState *dev, int indent) qdev_print_props(mon, dev, dev->parent_bus->info->props, "bus", indent); if (dev->parent_bus->info->print_dev) dev->parent_bus->info->print_dev(mon, dev, indent); - LIST_FOREACH(child, &dev->child_bus, sibling) { + QLIST_FOREACH(child, &dev->child_bus, sibling) { qbus_print(mon, child, indent); } } @@ -587,7 +587,7 @@ static void qbus_print(Monitor *mon, BusState *bus, int indent) qdev_printf("bus: %s\n", bus->name); indent += 2; qdev_printf("type %s\n", bus->info->name); - LIST_FOREACH(dev, &bus->children, sibling) { + QLIST_FOREACH(dev, &bus->children, sibling) { qdev_print(mon, dev, indent); } } @@ -3,7 +3,7 @@ #include "hw.h" #include "sysemu.h" -#include "sys-queue.h" +#include "qemu-queue.h" #include "qemu-char.h" #include "qemu-option.h" @@ -29,10 +29,10 @@ struct DeviceState { qemu_irq *gpio_out; int num_gpio_in; qemu_irq *gpio_in; - LIST_HEAD(, BusState) child_bus; + QLIST_HEAD(, BusState) child_bus; int num_child_bus; NICInfo *nd; - LIST_ENTRY(DeviceState) sibling; + QLIST_ENTRY(DeviceState) sibling; }; typedef void (*bus_dev_printfn)(Monitor *mon, DeviceState *dev, int indent); @@ -47,8 +47,8 @@ struct BusState { DeviceState *parent; BusInfo *info; const char *name; - LIST_HEAD(, DeviceState) children; - LIST_ENTRY(BusState) sibling; + QLIST_HEAD(, DeviceState) children; + QLIST_ENTRY(BusState) sibling; }; struct Property { @@ -25,8 +25,8 @@ static int ssi_slave_init(DeviceState *dev, DeviceInfo *base_info) SSIBus *bus; bus = FROM_QBUS(SSIBus, qdev_get_parent_bus(dev)); - if (LIST_FIRST(&bus->qbus.children) != dev - || LIST_NEXT(dev, sibling) != NULL) { + if (QLIST_FIRST(&bus->qbus.children) != dev + || QLIST_NEXT(dev, sibling) != NULL) { hw_error("Too many devices on SSI bus"); } @@ -61,7 +61,7 @@ uint32_t ssi_transfer(SSIBus *bus, uint32_t val) { DeviceState *dev; SSISlave *slave; - dev = LIST_FIRST(&bus->qbus.children); + dev = QLIST_FIRST(&bus->qbus.children); if (!dev) { return 0; } diff --git a/hw/usb-bus.c b/hw/usb-bus.c index 169fb2f58d..03933f12f1 100644 --- a/hw/usb-bus.c +++ b/hw/usb-bus.c @@ -12,7 +12,7 @@ static struct BusInfo usb_bus_info = { .print_dev = usb_bus_dev_print, }; static int next_usb_bus = 0; -static TAILQ_HEAD(, USBBus) busses = TAILQ_HEAD_INITIALIZER(busses); +static QTAILQ_HEAD(, USBBus) busses = QTAILQ_HEAD_INITIALIZER(busses); USBBus *usb_bus_new(DeviceState *host) { @@ -20,9 +20,9 @@ USBBus *usb_bus_new(DeviceState *host) bus = FROM_QBUS(USBBus, qbus_create(&usb_bus_info, host, NULL)); bus->busnr = next_usb_bus++; - TAILQ_INIT(&bus->free); - TAILQ_INIT(&bus->used); - TAILQ_INSERT_TAIL(&busses, bus, next); + QTAILQ_INIT(&bus->free); + QTAILQ_INIT(&bus->used); + QTAILQ_INSERT_TAIL(&busses, bus, next); return bus; } @@ -31,8 +31,8 @@ USBBus *usb_bus_find(int busnr) USBBus *bus; if (-1 == busnr) - return TAILQ_FIRST(&busses); - TAILQ_FOREACH(bus, &busses, next) { + return QTAILQ_FIRST(&busses); + QTAILQ_FOREACH(bus, &busses, next) { if (bus->busnr == busnr) return bus; } @@ -100,7 +100,7 @@ void usb_register_port(USBBus *bus, USBPort *port, void *opaque, int index, port->opaque = opaque; port->index = index; port->attach = attach; - TAILQ_INSERT_TAIL(&bus->free, port, next); + QTAILQ_INSERT_TAIL(&bus->free, port, next); bus->nfree++; } @@ -116,13 +116,13 @@ static void do_attach(USBDevice *dev) } dev->attached++; - port = TAILQ_FIRST(&bus->free); - TAILQ_REMOVE(&bus->free, port, next); + port = QTAILQ_FIRST(&bus->free); + QTAILQ_REMOVE(&bus->free, port, next); bus->nfree--; usb_attach(port, dev); - TAILQ_INSERT_TAIL(&bus->used, port, next); + QTAILQ_INSERT_TAIL(&bus->used, port, next); bus->nused++; } @@ -149,7 +149,7 @@ int usb_device_delete_addr(int busnr, int addr) if (!bus) return -1; - TAILQ_FOREACH(port, &bus->used, next) { + QTAILQ_FOREACH(port, &bus->used, next) { if (port->dev->addr == addr) break; } @@ -157,13 +157,13 @@ int usb_device_delete_addr(int busnr, int addr) return -1; dev = port->dev; - TAILQ_REMOVE(&bus->used, port, next); + QTAILQ_REMOVE(&bus->used, port, next); bus->nused--; usb_attach(port, NULL); dev->info->handle_destroy(dev); - TAILQ_INSERT_TAIL(&bus->free, port, next); + QTAILQ_INSERT_TAIL(&bus->free, port, next); bus->nfree++; return 0; } @@ -196,13 +196,13 @@ void usb_info(Monitor *mon) USBDevice *dev; USBPort *port; - if (TAILQ_EMPTY(&busses)) { + if (QTAILQ_EMPTY(&busses)) { monitor_printf(mon, "USB support not enabled\n"); return; } - TAILQ_FOREACH(bus, &busses, next) { - TAILQ_FOREACH(port, &bus->used, next) { + QTAILQ_FOREACH(bus, &busses, next) { + QTAILQ_FOREACH(port, &bus->used, next) { dev = port->dev; if (!dev) continue; diff --git a/hw/usb-net.c b/hw/usb-net.c index f19309ee13..b33e32927c 100644 --- a/hw/usb-net.c +++ b/hw/usb-net.c @@ -26,7 +26,7 @@ #include "qemu-common.h" #include "usb.h" #include "net.h" -#include "sys-queue.h" +#include "qemu-queue.h" /*#define TRAFFIC_DEBUG*/ /* Thanks to NetChip Technologies for donating this product ID. @@ -595,7 +595,7 @@ static const uint32_t oid_supported_list[] = #define NDIS_MAC_OPTION_8021P_PRIORITY (1 << 6) struct rndis_response { - TAILQ_ENTRY(rndis_response) entries; + QTAILQ_ENTRY(rndis_response) entries; uint32_t length; uint8_t buf[0]; }; @@ -621,7 +621,7 @@ typedef struct USBNetState { char usbstring_mac[13]; VLANClientState *vc; - TAILQ_HEAD(rndis_resp_head, rndis_response) rndis_resp; + QTAILQ_HEAD(rndis_resp_head, rndis_response) rndis_resp; } USBNetState; static int ndis_query(USBNetState *s, uint32_t oid, @@ -812,7 +812,7 @@ static int rndis_get_response(USBNetState *s, uint8_t *buf) if (!r) return ret; - TAILQ_REMOVE(&s->rndis_resp, r, entries); + QTAILQ_REMOVE(&s->rndis_resp, r, entries); ret = r->length; memcpy(buf, r->buf, r->length); qemu_free(r); @@ -825,7 +825,7 @@ static void *rndis_queue_response(USBNetState *s, unsigned int length) struct rndis_response *r = qemu_mallocz(sizeof(struct rndis_response) + length); - TAILQ_INSERT_TAIL(&s->rndis_resp, r, entries); + QTAILQ_INSERT_TAIL(&s->rndis_resp, r, entries); r->length = length; return &r->buf[0]; @@ -836,7 +836,7 @@ static void rndis_clear_responsequeue(USBNetState *s) struct rndis_response *r; while ((r = s->rndis_resp.tqh_first)) { - TAILQ_REMOVE(&s->rndis_resp, r, entries); + QTAILQ_REMOVE(&s->rndis_resp, r, entries); qemu_free(r); } } @@ -1440,7 +1440,7 @@ static int usb_net_initfn(USBDevice *dev) s->rndis = 1; s->rndis_state = RNDIS_UNINITIALIZED; - TAILQ_INIT(&s->rndis_resp); + QTAILQ_INIT(&s->rndis_resp); s->medium = 0; /* NDIS_MEDIUM_802_3 */ s->speed = 1000000; /* 100MBps, in 100Bps units */ @@ -24,7 +24,7 @@ #include "block.h" #include "qdev.h" -#include "sys-queue.h" +#include "qemu-queue.h" #define USB_TOKEN_SETUP 0x2d #define USB_TOKEN_IN 0x69 /* device -> host */ @@ -193,7 +193,7 @@ struct USBPort { usb_attachfn attach; void *opaque; int index; /* internal port index, may be used with the opaque */ - TAILQ_ENTRY(USBPort) next; + QTAILQ_ENTRY(USBPort) next; }; typedef void USBCallback(USBPacket * packet, void *opaque); @@ -298,9 +298,9 @@ struct USBBus { int busnr; int nfree; int nused; - TAILQ_HEAD(, USBPort) free; - TAILQ_HEAD(, USBPort) used; - TAILQ_ENTRY(USBBus) next; + QTAILQ_HEAD(, USBPort) free; + QTAILQ_HEAD(, USBPort) used; + QTAILQ_ENTRY(USBBus) next; }; USBBus *usb_bus_new(DeviceState *host); diff --git a/hw/watchdog.c b/hw/watchdog.c index adba872533..6a3d1b4320 100644 --- a/hw/watchdog.c +++ b/hw/watchdog.c @@ -22,7 +22,7 @@ #include "qemu-common.h" #include "qemu-option.h" #include "qemu-config.h" -#include "sys-queue.h" +#include "qemu-queue.h" #include "sysemu.h" #include "hw/watchdog.h" @@ -35,11 +35,11 @@ #define WDT_NONE 6 /* Do nothing. */ static int watchdog_action = WDT_RESET; -static LIST_HEAD(watchdog_list, WatchdogTimerModel) watchdog_list; +static QLIST_HEAD(watchdog_list, WatchdogTimerModel) watchdog_list; void watchdog_add_model(WatchdogTimerModel *model) { - LIST_INSERT_HEAD(&watchdog_list, model, entry); + QLIST_INSERT_HEAD(&watchdog_list, model, entry); } /* Returns: @@ -54,14 +54,14 @@ int select_watchdog(const char *p) /* -watchdog ? lists available devices and exits cleanly. */ if (strcmp(p, "?") == 0) { - LIST_FOREACH(model, &watchdog_list, entry) { + QLIST_FOREACH(model, &watchdog_list, entry) { fprintf(stderr, "\t%s\t%s\n", model->wdt_name, model->wdt_description); } return 2; } - LIST_FOREACH(model, &watchdog_list, entry) { + QLIST_FOREACH(model, &watchdog_list, entry) { if (strcasecmp(model->wdt_name, p) == 0) { /* add the device */ opts = qemu_opts_create(&qemu_device_opts, NULL, 0); @@ -71,7 +71,7 @@ int select_watchdog(const char *p) } fprintf(stderr, "Unknown -watchdog device. Supported devices are:\n"); - LIST_FOREACH(model, &watchdog_list, entry) { + QLIST_FOREACH(model, &watchdog_list, entry) { fprintf(stderr, "\t%s\t%s\n", model->wdt_name, model->wdt_description); } diff --git a/hw/watchdog.h b/hw/watchdog.h index 8c54fa41fd..330062c85f 100644 --- a/hw/watchdog.h +++ b/hw/watchdog.h @@ -23,7 +23,7 @@ #define QEMU_WATCHDOG_H struct WatchdogTimerModel { - LIST_ENTRY(WatchdogTimerModel) entry; + QLIST_ENTRY(WatchdogTimerModel) entry; /* Short name of the device - used to select it on the command line. */ const char *wdt_name; diff --git a/hw/xen_backend.c b/hw/xen_backend.c index efafd2fa52..658ea8d1d3 100644 --- a/hw/xen_backend.c +++ b/hw/xen_backend.c @@ -48,7 +48,7 @@ struct xs_handle *xenstore = NULL; const char *xen_protocol; /* private */ -static TAILQ_HEAD(XenDeviceHead, XenDevice) xendevs = TAILQ_HEAD_INITIALIZER(xendevs); +static QTAILQ_HEAD(XenDeviceHead, XenDevice) xendevs = QTAILQ_HEAD_INITIALIZER(xendevs); static int debug = 0; /* ------------------------------------------------------------- */ @@ -165,7 +165,7 @@ struct XenDevice *xen_be_find_xendev(const char *type, int dom, int dev) { struct XenDevice *xendev; - TAILQ_FOREACH(xendev, &xendevs, next) { + QTAILQ_FOREACH(xendev, &xendevs, next) { if (xendev->dom != dom) continue; if (xendev->dev != dev) @@ -227,7 +227,7 @@ static struct XenDevice *xen_be_get_xendev(const char *type, int dom, int dev, xendev->gnttabdev = -1; } - TAILQ_INSERT_TAIL(&xendevs, xendev, next); + QTAILQ_INSERT_TAIL(&xendevs, xendev, next); if (xendev->ops->alloc) xendev->ops->alloc(xendev); @@ -243,7 +243,7 @@ static struct XenDevice *xen_be_del_xendev(int dom, int dev) struct XenDevice *xendev, *xnext; /* - * This is pretty much like TAILQ_FOREACH(xendev, &xendevs, next) but + * This is pretty much like QTAILQ_FOREACH(xendev, &xendevs, next) but * we save the next pointer in xnext because we might free xendev. */ xnext = xendevs.tqh_first; @@ -271,7 +271,7 @@ static struct XenDevice *xen_be_del_xendev(int dom, int dev) if (xendev->gnttabdev >= 0) xc_gnttab_close(xendev->gnttabdev); - TAILQ_REMOVE(&xendevs, xendev, next); + QTAILQ_REMOVE(&xendevs, xendev, next); qemu_free(xendev); } return NULL; diff --git a/hw/xen_backend.h b/hw/xen_backend.h index 4dbfdb4a4a..f07f7d4224 100644 --- a/hw/xen_backend.h +++ b/hw/xen_backend.h @@ -50,7 +50,7 @@ struct XenDevice { int gnttabdev; struct XenDevOps *ops; - TAILQ_ENTRY(XenDevice) next; + QTAILQ_ENTRY(XenDevice) next; }; /* ------------------------------------------------------------- */ diff --git a/hw/xen_devconfig.c b/hw/xen_devconfig.c index 4121188a48..ea8f8c4c2d 100644 --- a/hw/xen_devconfig.c +++ b/hw/xen_devconfig.c @@ -4,9 +4,9 @@ struct xs_dirs { char *xs_dir; - TAILQ_ENTRY(xs_dirs) list; + QTAILQ_ENTRY(xs_dirs) list; }; -static TAILQ_HEAD(xs_dirs_head, xs_dirs) xs_cleanup = TAILQ_HEAD_INITIALIZER(xs_cleanup); +static QTAILQ_HEAD(xs_dirs_head, xs_dirs) xs_cleanup = QTAILQ_HEAD_INITIALIZER(xs_cleanup); static void xen_config_cleanup_dir(char *dir) { @@ -14,14 +14,14 @@ static void xen_config_cleanup_dir(char *dir) d = qemu_malloc(sizeof(*d)); d->xs_dir = dir; - TAILQ_INSERT_TAIL(&xs_cleanup, d, list); + QTAILQ_INSERT_TAIL(&xs_cleanup, d, list); } void xen_config_cleanup(void) { struct xs_dirs *d; - TAILQ_FOREACH(d, &xs_cleanup, list) { + QTAILQ_FOREACH(d, &xs_cleanup, list) { xs_rm(xenstore, 0, d->xs_dir); } } diff --git a/hw/xen_disk.c b/hw/xen_disk.c index 100ef8e9bc..74cde80691 100644 --- a/hw/xen_disk.c +++ b/hw/xen_disk.c @@ -77,7 +77,7 @@ struct ioreq { int aio_errors; struct XenBlkDev *blkdev; - LIST_ENTRY(ioreq) list; + QLIST_ENTRY(ioreq) list; }; struct XenBlkDev { @@ -99,9 +99,9 @@ struct XenBlkDev { int cnt_map; /* request lists */ - LIST_HEAD(inflight_head, ioreq) inflight; - LIST_HEAD(finished_head, ioreq) finished; - LIST_HEAD(freelist_head, ioreq) freelist; + QLIST_HEAD(inflight_head, ioreq) inflight; + QLIST_HEAD(finished_head, ioreq) finished; + QLIST_HEAD(freelist_head, ioreq) freelist; int requests_total; int requests_inflight; int requests_finished; @@ -118,7 +118,7 @@ static struct ioreq *ioreq_start(struct XenBlkDev *blkdev) { struct ioreq *ioreq = NULL; - if (LIST_EMPTY(&blkdev->freelist)) { + if (QLIST_EMPTY(&blkdev->freelist)) { if (blkdev->requests_total >= max_requests) goto out; /* allocate new struct */ @@ -128,11 +128,11 @@ static struct ioreq *ioreq_start(struct XenBlkDev *blkdev) qemu_iovec_init(&ioreq->v, BLKIF_MAX_SEGMENTS_PER_REQUEST); } else { /* get one from freelist */ - ioreq = LIST_FIRST(&blkdev->freelist); - LIST_REMOVE(ioreq, list); + ioreq = QLIST_FIRST(&blkdev->freelist); + QLIST_REMOVE(ioreq, list); qemu_iovec_reset(&ioreq->v); } - LIST_INSERT_HEAD(&blkdev->inflight, ioreq, list); + QLIST_INSERT_HEAD(&blkdev->inflight, ioreq, list); blkdev->requests_inflight++; out: @@ -143,8 +143,8 @@ static void ioreq_finish(struct ioreq *ioreq) { struct XenBlkDev *blkdev = ioreq->blkdev; - LIST_REMOVE(ioreq, list); - LIST_INSERT_HEAD(&blkdev->finished, ioreq, list); + QLIST_REMOVE(ioreq, list); + QLIST_INSERT_HEAD(&blkdev->finished, ioreq, list); blkdev->requests_inflight--; blkdev->requests_finished++; } @@ -153,10 +153,10 @@ static void ioreq_release(struct ioreq *ioreq) { struct XenBlkDev *blkdev = ioreq->blkdev; - LIST_REMOVE(ioreq, list); + QLIST_REMOVE(ioreq, list); memset(ioreq, 0, sizeof(*ioreq)); ioreq->blkdev = blkdev; - LIST_INSERT_HEAD(&blkdev->freelist, ioreq, list); + QLIST_INSERT_HEAD(&blkdev->freelist, ioreq, list); blkdev->requests_finished--; } @@ -476,8 +476,8 @@ static void blk_send_response_all(struct XenBlkDev *blkdev) struct ioreq *ioreq; int send_notify = 0; - while (!LIST_EMPTY(&blkdev->finished)) { - ioreq = LIST_FIRST(&blkdev->finished); + while (!QLIST_EMPTY(&blkdev->finished)) { + ioreq = QLIST_FIRST(&blkdev->finished); send_notify += blk_send_response_one(ioreq); ioreq_release(ioreq); } @@ -564,9 +564,9 @@ static void blk_alloc(struct XenDevice *xendev) { struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, xendev); - LIST_INIT(&blkdev->inflight); - LIST_INIT(&blkdev->finished); - LIST_INIT(&blkdev->freelist); + QLIST_INIT(&blkdev->inflight); + QLIST_INIT(&blkdev->finished); + QLIST_INIT(&blkdev->freelist); blkdev->bh = qemu_bh_new(blk_bh, blkdev); if (xen_mode != XEN_EMULATE) batch_maps = 1; @@ -750,9 +750,9 @@ static int blk_free(struct XenDevice *xendev) struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, xendev); struct ioreq *ioreq; - while (!LIST_EMPTY(&blkdev->freelist)) { - ioreq = LIST_FIRST(&blkdev->freelist); - LIST_REMOVE(ioreq, list); + while (!QLIST_EMPTY(&blkdev->freelist)) { + ioreq = QLIST_FIRST(&blkdev->freelist); + QLIST_REMOVE(ioreq, list); qemu_iovec_destroy(&ioreq->v); qemu_free(ioreq); } @@ -428,7 +428,7 @@ int kvm_init(int smp_cpus) s = qemu_mallocz(sizeof(KVMState)); #ifdef KVM_CAP_SET_GUEST_DEBUG - TAILQ_INIT(&s->kvm_sw_breakpoints); + QTAILQ_INIT(&s->kvm_sw_breakpoints); #endif for (i = 0; i < ARRAY_SIZE(s->slots); i++) s->slots[i].slot = i; @@ -917,7 +917,7 @@ struct kvm_sw_breakpoint *kvm_find_sw_breakpoint(CPUState *env, { struct kvm_sw_breakpoint *bp; - TAILQ_FOREACH(bp, &env->kvm_state->kvm_sw_breakpoints, entry) { + QTAILQ_FOREACH(bp, &env->kvm_state->kvm_sw_breakpoints, entry) { if (bp->pc == pc) return bp; } @@ -926,7 +926,7 @@ struct kvm_sw_breakpoint *kvm_find_sw_breakpoint(CPUState *env, int kvm_sw_breakpoints_active(CPUState *env) { - return !TAILQ_EMPTY(&env->kvm_state->kvm_sw_breakpoints); + return !QTAILQ_EMPTY(&env->kvm_state->kvm_sw_breakpoints); } struct kvm_set_guest_debug_data { @@ -983,7 +983,7 @@ int kvm_insert_breakpoint(CPUState *current_env, target_ulong addr, return err; } - TAILQ_INSERT_HEAD(¤t_env->kvm_state->kvm_sw_breakpoints, + QTAILQ_INSERT_HEAD(¤t_env->kvm_state->kvm_sw_breakpoints, bp, entry); } else { err = kvm_arch_insert_hw_breakpoint(addr, len, type); @@ -1020,7 +1020,7 @@ int kvm_remove_breakpoint(CPUState *current_env, target_ulong addr, if (err) return err; - TAILQ_REMOVE(¤t_env->kvm_state->kvm_sw_breakpoints, bp, entry); + QTAILQ_REMOVE(¤t_env->kvm_state->kvm_sw_breakpoints, bp, entry); qemu_free(bp); } else { err = kvm_arch_remove_hw_breakpoint(addr, len, type); @@ -1042,7 +1042,7 @@ void kvm_remove_all_breakpoints(CPUState *current_env) KVMState *s = current_env->kvm_state; CPUState *env; - TAILQ_FOREACH_SAFE(bp, &s->kvm_sw_breakpoints, entry, next) { + QTAILQ_FOREACH_SAFE(bp, &s->kvm_sw_breakpoints, entry, next) { if (kvm_arch_remove_sw_breakpoint(current_env, bp) != 0) { /* Try harder to find a CPU that currently sees the breakpoint. */ for (env = first_cpu; env != NULL; env = env->next_cpu) { @@ -15,7 +15,7 @@ #define QEMU_KVM_H #include "config.h" -#include "sys-queue.h" +#include "qemu-queue.h" #ifdef CONFIG_KVM extern int kvm_allowed; @@ -100,10 +100,10 @@ struct kvm_sw_breakpoint { target_ulong pc; target_ulong saved_insn; int use_count; - TAILQ_ENTRY(kvm_sw_breakpoint) entry; + QTAILQ_ENTRY(kvm_sw_breakpoint) entry; }; -TAILQ_HEAD(kvm_sw_breakpoint_head, kvm_sw_breakpoint); +QTAILQ_HEAD(kvm_sw_breakpoint_head, kvm_sw_breakpoint); int kvm_arch_debug(struct kvm_debug_exit_arch *arch_info); diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 4f04b98287..10d4781da8 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -1844,7 +1844,7 @@ struct target_elf_prpsinfo { /* Here is the structure in which status of each thread is captured. */ struct elf_thread_status { - TAILQ_ENTRY(elf_thread_status) ets_link; + QTAILQ_ENTRY(elf_thread_status) ets_link; struct target_elf_prstatus prstatus; /* NT_PRSTATUS */ #if 0 elf_fpregset_t fpu; /* NT_PRFPREG */ @@ -1860,7 +1860,7 @@ struct elf_note_info { struct target_elf_prstatus *prstatus; /* NT_PRSTATUS */ struct target_elf_prpsinfo *psinfo; /* NT_PRPSINFO */ - TAILQ_HEAD(thread_list_head, elf_thread_status) thread_list; + QTAILQ_HEAD(thread_list_head, elf_thread_status) thread_list; #if 0 /* * Current version of ELF coredump doesn't support @@ -1878,11 +1878,11 @@ struct vm_area_struct { abi_ulong vma_start; /* start vaddr of memory region */ abi_ulong vma_end; /* end vaddr of memory region */ abi_ulong vma_flags; /* protection etc. flags for the region */ - TAILQ_ENTRY(vm_area_struct) vma_link; + QTAILQ_ENTRY(vm_area_struct) vma_link; }; struct mm_struct { - TAILQ_HEAD(, vm_area_struct) mm_mmap; + QTAILQ_HEAD(, vm_area_struct) mm_mmap; int mm_count; /* number of mappings */ }; @@ -1962,7 +1962,7 @@ static struct mm_struct *vma_init(void) return (NULL); mm->mm_count = 0; - TAILQ_INIT(&mm->mm_mmap); + QTAILQ_INIT(&mm->mm_mmap); return (mm); } @@ -1972,7 +1972,7 @@ static void vma_delete(struct mm_struct *mm) struct vm_area_struct *vma; while ((vma = vma_first(mm)) != NULL) { - TAILQ_REMOVE(&mm->mm_mmap, vma, vma_link); + QTAILQ_REMOVE(&mm->mm_mmap, vma, vma_link); qemu_free(vma); } qemu_free(mm); @@ -1990,7 +1990,7 @@ static int vma_add_mapping(struct mm_struct *mm, abi_ulong start, vma->vma_end = end; vma->vma_flags = flags; - TAILQ_INSERT_TAIL(&mm->mm_mmap, vma, vma_link); + QTAILQ_INSERT_TAIL(&mm->mm_mmap, vma, vma_link); mm->mm_count++; return (0); @@ -1998,12 +1998,12 @@ static int vma_add_mapping(struct mm_struct *mm, abi_ulong start, static struct vm_area_struct *vma_first(const struct mm_struct *mm) { - return (TAILQ_FIRST(&mm->mm_mmap)); + return (QTAILQ_FIRST(&mm->mm_mmap)); } static struct vm_area_struct *vma_next(struct vm_area_struct *vma) { - return (TAILQ_NEXT(vma, vma_link)); + return (QTAILQ_NEXT(vma, vma_link)); } static int vma_get_mapping_count(const struct mm_struct *mm) @@ -2328,7 +2328,7 @@ static void fill_thread_info(struct elf_note_info *info, const CPUState *env) fill_note(&ets->notes[0], "CORE", NT_PRSTATUS, sizeof (ets->prstatus), &ets->prstatus); - TAILQ_INSERT_TAIL(&info->thread_list, ets, ets_link); + QTAILQ_INSERT_TAIL(&info->thread_list, ets, ets_link); info->notes_size += note_size(&ets->notes[0]); } @@ -2343,7 +2343,7 @@ static int fill_note_info(struct elf_note_info *info, (void) memset(info, 0, sizeof (*info)); - TAILQ_INIT(&info->thread_list); + QTAILQ_INIT(&info->thread_list); info->notes = qemu_mallocz(NUMNOTES * sizeof (struct memelfnote)); if (info->notes == NULL) @@ -2389,9 +2389,9 @@ static void free_note_info(struct elf_note_info *info) { struct elf_thread_status *ets; - while (!TAILQ_EMPTY(&info->thread_list)) { - ets = TAILQ_FIRST(&info->thread_list); - TAILQ_REMOVE(&info->thread_list, ets, ets_link); + while (!QTAILQ_EMPTY(&info->thread_list)) { + ets = QTAILQ_FIRST(&info->thread_list); + QTAILQ_REMOVE(&info->thread_list, ets, ets_link); qemu_free(ets); } diff --git a/linux-user/qemu.h b/linux-user/qemu.h index def620f0ee..d129debb1f 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -18,7 +18,7 @@ #include "syscall.h" #include "target_signal.h" #include "gdbstub.h" -#include "sys-queue.h" +#include "qemu-queue.h" #if defined(CONFIG_USE_NPTL) #define THREAD __thread @@ -12,17 +12,17 @@ */ #include "qemu-common.h" -#include "sys-queue.h" +#include "qemu-queue.h" #include "module.h" typedef struct ModuleEntry { module_init_type type; void (*init)(void); - TAILQ_ENTRY(ModuleEntry) node; + QTAILQ_ENTRY(ModuleEntry) node; } ModuleEntry; -typedef TAILQ_HEAD(, ModuleEntry) ModuleTypeList; +typedef QTAILQ_HEAD(, ModuleEntry) ModuleTypeList; static ModuleTypeList init_type_list[MODULE_INIT_MAX]; @@ -36,7 +36,7 @@ static void init_types(void) } for (i = 0; i < MODULE_INIT_MAX; i++) { - TAILQ_INIT(&init_type_list[i]); + QTAILQ_INIT(&init_type_list[i]); } inited = 1; @@ -64,7 +64,7 @@ void register_module_init(void (*fn)(void), module_init_type type) l = find_type(type); - TAILQ_INSERT_TAIL(l, e, node); + QTAILQ_INSERT_TAIL(l, e, node); } void module_call_init(module_init_type type) @@ -74,7 +74,7 @@ void module_call_init(module_init_type type) l = find_type(type); - TAILQ_FOREACH(e, l, node) { + QTAILQ_FOREACH(e, l, node) { e->init(); } } @@ -80,7 +80,7 @@ typedef struct mon_fd_t mon_fd_t; struct mon_fd_t { char *name; int fd; - LIST_ENTRY(mon_fd_t) next; + QLIST_ENTRY(mon_fd_t) next; }; struct Monitor { @@ -95,11 +95,11 @@ struct Monitor { CPUState *mon_cpu; BlockDriverCompletionFunc *password_completion_cb; void *password_opaque; - LIST_HEAD(,mon_fd_t) fds; - LIST_ENTRY(Monitor) entry; + QLIST_HEAD(,mon_fd_t) fds; + QLIST_ENTRY(Monitor) entry; }; -static LIST_HEAD(mon_list, Monitor) mon_list; +static QLIST_HEAD(mon_list, Monitor) mon_list; static const mon_cmd_t mon_cmds[]; static const mon_cmd_t info_cmds[]; @@ -270,7 +270,7 @@ static void do_commit(Monitor *mon, const QDict *qdict) const char *device = qdict_get_str(qdict, "device"); all_devices = !strcmp(device, "all"); - TAILQ_FOREACH(dinfo, &drives, next) { + QTAILQ_FOREACH(dinfo, &drives, next) { if (!all_devices) if (strcmp(bdrv_get_device_name(dinfo->bdrv), device)) continue; @@ -1477,7 +1477,7 @@ static void do_info_profile(Monitor *mon) #endif /* Capture support */ -static LIST_HEAD (capture_list_head, CaptureState) capture_head; +static QLIST_HEAD (capture_list_head, CaptureState) capture_head; static void do_info_capture(Monitor *mon) { @@ -1500,7 +1500,7 @@ static void do_stop_capture(Monitor *mon, const QDict *qdict) for (s = capture_head.lh_first, i = 0; s; s = s->entries.le_next, ++i) { if (i == n) { s->ops.destroy (s->opaque); - LIST_REMOVE (s, entries); + QLIST_REMOVE (s, entries); qemu_free (s); return; } @@ -1528,7 +1528,7 @@ static void do_wav_capture(Monitor *mon, const QDict *qdict) monitor_printf(mon, "Faied to add wave capture\n"); qemu_free (s); } - LIST_INSERT_HEAD (&capture_head, s, entries); + QLIST_INSERT_HEAD (&capture_head, s, entries); } #endif @@ -1600,7 +1600,7 @@ static void do_acl_show(Monitor *mon, const QDict *qdict) if (acl) { monitor_printf(mon, "policy: %s\n", acl->defaultDeny ? "deny" : "allow"); - TAILQ_FOREACH(entry, &acl->entries, next) { + QTAILQ_FOREACH(entry, &acl->entries, next) { i++; monitor_printf(mon, "%d: %s %s\n", i, entry->deny ? "deny" : "allow", entry->match); @@ -1729,7 +1729,7 @@ static void do_getfd(Monitor *mon, const QDict *qdict) return; } - LIST_FOREACH(monfd, &mon->fds, next) { + QLIST_FOREACH(monfd, &mon->fds, next) { if (strcmp(monfd->name, fdname) != 0) { continue; } @@ -1743,7 +1743,7 @@ static void do_getfd(Monitor *mon, const QDict *qdict) monfd->name = qemu_strdup(fdname); monfd->fd = fd; - LIST_INSERT_HEAD(&mon->fds, monfd, next); + QLIST_INSERT_HEAD(&mon->fds, monfd, next); } static void do_closefd(Monitor *mon, const QDict *qdict) @@ -1751,12 +1751,12 @@ static void do_closefd(Monitor *mon, const QDict *qdict) const char *fdname = qdict_get_str(qdict, "fdname"); mon_fd_t *monfd; - LIST_FOREACH(monfd, &mon->fds, next) { + QLIST_FOREACH(monfd, &mon->fds, next) { if (strcmp(monfd->name, fdname) != 0) { continue; } - LIST_REMOVE(monfd, next); + QLIST_REMOVE(monfd, next); close(monfd->fd); qemu_free(monfd->name); qemu_free(monfd); @@ -1782,7 +1782,7 @@ int monitor_get_fd(Monitor *mon, const char *fdname) { mon_fd_t *monfd; - LIST_FOREACH(monfd, &mon->fds, next) { + QLIST_FOREACH(monfd, &mon->fds, next) { int fd; if (strcmp(monfd->name, fdname) != 0) { @@ -1792,7 +1792,7 @@ int monitor_get_fd(Monitor *mon, const char *fdname) fd = monfd->fd; /* caller takes ownership of fd */ - LIST_REMOVE(monfd, next); + QLIST_REMOVE(monfd, next); qemu_free(monfd->name); qemu_free(monfd); @@ -3178,7 +3178,7 @@ void monitor_init(CharDriverState *chr, int flags) qemu_chr_add_handlers(chr, monitor_can_read, monitor_read, monitor_event, mon); - LIST_INSERT_HEAD(&mon_list, mon, entry); + QLIST_INSERT_HEAD(&mon_list, mon, entry); if (!cur_mon || (flags & MONITOR_IS_DEFAULT)) cur_mon = mon; } @@ -31,8 +31,6 @@ /* Needed early for CONFIG_BSD etc. */ #include "config-host.h" -/* Needed early to override system queue definitions on BSD */ -#include "sys-queue.h" #ifndef _WIN32 #include <sys/times.h> @@ -114,6 +112,7 @@ #include "qemu-log.h" #include "slirp/libslirp.h" +#include "qemu-queue.h" static VLANState *first_vlan; @@ -440,9 +439,9 @@ void qemu_purge_queued_packets(VLANClientState *vc) { VLANPacket *packet, *next; - TAILQ_FOREACH_SAFE(packet, &vc->vlan->send_queue, entry, next) { + QTAILQ_FOREACH_SAFE(packet, &vc->vlan->send_queue, entry, next) { if (packet->sender == vc) { - TAILQ_REMOVE(&vc->vlan->send_queue, packet, entry); + QTAILQ_REMOVE(&vc->vlan->send_queue, packet, entry); qemu_free(packet); } } @@ -450,16 +449,16 @@ void qemu_purge_queued_packets(VLANClientState *vc) void qemu_flush_queued_packets(VLANClientState *vc) { - while (!TAILQ_EMPTY(&vc->vlan->send_queue)) { + while (!QTAILQ_EMPTY(&vc->vlan->send_queue)) { VLANPacket *packet; int ret; - packet = TAILQ_FIRST(&vc->vlan->send_queue); - TAILQ_REMOVE(&vc->vlan->send_queue, packet, entry); + packet = QTAILQ_FIRST(&vc->vlan->send_queue); + QTAILQ_REMOVE(&vc->vlan->send_queue, packet, entry); ret = qemu_deliver_packet(packet->sender, packet->data, packet->size); if (ret == 0 && packet->sent_cb != NULL) { - TAILQ_INSERT_HEAD(&vc->vlan->send_queue, packet, entry); + QTAILQ_INSERT_HEAD(&vc->vlan->send_queue, packet, entry); break; } @@ -482,7 +481,7 @@ static void qemu_enqueue_packet(VLANClientState *sender, packet->sent_cb = sent_cb; memcpy(packet->data, buf, size); - TAILQ_INSERT_TAIL(&sender->vlan->send_queue, packet, entry); + QTAILQ_INSERT_TAIL(&sender->vlan->send_queue, packet, entry); } ssize_t qemu_send_packet_async(VLANClientState *sender, @@ -605,7 +604,7 @@ static ssize_t qemu_enqueue_packet_iov(VLANClientState *sender, packet->size += len; } - TAILQ_INSERT_TAIL(&sender->vlan->send_queue, packet, entry); + QTAILQ_INSERT_TAIL(&sender->vlan->send_queue, packet, entry); return packet->size; } @@ -671,7 +670,7 @@ struct slirp_config_str { }; typedef struct SlirpState { - TAILQ_ENTRY(SlirpState) entry; + QTAILQ_ENTRY(SlirpState) entry; VLANClientState *vc; Slirp *slirp; #ifndef _WIN32 @@ -682,8 +681,8 @@ typedef struct SlirpState { static struct slirp_config_str *slirp_configs; const char *legacy_tftp_prefix; const char *legacy_bootp_filename; -static TAILQ_HEAD(slirp_stacks, SlirpState) slirp_stacks = - TAILQ_HEAD_INITIALIZER(slirp_stacks); +static QTAILQ_HEAD(slirp_stacks, SlirpState) slirp_stacks = + QTAILQ_HEAD_INITIALIZER(slirp_stacks); static void slirp_hostfwd(SlirpState *s, Monitor *mon, const char *redir_str, int legacy_format); @@ -736,7 +735,7 @@ static void net_slirp_cleanup(VLANClientState *vc) slirp_cleanup(s->slirp); slirp_smb_cleanup(s); - TAILQ_REMOVE(&slirp_stacks, s, entry); + QTAILQ_REMOVE(&slirp_stacks, s, entry); qemu_free(s); } @@ -844,7 +843,7 @@ static int net_slirp_init(Monitor *mon, VLANState *vlan, const char *model, s = qemu_mallocz(sizeof(SlirpState)); s->slirp = slirp_init(restricted, net, mask, host, vhostname, tftp_export, bootfile, dhcp, dns, s); - TAILQ_INSERT_TAIL(&slirp_stacks, s, entry); + QTAILQ_INSERT_TAIL(&slirp_stacks, s, entry); while (slirp_configs) { struct slirp_config_str *config = slirp_configs; @@ -891,11 +890,11 @@ static SlirpState *slirp_lookup(Monitor *mon, const char *vlan, } return vc->opaque; } else { - if (TAILQ_EMPTY(&slirp_stacks)) { + if (QTAILQ_EMPTY(&slirp_stacks)) { monitor_printf(mon, "user mode network stack not in use\n"); return NULL; } - return TAILQ_FIRST(&slirp_stacks); + return QTAILQ_FIRST(&slirp_stacks); } } @@ -946,7 +945,7 @@ void net_slirp_hostfwd_remove(Monitor *mon, const QDict *qdict) host_port = atoi(p); - err = slirp_remove_hostfwd(TAILQ_FIRST(&slirp_stacks)->slirp, is_udp, + err = slirp_remove_hostfwd(QTAILQ_FIRST(&slirp_stacks)->slirp, is_udp, host_addr, host_port); monitor_printf(mon, "host forwarding rule for %s %s\n", src_str, @@ -1045,7 +1044,7 @@ void net_slirp_redir(const char *redir_str) { struct slirp_config_str *config; - if (TAILQ_EMPTY(&slirp_stacks)) { + if (QTAILQ_EMPTY(&slirp_stacks)) { config = qemu_malloc(sizeof(*config)); pstrcpy(config->str, sizeof(config->str), redir_str); config->flags = SLIRP_CFG_HOSTFWD | SLIRP_CFG_LEGACY; @@ -1054,7 +1053,7 @@ void net_slirp_redir(const char *redir_str) return; } - slirp_hostfwd(TAILQ_FIRST(&slirp_stacks), NULL, redir_str, 1); + slirp_hostfwd(QTAILQ_FIRST(&slirp_stacks), NULL, redir_str, 1); } #ifndef _WIN32 @@ -1137,8 +1136,8 @@ void net_slirp_smb(const char *exported_dir) exit(1); } legacy_smb_export = exported_dir; - if (!TAILQ_EMPTY(&slirp_stacks)) { - slirp_smb(TAILQ_FIRST(&slirp_stacks), NULL, exported_dir, + if (!QTAILQ_EMPTY(&slirp_stacks)) { + slirp_smb(QTAILQ_FIRST(&slirp_stacks), NULL, exported_dir, vserver_addr); } } @@ -1233,7 +1232,7 @@ void do_info_usernet(Monitor *mon) { SlirpState *s; - TAILQ_FOREACH(s, &slirp_stacks, entry) { + QTAILQ_FOREACH(s, &slirp_stacks, entry) { monitor_printf(mon, "VLAN %d (%s):\n", s->vc->vlan->id, s->vc->name); slirp_connection_info(s->slirp, mon); } @@ -2330,7 +2329,7 @@ VLANState *qemu_find_vlan(int id, int allocate) } vlan = qemu_mallocz(sizeof(VLANState)); vlan->id = id; - TAILQ_INIT(&vlan->send_queue); + QTAILQ_INIT(&vlan->send_queue); vlan->next = NULL; pvlan = &first_vlan; while (*pvlan != NULL) @@ -2594,7 +2593,7 @@ int net_client_init(Monitor *mon, const char *device, const char *p) qemu_free(smb_export); qemu_free(vsmbsrv); } else if (!strcmp(device, "channel")) { - if (TAILQ_EMPTY(&slirp_stacks)) { + if (QTAILQ_EMPTY(&slirp_stacks)) { struct slirp_config_str *config; config = qemu_malloc(sizeof(*config)); @@ -2603,7 +2602,7 @@ int net_client_init(Monitor *mon, const char *device, const char *p) config->next = slirp_configs; slirp_configs = config; } else { - slirp_guestfwd(TAILQ_FIRST(&slirp_stacks), mon, p, 1); + slirp_guestfwd(QTAILQ_FIRST(&slirp_stacks), mon, p, 1); } ret = 0; } else @@ -1,7 +1,7 @@ #ifndef QEMU_NET_H #define QEMU_NET_H -#include "sys-queue.h" +#include "qemu-queue.h" #include "qemu-common.h" #include "qdict.h" @@ -37,7 +37,7 @@ typedef struct VLANPacket VLANPacket; typedef void (NetPacketSent) (VLANClientState *, ssize_t); struct VLANPacket { - TAILQ_ENTRY(VLANPacket) entry; + QTAILQ_ENTRY(VLANPacket) entry; VLANClientState *sender; int size; NetPacketSent *sent_cb; @@ -49,7 +49,7 @@ struct VLANState { VLANClientState *first_client; struct VLANState *next; unsigned int nb_guest_devs, nb_host_devs; - TAILQ_HEAD(send_queue, VLANPacket) send_queue; + QTAILQ_HEAD(send_queue, VLANPacket) send_queue; int delivering; }; diff --git a/posix-aio-compat.c b/posix-aio-compat.c index 8bb3d10ee8..68cbec8bd1 100644 --- a/posix-aio-compat.c +++ b/posix-aio-compat.c @@ -22,7 +22,7 @@ #include <stdlib.h> #include <stdio.h> -#include "sys-queue.h" +#include "qemu-queue.h" #include "osdep.h" #include "qemu-common.h" #include "block_int.h" @@ -43,7 +43,7 @@ struct qemu_paiocb { int ev_signo; off_t aio_offset; - TAILQ_ENTRY(qemu_paiocb) node; + QTAILQ_ENTRY(qemu_paiocb) node; int aio_type; ssize_t ret; int active; @@ -63,7 +63,7 @@ static pthread_attr_t attr; static int max_threads = 64; static int cur_threads = 0; static int idle_threads = 0; -static TAILQ_HEAD(, qemu_paiocb) request_list; +static QTAILQ_HEAD(, qemu_paiocb) request_list; #ifdef CONFIG_PREADV static int preadv_present = 1; @@ -321,16 +321,16 @@ static void *aio_thread(void *unused) mutex_lock(&lock); - while (TAILQ_EMPTY(&request_list) && + while (QTAILQ_EMPTY(&request_list) && !(ret == ETIMEDOUT)) { ret = cond_timedwait(&cond, &lock, &ts); } - if (TAILQ_EMPTY(&request_list)) + if (QTAILQ_EMPTY(&request_list)) break; - aiocb = TAILQ_FIRST(&request_list); - TAILQ_REMOVE(&request_list, aiocb, node); + aiocb = QTAILQ_FIRST(&request_list); + QTAILQ_REMOVE(&request_list, aiocb, node); aiocb->active = 1; idle_threads--; mutex_unlock(&lock); @@ -381,7 +381,7 @@ static void qemu_paio_submit(struct qemu_paiocb *aiocb) mutex_lock(&lock); if (idle_threads == 0 && cur_threads < max_threads) spawn_thread(); - TAILQ_INSERT_TAIL(&request_list, aiocb, node); + QTAILQ_INSERT_TAIL(&request_list, aiocb, node); mutex_unlock(&lock); cond_signal(&cond); } @@ -509,7 +509,7 @@ static void paio_cancel(BlockDriverAIOCB *blockacb) mutex_lock(&lock); if (!acb->active) { - TAILQ_REMOVE(&request_list, acb, node); + QTAILQ_REMOVE(&request_list, acb, node); acb->ret = -ECANCELED; } else if (acb->ret == -EINPROGRESS) { active = 1; @@ -619,7 +619,7 @@ void *paio_init(void) if (ret) die2(ret, "pthread_attr_setdetachstate"); - TAILQ_INIT(&request_list); + QTAILQ_INIT(&request_list); posix_aio_state = s; @@ -14,7 +14,7 @@ #include "qdict.h" #include "qstring.h" #include "qobject.h" -#include "sys-queue.h" +#include "qemu-queue.h" #include "qemu-common.h" static void qdict_destroy_obj(QObject *obj); @@ -88,7 +88,7 @@ static QDictEntry *qdict_find(const QDict *qdict, { QDictEntry *entry; - LIST_FOREACH(entry, &qdict->table[hash], next) + QLIST_FOREACH(entry, &qdict->table[hash], next) if (!strcmp(entry->key, key)) return entry; @@ -120,7 +120,7 @@ void qdict_put_obj(QDict *qdict, const char *key, QObject *value) } else { /* allocate a new entry */ entry = alloc_entry(key, value); - LIST_INSERT_HEAD(&qdict->table[hash], entry, next); + QLIST_INSERT_HEAD(&qdict->table[hash], entry, next); } qdict->size++; @@ -266,7 +266,7 @@ void qdict_del(QDict *qdict, const char *key) entry = qdict_find(qdict, key, tdb_hash(key) % QDICT_HASH_SIZE); if (entry) { - LIST_REMOVE(entry, next); + QLIST_REMOVE(entry, next); qentry_destroy(entry); qdict->size--; } @@ -284,10 +284,10 @@ static void qdict_destroy_obj(QObject *obj) qdict = qobject_to_qdict(obj); for (i = 0; i < QDICT_HASH_SIZE; i++) { - QDictEntry *entry = LIST_FIRST(&qdict->table[i]); + QDictEntry *entry = QLIST_FIRST(&qdict->table[i]); while (entry) { - QDictEntry *tmp = LIST_NEXT(entry, next); - LIST_REMOVE(entry, next); + QDictEntry *tmp = QLIST_NEXT(entry, next); + QLIST_REMOVE(entry, next); qentry_destroy(entry); entry = tmp; } @@ -2,7 +2,7 @@ #define QDICT_H #include "qobject.h" -#include "sys-queue.h" +#include "qemu-queue.h" #include <stdint.h> #define QDICT_HASH_SIZE 512 @@ -10,13 +10,13 @@ typedef struct QDictEntry { char *key; QObject *value; - LIST_ENTRY(QDictEntry) next; + QLIST_ENTRY(QDictEntry) next; } QDictEntry; typedef struct QDict { QObject_HEAD; size_t size; - LIST_HEAD(,QDictEntry) table[QDICT_HASH_SIZE]; + QLIST_HEAD(,QDictEntry) table[QDICT_HASH_SIZE]; } QDict; /* Object API */ diff --git a/qemu-char.c b/qemu-char.c index 4f29618022..8084a6785d 100644 --- a/qemu-char.c +++ b/qemu-char.c @@ -106,8 +106,8 @@ /***********************************************************/ /* character device */ -static TAILQ_HEAD(CharDriverStateHead, CharDriverState) chardevs = - TAILQ_HEAD_INITIALIZER(chardevs); +static QTAILQ_HEAD(CharDriverStateHead, CharDriverState) chardevs = + QTAILQ_HEAD_INITIALIZER(chardevs); static int initial_reset_issued; static void qemu_chr_event(CharDriverState *s, int event) @@ -139,7 +139,7 @@ void qemu_chr_initial_reset(void) initial_reset_issued = 1; - TAILQ_FOREACH(chr, &chardevs, next) { + QTAILQ_FOREACH(chr, &chardevs, next) { qemu_chr_reset(chr); } } @@ -352,7 +352,7 @@ static int mux_proc_byte(CharDriverState *chr, MuxDriver *d, int ch) case 's': { DriveInfo *dinfo; - TAILQ_FOREACH(dinfo, &drives, next) { + QTAILQ_FOREACH(dinfo, &drives, next) { bdrv_commit(dinfo->bdrv); } } @@ -2400,7 +2400,7 @@ CharDriverState *qemu_chr_open_opts(QemuOpts *opts, if (!chr->filename) chr->filename = qemu_strdup(qemu_opt_get(opts, "backend")); chr->init = init; - TAILQ_INSERT_TAIL(&chardevs, chr, next); + QTAILQ_INSERT_TAIL(&chardevs, chr, next); if (qemu_opt_get_bool(opts, "mux", 0)) { CharDriverState *base = chr; @@ -2409,7 +2409,7 @@ CharDriverState *qemu_chr_open_opts(QemuOpts *opts, snprintf(base->label, len, "%s-base", qemu_opts_id(opts)); chr = qemu_chr_open_mux(base); chr->filename = base->filename; - TAILQ_INSERT_TAIL(&chardevs, chr, next); + QTAILQ_INSERT_TAIL(&chardevs, chr, next); } chr->label = qemu_strdup(qemu_opts_id(opts)); return chr; @@ -2438,7 +2438,7 @@ CharDriverState *qemu_chr_open(const char *label, const char *filename, void (*i void qemu_chr_close(CharDriverState *chr) { - TAILQ_REMOVE(&chardevs, chr, next); + QTAILQ_REMOVE(&chardevs, chr, next); if (chr->chr_close) chr->chr_close(chr); qemu_free(chr->filename); @@ -2450,7 +2450,7 @@ void qemu_chr_info(Monitor *mon) { CharDriverState *chr; - TAILQ_FOREACH(chr, &chardevs, next) { + QTAILQ_FOREACH(chr, &chardevs, next) { monitor_printf(mon, "%s: filename=%s\n", chr->label, chr->filename); } } @@ -2459,7 +2459,7 @@ CharDriverState *qemu_chr_find(const char *name) { CharDriverState *chr; - TAILQ_FOREACH(chr, &chardevs, next) { + QTAILQ_FOREACH(chr, &chardevs, next) { if (strcmp(chr->label, name) != 0) continue; return chr; diff --git a/qemu-char.h b/qemu-char.h index d12ab11a84..c0654bca25 100644 --- a/qemu-char.h +++ b/qemu-char.h @@ -2,7 +2,7 @@ #define QEMU_CHAR_H #include "qemu-common.h" -#include "sys-queue.h" +#include "qemu-queue.h" #include "qemu-option.h" #include "qemu-config.h" @@ -66,7 +66,7 @@ struct CharDriverState { QEMUBH *bh; char *label; char *filename; - TAILQ_ENTRY(CharDriverState) next; + QTAILQ_ENTRY(CharDriverState) next; }; CharDriverState *qemu_chr_open_opts(QemuOpts *opts, diff --git a/qemu-config.c b/qemu-config.c index f6f4cb4828..39bf6a9826 100644 --- a/qemu-config.c +++ b/qemu-config.c @@ -4,7 +4,7 @@ QemuOptsList qemu_drive_opts = { .name = "drive", - .head = TAILQ_HEAD_INITIALIZER(qemu_drive_opts.head), + .head = QTAILQ_HEAD_INITIALIZER(qemu_drive_opts.head), .desc = { { .name = "bus", @@ -77,7 +77,7 @@ QemuOptsList qemu_drive_opts = { QemuOptsList qemu_chardev_opts = { .name = "chardev", - .head = TAILQ_HEAD_INITIALIZER(qemu_chardev_opts.head), + .head = QTAILQ_HEAD_INITIALIZER(qemu_chardev_opts.head), .desc = { { .name = "backend", @@ -140,7 +140,7 @@ QemuOptsList qemu_chardev_opts = { QemuOptsList qemu_device_opts = { .name = "device", - .head = TAILQ_HEAD_INITIALIZER(qemu_device_opts.head), + .head = QTAILQ_HEAD_INITIALIZER(qemu_device_opts.head), .desc = { /* * no elements => accept any diff --git a/qemu-option.c b/qemu-option.c index 0c2101e3e6..88298e4b51 100644 --- a/qemu-option.c +++ b/qemu-option.c @@ -477,21 +477,21 @@ struct QemuOpt { } value; QemuOpts *opts; - TAILQ_ENTRY(QemuOpt) next; + QTAILQ_ENTRY(QemuOpt) next; }; struct QemuOpts { const char *id; QemuOptsList *list; - TAILQ_HEAD(, QemuOpt) head; - TAILQ_ENTRY(QemuOpts) next; + QTAILQ_HEAD(, QemuOpt) head; + QTAILQ_ENTRY(QemuOpts) next; }; static QemuOpt *qemu_opt_find(QemuOpts *opts, const char *name) { QemuOpt *opt; - TAILQ_FOREACH(opt, &opts->head, next) { + QTAILQ_FOREACH(opt, &opts->head, next) { if (strcmp(opt->name, name) != 0) continue; return opt; @@ -556,7 +556,7 @@ static int qemu_opt_parse(QemuOpt *opt) static void qemu_opt_del(QemuOpt *opt) { - TAILQ_REMOVE(&opt->opts->head, opt, next); + QTAILQ_REMOVE(&opt->opts->head, opt, next); qemu_free((/* !const */ char*)opt->name); qemu_free((/* !const */ char*)opt->str); qemu_free(opt); @@ -588,7 +588,7 @@ int qemu_opt_set(QemuOpts *opts, const char *name, const char *value) opt = qemu_mallocz(sizeof(*opt)); opt->name = qemu_strdup(name); opt->opts = opts; - TAILQ_INSERT_TAIL(&opts->head, opt, next); + QTAILQ_INSERT_TAIL(&opts->head, opt, next); if (desc[i].name != NULL) { opt->desc = desc+i; } @@ -613,7 +613,7 @@ int qemu_opt_foreach(QemuOpts *opts, qemu_opt_loopfunc func, void *opaque, QemuOpt *opt; int rc = 0; - TAILQ_FOREACH(opt, &opts->head, next) { + QTAILQ_FOREACH(opt, &opts->head, next) { rc = func(opt->name, opt->str, opaque); if (abort_on_failure && rc != 0) break; @@ -625,7 +625,7 @@ QemuOpts *qemu_opts_find(QemuOptsList *list, const char *id) { QemuOpts *opts; - TAILQ_FOREACH(opts, &list->head, next) { + QTAILQ_FOREACH(opts, &list->head, next) { if (!opts->id) { continue; } @@ -658,8 +658,8 @@ QemuOpts *qemu_opts_create(QemuOptsList *list, const char *id, int fail_if_exist opts->id = qemu_strdup(id); } opts->list = list; - TAILQ_INIT(&opts->head); - TAILQ_INSERT_TAIL(&list->head, opts, next); + QTAILQ_INIT(&opts->head); + QTAILQ_INSERT_TAIL(&list->head, opts, next); return opts; } @@ -687,12 +687,12 @@ void qemu_opts_del(QemuOpts *opts) QemuOpt *opt; for (;;) { - opt = TAILQ_FIRST(&opts->head); + opt = QTAILQ_FIRST(&opts->head); if (opt == NULL) break; qemu_opt_del(opt); } - TAILQ_REMOVE(&opts->list->head, opts, next); + QTAILQ_REMOVE(&opts->list->head, opts, next); qemu_free(opts); } @@ -702,7 +702,7 @@ int qemu_opts_print(QemuOpts *opts, void *dummy) fprintf(stderr, "%s: %s:", opts->list->name, opts->id ? opts->id : "<noid>"); - TAILQ_FOREACH(opt, &opts->head, next) { + QTAILQ_FOREACH(opt, &opts->head, next) { fprintf(stderr, " %s=\"%s\"", opt->name, opt->str); } fprintf(stderr, "\n"); @@ -788,7 +788,7 @@ int qemu_opts_foreach(QemuOptsList *list, qemu_opts_loopfunc func, void *opaque, QemuOpts *opts; int rc = 0; - TAILQ_FOREACH(opts, &list->head, next) { + QTAILQ_FOREACH(opts, &list->head, next) { rc = func(opts, opaque); if (abort_on_failure && rc != 0) break; diff --git a/qemu-option.h b/qemu-option.h index 9e52625cc0..6b968a5728 100644 --- a/qemu-option.h +++ b/qemu-option.h @@ -26,7 +26,7 @@ #ifndef QEMU_OPTIONS_H #define QEMU_OPTIONS_H -#include "sys-queue.h" +#include "qemu-queue.h" enum QEMUOptionParType { OPT_FLAG, @@ -95,7 +95,7 @@ typedef struct QemuOptDesc { struct QemuOptsList { const char *name; - TAILQ_HEAD(, QemuOpts) head; + QTAILQ_HEAD(, QemuOpts) head; QemuOptDesc desc[]; }; diff --git a/sys-queue.h b/qemu-queue.h index eb89a4d217..8877efd7b4 100644 --- a/sys-queue.h +++ b/qemu-queue.h @@ -36,8 +36,8 @@ * @(#)queue.h 8.5 (Berkeley) 8/20/94 */ -#ifndef _SYS_QUEUE_H_ -#define _SYS_QUEUE_H_ +#ifndef QEMU_SYS_QUEUE_H_ +#define QEMU_SYS_QUEUE_H_ /* * This file defines three types of data structures: @@ -71,15 +71,15 @@ /* * List definitions. */ -#define LIST_HEAD(name, type) \ +#define QLIST_HEAD(name, type) \ struct name { \ struct type *lh_first; /* first element */ \ } -#define LIST_HEAD_INITIALIZER(head) \ +#define QLIST_HEAD_INITIALIZER(head) \ { NULL } -#define LIST_ENTRY(type) \ +#define QLIST_ENTRY(type) \ struct { \ struct type *le_next; /* next element */ \ struct type **le_prev; /* address of previous next element */ \ @@ -88,11 +88,11 @@ struct { \ /* * List functions. */ -#define LIST_INIT(head) do { \ +#define QLIST_INIT(head) do { \ (head)->lh_first = NULL; \ } while (/*CONSTCOND*/0) -#define LIST_INSERT_AFTER(listelm, elm, field) do { \ +#define QLIST_INSERT_AFTER(listelm, elm, field) do { \ if (((elm)->field.le_next = (listelm)->field.le_next) != NULL) \ (listelm)->field.le_next->field.le_prev = \ &(elm)->field.le_next; \ @@ -100,33 +100,33 @@ struct { \ (elm)->field.le_prev = &(listelm)->field.le_next; \ } while (/*CONSTCOND*/0) -#define LIST_INSERT_BEFORE(listelm, elm, field) do { \ +#define QLIST_INSERT_BEFORE(listelm, elm, field) do { \ (elm)->field.le_prev = (listelm)->field.le_prev; \ (elm)->field.le_next = (listelm); \ *(listelm)->field.le_prev = (elm); \ (listelm)->field.le_prev = &(elm)->field.le_next; \ } while (/*CONSTCOND*/0) -#define LIST_INSERT_HEAD(head, elm, field) do { \ +#define QLIST_INSERT_HEAD(head, elm, field) do { \ if (((elm)->field.le_next = (head)->lh_first) != NULL) \ (head)->lh_first->field.le_prev = &(elm)->field.le_next;\ (head)->lh_first = (elm); \ (elm)->field.le_prev = &(head)->lh_first; \ } while (/*CONSTCOND*/0) -#define LIST_REMOVE(elm, field) do { \ +#define QLIST_REMOVE(elm, field) do { \ if ((elm)->field.le_next != NULL) \ (elm)->field.le_next->field.le_prev = \ (elm)->field.le_prev; \ *(elm)->field.le_prev = (elm)->field.le_next; \ } while (/*CONSTCOND*/0) -#define LIST_FOREACH(var, head, field) \ +#define QLIST_FOREACH(var, head, field) \ for ((var) = ((head)->lh_first); \ (var); \ (var) = ((var)->field.le_next)) -#define LIST_FOREACH_SAFE(var, head, field, next_var) \ +#define QLIST_FOREACH_SAFE(var, head, field, next_var) \ for ((var) = ((head)->lh_first); \ (var) && ((next_var) = ((var)->field.le_next), 1); \ (var) = (next_var)) @@ -134,40 +134,40 @@ struct { \ /* * List access methods. */ -#define LIST_EMPTY(head) ((head)->lh_first == NULL) -#define LIST_FIRST(head) ((head)->lh_first) -#define LIST_NEXT(elm, field) ((elm)->field.le_next) +#define QLIST_EMPTY(head) ((head)->lh_first == NULL) +#define QLIST_FIRST(head) ((head)->lh_first) +#define QLIST_NEXT(elm, field) ((elm)->field.le_next) /* * Tail queue definitions. */ -#define _TAILQ_HEAD(name, type, qual) \ +#define Q_TAILQ_HEAD(name, type, qual) \ struct name { \ qual type *tqh_first; /* first element */ \ qual type *qual *tqh_last; /* addr of last next element */ \ } -#define TAILQ_HEAD(name, type) _TAILQ_HEAD(name, struct type,) +#define QTAILQ_HEAD(name, type) Q_TAILQ_HEAD(name, struct type,) -#define TAILQ_HEAD_INITIALIZER(head) \ +#define QTAILQ_HEAD_INITIALIZER(head) \ { NULL, &(head).tqh_first } -#define _TAILQ_ENTRY(type, qual) \ +#define Q_TAILQ_ENTRY(type, qual) \ struct { \ qual type *tqe_next; /* next element */ \ qual type *qual *tqe_prev; /* address of previous next element */\ } -#define TAILQ_ENTRY(type) _TAILQ_ENTRY(struct type,) +#define QTAILQ_ENTRY(type) Q_TAILQ_ENTRY(struct type,) /* * Tail queue functions. */ -#define TAILQ_INIT(head) do { \ +#define QTAILQ_INIT(head) do { \ (head)->tqh_first = NULL; \ (head)->tqh_last = &(head)->tqh_first; \ } while (/*CONSTCOND*/0) -#define TAILQ_INSERT_HEAD(head, elm, field) do { \ +#define QTAILQ_INSERT_HEAD(head, elm, field) do { \ if (((elm)->field.tqe_next = (head)->tqh_first) != NULL) \ (head)->tqh_first->field.tqe_prev = \ &(elm)->field.tqe_next; \ @@ -177,14 +177,14 @@ struct { \ (elm)->field.tqe_prev = &(head)->tqh_first; \ } while (/*CONSTCOND*/0) -#define TAILQ_INSERT_TAIL(head, elm, field) do { \ +#define QTAILQ_INSERT_TAIL(head, elm, field) do { \ (elm)->field.tqe_next = NULL; \ (elm)->field.tqe_prev = (head)->tqh_last; \ *(head)->tqh_last = (elm); \ (head)->tqh_last = &(elm)->field.tqe_next; \ } while (/*CONSTCOND*/0) -#define TAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ +#define QTAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ if (((elm)->field.tqe_next = (listelm)->field.tqe_next) != NULL)\ (elm)->field.tqe_next->field.tqe_prev = \ &(elm)->field.tqe_next; \ @@ -194,14 +194,14 @@ struct { \ (elm)->field.tqe_prev = &(listelm)->field.tqe_next; \ } while (/*CONSTCOND*/0) -#define TAILQ_INSERT_BEFORE(listelm, elm, field) do { \ +#define QTAILQ_INSERT_BEFORE(listelm, elm, field) do { \ (elm)->field.tqe_prev = (listelm)->field.tqe_prev; \ (elm)->field.tqe_next = (listelm); \ *(listelm)->field.tqe_prev = (elm); \ (listelm)->field.tqe_prev = &(elm)->field.tqe_next; \ } while (/*CONSTCOND*/0) -#define TAILQ_REMOVE(head, elm, field) do { \ +#define QTAILQ_REMOVE(head, elm, field) do { \ if (((elm)->field.tqe_next) != NULL) \ (elm)->field.tqe_next->field.tqe_prev = \ (elm)->field.tqe_prev; \ @@ -210,17 +210,17 @@ struct { \ *(elm)->field.tqe_prev = (elm)->field.tqe_next; \ } while (/*CONSTCOND*/0) -#define TAILQ_FOREACH(var, head, field) \ +#define QTAILQ_FOREACH(var, head, field) \ for ((var) = ((head)->tqh_first); \ (var); \ (var) = ((var)->field.tqe_next)) -#define TAILQ_FOREACH_SAFE(var, head, field, next_var) \ +#define QTAILQ_FOREACH_SAFE(var, head, field, next_var) \ for ((var) = ((head)->tqh_first); \ (var) && ((next_var) = ((var)->field.tqe_next), 1); \ (var) = (next_var)) -#define TAILQ_FOREACH_REVERSE(var, head, headname, field) \ +#define QTAILQ_FOREACH_REVERSE(var, head, headname, field) \ for ((var) = (*(((struct headname *)((head)->tqh_last))->tqh_last)); \ (var); \ (var) = (*(((struct headname *)((var)->field.tqe_prev))->tqh_last))) @@ -228,29 +228,29 @@ struct { \ /* * Tail queue access methods. */ -#define TAILQ_EMPTY(head) ((head)->tqh_first == NULL) -#define TAILQ_FIRST(head) ((head)->tqh_first) -#define TAILQ_NEXT(elm, field) ((elm)->field.tqe_next) +#define QTAILQ_EMPTY(head) ((head)->tqh_first == NULL) +#define QTAILQ_FIRST(head) ((head)->tqh_first) +#define QTAILQ_NEXT(elm, field) ((elm)->field.tqe_next) -#define TAILQ_LAST(head, headname) \ +#define QTAILQ_LAST(head, headname) \ (*(((struct headname *)((head)->tqh_last))->tqh_last)) -#define TAILQ_PREV(elm, headname, field) \ +#define QTAILQ_PREV(elm, headname, field) \ (*(((struct headname *)((elm)->field.tqe_prev))->tqh_last)) /* * Circular queue definitions. */ -#define CIRCLEQ_HEAD(name, type) \ +#define QCIRCLEQ_HEAD(name, type) \ struct name { \ struct type *cqh_first; /* first element */ \ struct type *cqh_last; /* last element */ \ } -#define CIRCLEQ_HEAD_INITIALIZER(head) \ +#define QCIRCLEQ_HEAD_INITIALIZER(head) \ { (void *)&head, (void *)&head } -#define CIRCLEQ_ENTRY(type) \ +#define QCIRCLEQ_ENTRY(type) \ struct { \ struct type *cqe_next; /* next element */ \ struct type *cqe_prev; /* previous element */ \ @@ -259,12 +259,12 @@ struct { \ /* * Circular queue functions. */ -#define CIRCLEQ_INIT(head) do { \ +#define QCIRCLEQ_INIT(head) do { \ (head)->cqh_first = (void *)(head); \ (head)->cqh_last = (void *)(head); \ } while (/*CONSTCOND*/0) -#define CIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ +#define QCIRCLEQ_INSERT_AFTER(head, listelm, elm, field) do { \ (elm)->field.cqe_next = (listelm)->field.cqe_next; \ (elm)->field.cqe_prev = (listelm); \ if ((listelm)->field.cqe_next == (void *)(head)) \ @@ -274,7 +274,7 @@ struct { \ (listelm)->field.cqe_next = (elm); \ } while (/*CONSTCOND*/0) -#define CIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do { \ +#define QCIRCLEQ_INSERT_BEFORE(head, listelm, elm, field) do { \ (elm)->field.cqe_next = (listelm); \ (elm)->field.cqe_prev = (listelm)->field.cqe_prev; \ if ((listelm)->field.cqe_prev == (void *)(head)) \ @@ -284,7 +284,7 @@ struct { \ (listelm)->field.cqe_prev = (elm); \ } while (/*CONSTCOND*/0) -#define CIRCLEQ_INSERT_HEAD(head, elm, field) do { \ +#define QCIRCLEQ_INSERT_HEAD(head, elm, field) do { \ (elm)->field.cqe_next = (head)->cqh_first; \ (elm)->field.cqe_prev = (void *)(head); \ if ((head)->cqh_last == (void *)(head)) \ @@ -294,7 +294,7 @@ struct { \ (head)->cqh_first = (elm); \ } while (/*CONSTCOND*/0) -#define CIRCLEQ_INSERT_TAIL(head, elm, field) do { \ +#define QCIRCLEQ_INSERT_TAIL(head, elm, field) do { \ (elm)->field.cqe_next = (void *)(head); \ (elm)->field.cqe_prev = (head)->cqh_last; \ if ((head)->cqh_first == (void *)(head)) \ @@ -304,7 +304,7 @@ struct { \ (head)->cqh_last = (elm); \ } while (/*CONSTCOND*/0) -#define CIRCLEQ_REMOVE(head, elm, field) do { \ +#define QCIRCLEQ_REMOVE(head, elm, field) do { \ if ((elm)->field.cqe_next == (void *)(head)) \ (head)->cqh_last = (elm)->field.cqe_prev; \ else \ @@ -317,12 +317,12 @@ struct { \ (elm)->field.cqe_next; \ } while (/*CONSTCOND*/0) -#define CIRCLEQ_FOREACH(var, head, field) \ +#define QCIRCLEQ_FOREACH(var, head, field) \ for ((var) = ((head)->cqh_first); \ (var) != (const void *)(head); \ (var) = ((var)->field.cqe_next)) -#define CIRCLEQ_FOREACH_REVERSE(var, head, field) \ +#define QCIRCLEQ_FOREACH_REVERSE(var, head, field) \ for ((var) = ((head)->cqh_last); \ (var) != (const void *)(head); \ (var) = ((var)->field.cqe_prev)) @@ -330,19 +330,19 @@ struct { \ /* * Circular queue access methods. */ -#define CIRCLEQ_EMPTY(head) ((head)->cqh_first == (void *)(head)) -#define CIRCLEQ_FIRST(head) ((head)->cqh_first) -#define CIRCLEQ_LAST(head) ((head)->cqh_last) -#define CIRCLEQ_NEXT(elm, field) ((elm)->field.cqe_next) -#define CIRCLEQ_PREV(elm, field) ((elm)->field.cqe_prev) +#define QCIRCLEQ_EMPTY(head) ((head)->cqh_first == (void *)(head)) +#define QCIRCLEQ_FIRST(head) ((head)->cqh_first) +#define QCIRCLEQ_LAST(head) ((head)->cqh_last) +#define QCIRCLEQ_NEXT(elm, field) ((elm)->field.cqe_next) +#define QCIRCLEQ_PREV(elm, field) ((elm)->field.cqe_prev) -#define CIRCLEQ_LOOP_NEXT(head, elm, field) \ +#define QCIRCLEQ_LOOP_NEXT(head, elm, field) \ (((elm)->field.cqe_next == (void *)(head)) \ ? ((head)->cqh_first) \ : (elm->field.cqe_next)) -#define CIRCLEQ_LOOP_PREV(head, elm, field) \ +#define QCIRCLEQ_LOOP_PREV(head, elm, field) \ (((elm)->field.cqe_prev == (void *)(head)) \ ? ((head)->cqh_last) \ : (elm->field.cqe_prev)) -#endif /* !_SYS_QUEUE_H_ */ +#endif /* !QEMU_SYS_QUEUE_H_ */ diff --git a/qemu-sockets.c b/qemu-sockets.c index b80279c867..3cdff4c206 100644 --- a/qemu-sockets.c +++ b/qemu-sockets.c @@ -32,7 +32,7 @@ static const int on=1, off=0; /* used temporarely until all users are converted to QemuOpts */ QemuOptsList dummy_opts = { .name = "dummy", - .head = TAILQ_HEAD_INITIALIZER(dummy_opts.head), + .head = QTAILQ_HEAD_INITIALIZER(dummy_opts.head), .desc = { { .name = "path", @@ -31,8 +31,6 @@ /* Needed early for CONFIG_BSD etc. */ #include "config-host.h" -/* Needed early to override system queue definitions on BSD */ -#include "sys-queue.h" #ifndef _WIN32 #include <sys/times.h> @@ -92,6 +90,7 @@ #include "audio/audio.h" #include "migration.h" #include "qemu_socket.h" +#include "qemu-queue.h" /* point to the block driver where the snapshots are managed */ static BlockDriverState *bs_snapshots; @@ -912,7 +911,7 @@ const VMStateInfo vmstate_info_buffer = { }; typedef struct SaveStateEntry { - TAILQ_ENTRY(SaveStateEntry) entry; + QTAILQ_ENTRY(SaveStateEntry) entry; char idstr[256]; int instance_id; int version_id; @@ -924,8 +923,8 @@ typedef struct SaveStateEntry { void *opaque; } SaveStateEntry; -static TAILQ_HEAD(savevm_handlers, SaveStateEntry) savevm_handlers = - TAILQ_HEAD_INITIALIZER(savevm_handlers); +static QTAILQ_HEAD(savevm_handlers, SaveStateEntry) savevm_handlers = + QTAILQ_HEAD_INITIALIZER(savevm_handlers); static int global_section_id; static int calculate_new_instance_id(const char *idstr) @@ -933,7 +932,7 @@ static int calculate_new_instance_id(const char *idstr) SaveStateEntry *se; int instance_id = 0; - TAILQ_FOREACH(se, &savevm_handlers, entry) { + QTAILQ_FOREACH(se, &savevm_handlers, entry) { if (strcmp(idstr, se->idstr) == 0 && instance_id <= se->instance_id) { instance_id = se->instance_id + 1; @@ -972,7 +971,7 @@ int register_savevm_live(const char *idstr, se->instance_id = instance_id; } /* add at the end of list */ - TAILQ_INSERT_TAIL(&savevm_handlers, se, entry); + QTAILQ_INSERT_TAIL(&savevm_handlers, se, entry); return 0; } @@ -991,9 +990,9 @@ void unregister_savevm(const char *idstr, void *opaque) { SaveStateEntry *se, *new_se; - TAILQ_FOREACH_SAFE(se, &savevm_handlers, entry, new_se) { + QTAILQ_FOREACH_SAFE(se, &savevm_handlers, entry, new_se) { if (strcmp(se->idstr, idstr) == 0 && se->opaque == opaque) { - TAILQ_REMOVE(&savevm_handlers, se, entry); + QTAILQ_REMOVE(&savevm_handlers, se, entry); qemu_free(se); } } @@ -1020,7 +1019,7 @@ int vmstate_register(int instance_id, const VMStateDescription *vmsd, se->instance_id = instance_id; } /* add at the end of list */ - TAILQ_INSERT_TAIL(&savevm_handlers, se, entry); + QTAILQ_INSERT_TAIL(&savevm_handlers, se, entry); return 0; } @@ -1028,9 +1027,9 @@ void vmstate_unregister(const VMStateDescription *vmsd, void *opaque) { SaveStateEntry *se, *new_se; - TAILQ_FOREACH_SAFE(se, &savevm_handlers, entry, new_se) { + QTAILQ_FOREACH_SAFE(se, &savevm_handlers, entry, new_se) { if (se->vmsd == vmsd && se->opaque == opaque) { - TAILQ_REMOVE(&savevm_handlers, se, entry); + QTAILQ_REMOVE(&savevm_handlers, se, entry); qemu_free(se); } } @@ -1160,7 +1159,7 @@ int qemu_savevm_state_begin(QEMUFile *f) qemu_put_be32(f, QEMU_VM_FILE_MAGIC); qemu_put_be32(f, QEMU_VM_FILE_VERSION); - TAILQ_FOREACH(se, &savevm_handlers, entry) { + QTAILQ_FOREACH(se, &savevm_handlers, entry) { int len; if (se->save_live_state == NULL) @@ -1192,7 +1191,7 @@ int qemu_savevm_state_iterate(QEMUFile *f) SaveStateEntry *se; int ret = 1; - TAILQ_FOREACH(se, &savevm_handlers, entry) { + QTAILQ_FOREACH(se, &savevm_handlers, entry) { if (se->save_live_state == NULL) continue; @@ -1216,7 +1215,7 @@ int qemu_savevm_state_complete(QEMUFile *f) { SaveStateEntry *se; - TAILQ_FOREACH(se, &savevm_handlers, entry) { + QTAILQ_FOREACH(se, &savevm_handlers, entry) { if (se->save_live_state == NULL) continue; @@ -1227,7 +1226,7 @@ int qemu_savevm_state_complete(QEMUFile *f) se->save_live_state(f, QEMU_VM_SECTION_END, se->opaque); } - TAILQ_FOREACH(se, &savevm_handlers, entry) { + QTAILQ_FOREACH(se, &savevm_handlers, entry) { int len; if (se->save_state == NULL && se->vmsd == NULL) @@ -1292,7 +1291,7 @@ static SaveStateEntry *find_se(const char *idstr, int instance_id) { SaveStateEntry *se; - TAILQ_FOREACH(se, &savevm_handlers, entry) { + QTAILQ_FOREACH(se, &savevm_handlers, entry) { if (!strcmp(se->idstr, idstr) && instance_id == se->instance_id) return se; @@ -1301,7 +1300,7 @@ static SaveStateEntry *find_se(const char *idstr, int instance_id) } typedef struct LoadStateEntry { - LIST_ENTRY(LoadStateEntry) entry; + QLIST_ENTRY(LoadStateEntry) entry; SaveStateEntry *se; int section_id; int version_id; @@ -1309,8 +1308,8 @@ typedef struct LoadStateEntry { int qemu_loadvm_state(QEMUFile *f) { - LIST_HEAD(, LoadStateEntry) loadvm_handlers = - LIST_HEAD_INITIALIZER(loadvm_handlers); + QLIST_HEAD(, LoadStateEntry) loadvm_handlers = + QLIST_HEAD_INITIALIZER(loadvm_handlers); LoadStateEntry *le, *new_le; uint8_t section_type; unsigned int v; @@ -1367,7 +1366,7 @@ int qemu_loadvm_state(QEMUFile *f) le->se = se; le->section_id = section_id; le->version_id = version_id; - LIST_INSERT_HEAD(&loadvm_handlers, le, entry); + QLIST_INSERT_HEAD(&loadvm_handlers, le, entry); ret = vmstate_load(f, le->se, le->version_id); if (ret < 0) { @@ -1380,7 +1379,7 @@ int qemu_loadvm_state(QEMUFile *f) case QEMU_VM_SECTION_END: section_id = qemu_get_be32(f); - LIST_FOREACH(le, &loadvm_handlers, entry) { + QLIST_FOREACH(le, &loadvm_handlers, entry) { if (le->section_id == section_id) { break; } @@ -1408,8 +1407,8 @@ int qemu_loadvm_state(QEMUFile *f) ret = 0; out: - LIST_FOREACH_SAFE(le, &loadvm_handlers, entry, new_le) { - LIST_REMOVE(le, entry); + QLIST_FOREACH_SAFE(le, &loadvm_handlers, entry, new_le) { + QLIST_REMOVE(le, entry); qemu_free(le); } @@ -1442,7 +1441,7 @@ static BlockDriverState *get_bs_snapshots(void) if (bs_snapshots) return bs_snapshots; - TAILQ_FOREACH(dinfo, &drives, next) { + QTAILQ_FOREACH(dinfo, &drives, next) { bs = dinfo->bdrv; if (bdrv_can_snapshot(bs)) goto ok; @@ -1547,7 +1546,7 @@ void do_savevm(Monitor *mon, const QDict *qdict) /* create the snapshots */ - TAILQ_FOREACH(dinfo, &drives, next) { + QTAILQ_FOREACH(dinfo, &drives, next) { bs1 = dinfo->bdrv; if (bdrv_has_snapshot(bs1)) { if (must_delete) { @@ -1590,7 +1589,7 @@ int load_vmstate(Monitor *mon, const char *name) /* Flush all IO requests so they don't interfere with the new state. */ qemu_aio_flush(); - TAILQ_FOREACH(dinfo, &drives, next) { + QTAILQ_FOREACH(dinfo, &drives, next) { bs1 = dinfo->bdrv; if (bdrv_has_snapshot(bs1)) { ret = bdrv_snapshot_goto(bs1, name); @@ -1653,7 +1652,7 @@ void do_delvm(Monitor *mon, const QDict *qdict) return; } - TAILQ_FOREACH(dinfo, &drives, next) { + QTAILQ_FOREACH(dinfo, &drives, next) { bs1 = dinfo->bdrv; if (bdrv_has_snapshot(bs1)) { ret = bdrv_snapshot_delete(bs1, name); @@ -1684,7 +1683,7 @@ void do_info_snapshots(Monitor *mon) return; } monitor_printf(mon, "Snapshot devices:"); - TAILQ_FOREACH(dinfo, &drives, next) { + QTAILQ_FOREACH(dinfo, &drives, next) { bs1 = dinfo->bdrv; if (bdrv_has_snapshot(bs1)) { if (bs == bs1) diff --git a/slirp/slirp.c b/slirp/slirp.c index d4a9bacf17..6731f529f6 100644 --- a/slirp/slirp.c +++ b/slirp/slirp.c @@ -44,8 +44,8 @@ u_int curtime; static u_int time_fasttimo, last_slowtimo; static int do_slowtimo; -static TAILQ_HEAD(slirp_instances, Slirp) slirp_instances = - TAILQ_HEAD_INITIALIZER(slirp_instances); +static QTAILQ_HEAD(slirp_instances, Slirp) slirp_instances = + QTAILQ_HEAD_INITIALIZER(slirp_instances); static struct in_addr dns_addr; static u_int dns_addr_time; @@ -234,14 +234,14 @@ Slirp *slirp_init(int restricted, struct in_addr vnetwork, register_savevm("slirp", 0, 3, slirp_state_save, slirp_state_load, slirp); - TAILQ_INSERT_TAIL(&slirp_instances, slirp, entry); + QTAILQ_INSERT_TAIL(&slirp_instances, slirp, entry); return slirp; } void slirp_cleanup(Slirp *slirp) { - TAILQ_REMOVE(&slirp_instances, slirp, entry); + QTAILQ_REMOVE(&slirp_instances, slirp, entry); unregister_savevm("slirp", slirp); @@ -261,7 +261,7 @@ void slirp_select_fill(int *pnfds, struct socket *so, *so_next; int nfds; - if (TAILQ_EMPTY(&slirp_instances)) { + if (QTAILQ_EMPTY(&slirp_instances)) { return; } @@ -276,7 +276,7 @@ void slirp_select_fill(int *pnfds, */ do_slowtimo = 0; - TAILQ_FOREACH(slirp, &slirp_instances, entry) { + QTAILQ_FOREACH(slirp, &slirp_instances, entry) { /* * *_slowtimo needs calling if there are IP fragments * in the fragment queue, or there are TCP connections active @@ -384,7 +384,7 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds, struct socket *so, *so_next; int ret; - if (TAILQ_EMPTY(&slirp_instances)) { + if (QTAILQ_EMPTY(&slirp_instances)) { return; } @@ -394,7 +394,7 @@ void slirp_select_poll(fd_set *readfds, fd_set *writefds, fd_set *xfds, curtime = qemu_get_clock(rt_clock); - TAILQ_FOREACH(slirp, &slirp_instances, entry) { + QTAILQ_FOREACH(slirp, &slirp_instances, entry) { /* * See if anything has timed out */ diff --git a/slirp/slirp.h b/slirp/slirp.h index 020412caf3..9ef57ea394 100644 --- a/slirp/slirp.h +++ b/slirp/slirp.h @@ -174,7 +174,7 @@ int inet_aton(const char *cp, struct in_addr *ia); #include "debug.h" -#include "sys-queue.h" +#include "qemu-queue.h" #include "libslirp.h" #include "ip.h" @@ -198,7 +198,7 @@ int inet_aton(const char *cp, struct in_addr *ia); #include "tftp.h" struct Slirp { - TAILQ_ENTRY(Slirp) entry; + QTAILQ_ENTRY(Slirp) entry; /* virtual network configuration */ struct in_addr vnetwork_addr; @@ -4,7 +4,7 @@ #include "qemu-common.h" #include "qemu-option.h" -#include "sys-queue.h" +#include "qemu-queue.h" #include "qdict.h" #ifdef _WIN32 @@ -174,15 +174,15 @@ typedef struct DriveInfo { QemuOpts *opts; BlockInterfaceErrorAction onerror; char serial[BLOCK_SERIAL_STRLEN + 1]; - TAILQ_ENTRY(DriveInfo) next; + QTAILQ_ENTRY(DriveInfo) next; } DriveInfo; #define MAX_IDE_DEVS 2 #define MAX_SCSI_DEVS 7 #define MAX_DRIVES 32 -extern TAILQ_HEAD(drivelist, DriveInfo) drives; -extern TAILQ_HEAD(driveoptlist, DriveOpt) driveopts; +extern QTAILQ_HEAD(drivelist, DriveInfo) drives; +extern QTAILQ_HEAD(driveoptlist, DriveOpt) driveopts; extern DriveInfo *drive_get(BlockInterfaceType type, int bus, int unit); extern DriveInfo *drive_get_by_id(const char *id); diff --git a/target-alpha/translate.c b/target-alpha/translate.c index 1dd85629b3..9d2bc45d86 100644 --- a/target-alpha/translate.c +++ b/target-alpha/translate.c @@ -2367,8 +2367,8 @@ static inline void gen_intermediate_code_internal(CPUState *env, gen_icount_start(); for (ret = 0; ret == 0;) { - if (unlikely(!TAILQ_EMPTY(&env->breakpoints))) { - TAILQ_FOREACH(bp, &env->breakpoints, entry) { + if (unlikely(!QTAILQ_EMPTY(&env->breakpoints))) { + QTAILQ_FOREACH(bp, &env->breakpoints, entry) { if (bp->pc == ctx.pc) { gen_excp(&ctx, EXCP_DEBUG, 0); break; diff --git a/target-arm/translate.c b/target-arm/translate.c index 4db8d0e262..c1d0dcf166 100644 --- a/target-arm/translate.c +++ b/target-arm/translate.c @@ -8770,8 +8770,8 @@ static inline void gen_intermediate_code_internal(CPUState *env, } #endif - if (unlikely(!TAILQ_EMPTY(&env->breakpoints))) { - TAILQ_FOREACH(bp, &env->breakpoints, entry) { + if (unlikely(!QTAILQ_EMPTY(&env->breakpoints))) { + QTAILQ_FOREACH(bp, &env->breakpoints, entry) { if (bp->pc == dc->pc) { gen_set_condexec(dc); gen_set_pc_im(dc->pc); diff --git a/target-cris/translate.c b/target-cris/translate.c index bd3ae3d763..c6068f78f8 100644 --- a/target-cris/translate.c +++ b/target-cris/translate.c @@ -3082,8 +3082,8 @@ static void check_breakpoint(CPUState *env, DisasContext *dc) { CPUBreakpoint *bp; - if (unlikely(!TAILQ_EMPTY(&env->breakpoints))) { - TAILQ_FOREACH(bp, &env->breakpoints, entry) { + if (unlikely(!QTAILQ_EMPTY(&env->breakpoints))) { + QTAILQ_FOREACH(bp, &env->breakpoints, entry) { if (bp->pc == dc->pc) { cris_evaluate_flags (dc); tcg_gen_movi_tl(env_pc, dc->pc); diff --git a/target-i386/helper.c b/target-i386/helper.c index 8abbed0a6f..45b04eeb03 100644 --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -1522,7 +1522,7 @@ static void breakpoint_handler(CPUState *env) cpu_resume_from_signal(env, NULL); } } else { - TAILQ_FOREACH(bp, &env->breakpoints, entry) + QTAILQ_FOREACH(bp, &env->breakpoints, entry) if (bp->pc == env->eip) { if (bp->flags & BP_CPU) { check_hw_breakpoints(env, 1); diff --git a/target-i386/translate.c b/target-i386/translate.c index ff93985754..335fc08421 100644 --- a/target-i386/translate.c +++ b/target-i386/translate.c @@ -7687,8 +7687,8 @@ static inline void gen_intermediate_code_internal(CPUState *env, gen_icount_start(); for(;;) { - if (unlikely(!TAILQ_EMPTY(&env->breakpoints))) { - TAILQ_FOREACH(bp, &env->breakpoints, entry) { + if (unlikely(!QTAILQ_EMPTY(&env->breakpoints))) { + QTAILQ_FOREACH(bp, &env->breakpoints, entry) { if (bp->pc == pc_ptr && !((bp->flags & BP_CPU) && (tb->flags & HF_RF_MASK))) { gen_debug(dc, pc_ptr - dc->cs_base); diff --git a/target-m68k/translate.c b/target-m68k/translate.c index b37578baf9..99cf6ddef7 100644 --- a/target-m68k/translate.c +++ b/target-m68k/translate.c @@ -2999,8 +2999,8 @@ gen_intermediate_code_internal(CPUState *env, TranslationBlock *tb, do { pc_offset = dc->pc - pc_start; gen_throws_exception = NULL; - if (unlikely(!TAILQ_EMPTY(&env->breakpoints))) { - TAILQ_FOREACH(bp, &env->breakpoints, entry) { + if (unlikely(!QTAILQ_EMPTY(&env->breakpoints))) { + QTAILQ_FOREACH(bp, &env->breakpoints, entry) { if (bp->pc == dc->pc) { gen_exception(dc, dc->pc, EXCP_DEBUG); dc->is_jmp = DISAS_JUMP; diff --git a/target-microblaze/translate.c b/target-microblaze/translate.c index fe53b2e141..dfeb8ae848 100644 --- a/target-microblaze/translate.c +++ b/target-microblaze/translate.c @@ -1230,8 +1230,8 @@ static void check_breakpoint(CPUState *env, DisasContext *dc) { CPUBreakpoint *bp; - if (unlikely(!TAILQ_EMPTY(&env->breakpoints))) { - TAILQ_FOREACH(bp, &env->breakpoints, entry) { + if (unlikely(!QTAILQ_EMPTY(&env->breakpoints))) { + QTAILQ_FOREACH(bp, &env->breakpoints, entry) { if (bp->pc == dc->pc) { t_gen_raise_exception(dc, EXCP_DEBUG); dc->is_jmp = DISAS_UPDATE; diff --git a/target-mips/translate.c b/target-mips/translate.c index a2b2edbbd2..fb3c980c18 100644 --- a/target-mips/translate.c +++ b/target-mips/translate.c @@ -8314,8 +8314,8 @@ gen_intermediate_code_internal (CPUState *env, TranslationBlock *tb, LOG_DISAS("\ntb %p idx %d hflags %04x\n", tb, ctx.mem_idx, ctx.hflags); gen_icount_start(); while (ctx.bstate == BS_NONE) { - if (unlikely(!TAILQ_EMPTY(&env->breakpoints))) { - TAILQ_FOREACH(bp, &env->breakpoints, entry) { + if (unlikely(!QTAILQ_EMPTY(&env->breakpoints))) { + QTAILQ_FOREACH(bp, &env->breakpoints, entry) { if (bp->pc == ctx.pc) { save_cpu_state(&ctx, 1); ctx.bstate = BS_BRANCH; diff --git a/target-ppc/translate.c b/target-ppc/translate.c index 1c54fa7d85..648bf9e187 100644 --- a/target-ppc/translate.c +++ b/target-ppc/translate.c @@ -9000,8 +9000,8 @@ static inline void gen_intermediate_code_internal(CPUState *env, gen_icount_start(); /* Set env in case of segfault during code fetch */ while (ctx.exception == POWERPC_EXCP_NONE && gen_opc_ptr < gen_opc_end) { - if (unlikely(!TAILQ_EMPTY(&env->breakpoints))) { - TAILQ_FOREACH(bp, &env->breakpoints, entry) { + if (unlikely(!QTAILQ_EMPTY(&env->breakpoints))) { + QTAILQ_FOREACH(bp, &env->breakpoints, entry) { if (bp->pc == ctx.nip) { gen_debug_exception(ctxp); break; diff --git a/target-sh4/translate.c b/target-sh4/translate.c index b272f4c06e..895b978d38 100644 --- a/target-sh4/translate.c +++ b/target-sh4/translate.c @@ -1927,8 +1927,8 @@ gen_intermediate_code_internal(CPUState * env, TranslationBlock * tb, max_insns = CF_COUNT_MASK; gen_icount_start(); while (ctx.bstate == BS_NONE && gen_opc_ptr < gen_opc_end) { - if (unlikely(!TAILQ_EMPTY(&env->breakpoints))) { - TAILQ_FOREACH(bp, &env->breakpoints, entry) { + if (unlikely(!QTAILQ_EMPTY(&env->breakpoints))) { + QTAILQ_FOREACH(bp, &env->breakpoints, entry) { if (ctx.pc == bp->pc) { /* We have hit a breakpoint - make sure PC is up-to-date */ tcg_gen_movi_i32(cpu_pc, ctx.pc); diff --git a/target-sparc/translate.c b/target-sparc/translate.c index 61578ecc3c..928aa61ad2 100644 --- a/target-sparc/translate.c +++ b/target-sparc/translate.c @@ -4706,8 +4706,8 @@ static inline void gen_intermediate_code_internal(TranslationBlock * tb, max_insns = CF_COUNT_MASK; gen_icount_start(); do { - if (unlikely(!TAILQ_EMPTY(&env->breakpoints))) { - TAILQ_FOREACH(bp, &env->breakpoints, entry) { + if (unlikely(!QTAILQ_EMPTY(&env->breakpoints))) { + QTAILQ_FOREACH(bp, &env->breakpoints, entry) { if (bp->pc == dc->pc) { if (dc->pc != pc_start) save_state(dc, cpu_cond); @@ -31,8 +31,6 @@ /* Needed early for CONFIG_BSD etc. */ #include "config-host.h" -/* Needed early to override system queue definitions on BSD */ -#include "sys-queue.h" #ifndef _WIN32 #include <libgen.h> @@ -168,6 +166,8 @@ int main(int argc, char **argv) #include "slirp/libslirp.h" +#include "qemu-queue.h" + //#define DEBUG_NET //#define DEBUG_SLIRP @@ -180,8 +180,8 @@ static const char *data_dir; const char *bios_name = NULL; /* Note: drives_table[MAX_DRIVES] is a dummy block driver if none available to store the VM snapshots */ -struct drivelist drives = TAILQ_HEAD_INITIALIZER(drives); -struct driveoptlist driveopts = TAILQ_HEAD_INITIALIZER(driveopts); +struct drivelist drives = QTAILQ_HEAD_INITIALIZER(drives); +struct driveoptlist driveopts = QTAILQ_HEAD_INITIALIZER(driveopts); enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB; static DisplayState *display_state; DisplayType display_type = DT_DEFAULT; @@ -1810,7 +1810,7 @@ DriveInfo *drive_get(BlockInterfaceType type, int bus, int unit) /* seek interface, bus and unit */ - TAILQ_FOREACH(dinfo, &drives, next) { + QTAILQ_FOREACH(dinfo, &drives, next) { if (dinfo->type == type && dinfo->bus == bus && dinfo->unit == unit) @@ -1824,7 +1824,7 @@ DriveInfo *drive_get_by_id(const char *id) { DriveInfo *dinfo; - TAILQ_FOREACH(dinfo, &drives, next) { + QTAILQ_FOREACH(dinfo, &drives, next) { if (strcmp(id, dinfo->id)) continue; return dinfo; @@ -1838,7 +1838,7 @@ int drive_get_max_bus(BlockInterfaceType type) DriveInfo *dinfo; max_bus = -1; - TAILQ_FOREACH(dinfo, &drives, next) { + QTAILQ_FOREACH(dinfo, &drives, next) { if(dinfo->type == type && dinfo->bus > max_bus) max_bus = dinfo->bus; @@ -1850,7 +1850,7 @@ const char *drive_get_serial(BlockDriverState *bdrv) { DriveInfo *dinfo; - TAILQ_FOREACH(dinfo, &drives, next) { + QTAILQ_FOREACH(dinfo, &drives, next) { if (dinfo->bdrv == bdrv) return dinfo->serial; } @@ -1862,7 +1862,7 @@ BlockInterfaceErrorAction drive_get_onerror(BlockDriverState *bdrv) { DriveInfo *dinfo; - TAILQ_FOREACH(dinfo, &drives, next) { + QTAILQ_FOREACH(dinfo, &drives, next) { if (dinfo->bdrv == bdrv) return dinfo->onerror; } @@ -1879,11 +1879,11 @@ void drive_uninit(BlockDriverState *bdrv) { DriveInfo *dinfo; - TAILQ_FOREACH(dinfo, &drives, next) { + QTAILQ_FOREACH(dinfo, &drives, next) { if (dinfo->bdrv != bdrv) continue; qemu_opts_del(dinfo->opts); - TAILQ_REMOVE(&drives, dinfo, next); + QTAILQ_REMOVE(&drives, dinfo, next); qemu_free(dinfo); break; } @@ -2170,7 +2170,7 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque, dinfo->opts = opts; if (serial) strncpy(dinfo->serial, serial, sizeof(serial)); - TAILQ_INSERT_TAIL(&drives, dinfo, next); + QTAILQ_INSERT_TAIL(&drives, dinfo, next); switch(type) { case IF_IDE: @@ -3145,10 +3145,10 @@ static void nographic_update(void *opaque) struct vm_change_state_entry { VMChangeStateHandler *cb; void *opaque; - LIST_ENTRY (vm_change_state_entry) entries; + QLIST_ENTRY (vm_change_state_entry) entries; }; -static LIST_HEAD(vm_change_state_head, vm_change_state_entry) vm_change_state_head; +static QLIST_HEAD(vm_change_state_head, vm_change_state_entry) vm_change_state_head; VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb, void *opaque) @@ -3159,13 +3159,13 @@ VMChangeStateEntry *qemu_add_vm_change_state_handler(VMChangeStateHandler *cb, e->cb = cb; e->opaque = opaque; - LIST_INSERT_HEAD(&vm_change_state_head, e, entries); + QLIST_INSERT_HEAD(&vm_change_state_head, e, entries); return e; } void qemu_del_vm_change_state_handler(VMChangeStateEntry *e) { - LIST_REMOVE (e, entries); + QLIST_REMOVE (e, entries); qemu_free (e); } @@ -3195,13 +3195,13 @@ void vm_start(void) /* reset/shutdown handler */ typedef struct QEMUResetEntry { - TAILQ_ENTRY(QEMUResetEntry) entry; + QTAILQ_ENTRY(QEMUResetEntry) entry; QEMUResetHandler *func; void *opaque; } QEMUResetEntry; -static TAILQ_HEAD(reset_handlers, QEMUResetEntry) reset_handlers = - TAILQ_HEAD_INITIALIZER(reset_handlers); +static QTAILQ_HEAD(reset_handlers, QEMUResetEntry) reset_handlers = + QTAILQ_HEAD_INITIALIZER(reset_handlers); static int reset_requested; static int shutdown_requested; static int powerdown_requested; @@ -3259,16 +3259,16 @@ void qemu_register_reset(QEMUResetHandler *func, void *opaque) re->func = func; re->opaque = opaque; - TAILQ_INSERT_TAIL(&reset_handlers, re, entry); + QTAILQ_INSERT_TAIL(&reset_handlers, re, entry); } void qemu_unregister_reset(QEMUResetHandler *func, void *opaque) { QEMUResetEntry *re; - TAILQ_FOREACH(re, &reset_handlers, entry) { + QTAILQ_FOREACH(re, &reset_handlers, entry) { if (re->func == func && re->opaque == opaque) { - TAILQ_REMOVE(&reset_handlers, re, entry); + QTAILQ_REMOVE(&reset_handlers, re, entry); qemu_free(re); return; } @@ -3280,7 +3280,7 @@ void qemu_system_reset(void) QEMUResetEntry *re, *nre; /* reset all devices */ - TAILQ_FOREACH_SAFE(re, &reset_handlers, entry, nre) { + QTAILQ_FOREACH_SAFE(re, &reset_handlers, entry, nre) { re->func(re->opaque); } } @@ -4579,9 +4579,9 @@ struct device_config { DEV_BT, /* -bt */ } type; const char *cmdline; - TAILQ_ENTRY(device_config) next; + QTAILQ_ENTRY(device_config) next; }; -TAILQ_HEAD(, device_config) device_configs = TAILQ_HEAD_INITIALIZER(device_configs); +QTAILQ_HEAD(, device_config) device_configs = QTAILQ_HEAD_INITIALIZER(device_configs); static void add_device_config(int type, const char *cmdline) { @@ -4590,7 +4590,7 @@ static void add_device_config(int type, const char *cmdline) conf = qemu_mallocz(sizeof(*conf)); conf->type = type; conf->cmdline = cmdline; - TAILQ_INSERT_TAIL(&device_configs, conf, next); + QTAILQ_INSERT_TAIL(&device_configs, conf, next); } static int foreach_device_config(int type, int (*func)(const char *cmdline)) @@ -4598,7 +4598,7 @@ static int foreach_device_config(int type, int (*func)(const char *cmdline)) struct device_config *conf; int rc; - TAILQ_FOREACH(conf, &device_configs, next) { + QTAILQ_FOREACH(conf, &device_configs, next) { if (conf->type != type) continue; rc = func(conf->cmdline); @@ -4655,7 +4655,7 @@ int main(int argc, char **argv, char **envp) qemu_errors_to_file(stderr); qemu_cache_utils_init(envp); - LIST_INIT (&vm_change_state_head); + QLIST_INIT (&vm_change_state_head); #ifndef _WIN32 { struct sigaction act; |