Skip to content

Commit

Permalink
Fix sys-queue.h conflict for good
Browse files Browse the repository at this point in the history
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 15cc923,
f40d753,
96555a9 and
3990d09 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>
  • Loading branch information
blueswirl committed Sep 12, 2009
1 parent 620150d commit 72cf2d4
Show file tree
Hide file tree
Showing 65 changed files with 481 additions and 488 deletions.
18 changes: 9 additions & 9 deletions acl.c
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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);
}
Expand All @@ -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;
Expand All @@ -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;
}
Expand All @@ -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;
}
}
Expand Down
6 changes: 3 additions & 3 deletions acl.h
Expand Up @@ -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;
Expand All @@ -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;
};

Expand Down
22 changes: 11 additions & 11 deletions aio.c
Expand Up @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
}
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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.
Expand Down Expand Up @@ -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;

Expand All @@ -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);
}
}
Expand Down
38 changes: 19 additions & 19 deletions audio/audio.c
Expand Up @@ -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:
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand Down Expand Up @@ -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 {
Expand All @@ -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;
Expand Down Expand Up @@ -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))) {
Expand All @@ -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) {
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions audio/audio.h
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand All @@ -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 {
Expand Down

0 comments on commit 72cf2d4

Please sign in to comment.