ia64/xen-unstable

changeset 16997:45b2e7d59e3a

ioemu: avoid name clashes due to LIST_* macros

Here is what I wrote in my submission to qemu upstream:

qemu's audio subdirectory contains a copy of BSD's sys-queue.h, which
defines a bunch of LIST_ macros. This makes it difficult to build a
program made partly out of qemu and partly out of the Linux
kernel[1], since Linux has a different set of LIST_ macros. It might
also cause trouble when mixing with BSD-derived code.

Under the circumstances it's probably best to rename the versions in
qemu. The attached patch does this.

[1] You might well ask why anyone would want to do this. In Xen we
are moving our emulation of IO devices from processes which run on
the host into a dedicated VM (one per actual VM) which we call a
`stub domain'. This dedicated VM runs a very cut-down `operating
system' which uses some code from Linux.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Feb 07 09:21:19 2008 +0000 (2008-02-07)
parents 3821e39cc1a0
children d04593aa1605
files tools/ioemu/audio/audio.c tools/ioemu/audio/audio.h tools/ioemu/audio/audio_int.h tools/ioemu/audio/audio_template.h tools/ioemu/audio/sys-queue.h
line diff
     1.1 --- a/tools/ioemu/audio/audio.c	Thu Feb 07 09:19:12 2008 +0000
     1.2 +++ b/tools/ioemu/audio/audio.c	Thu Feb 07 09:21:19 2008 +0000
     1.3 @@ -707,8 +707,8 @@ static void audio_detach_capture (HWVoic
     1.4              sw->rate = NULL;
     1.5          }
     1.6  
     1.7 -        LIST_REMOVE (sw, entries);
     1.8 -        LIST_REMOVE (sc, entries);
     1.9 +        QEMU_LIST_REMOVE (sw, entries);
    1.10 +        QEMU_LIST_REMOVE (sc, entries);
    1.11          qemu_free (sc);
    1.12          if (was_active) {
    1.13              /* We have removed soft voice from the capture:
    1.14 @@ -751,8 +751,8 @@ static int audio_attach_capture (AudioSt
    1.15              qemu_free (sw);
    1.16              return -1;
    1.17          }
    1.18 -        LIST_INSERT_HEAD (&hw_cap->sw_head, sw, entries);
    1.19 -        LIST_INSERT_HEAD (&hw->cap_head, sc, entries);
    1.20 +        QEMU_LIST_INSERT_HEAD (&hw_cap->sw_head, sw, entries);
    1.21 +        QEMU_LIST_INSERT_HEAD (&hw->cap_head, sc, entries);
    1.22  #ifdef DEBUG_CAPTURE
    1.23          asprintf (&sw->name, "for %p %d,%d,%d",
    1.24                    hw, sw->info.freq, sw->info.bits, sw->info.nchannels);
    1.25 @@ -1620,12 +1620,12 @@ void AUD_register_card (AudioState *s, c
    1.26      card->audio = s;
    1.27      card->name = qemu_strdup (name);
    1.28      memset (&card->entries, 0, sizeof (card->entries));
    1.29 -    LIST_INSERT_HEAD (&s->card_head, card, entries);
    1.30 +    QEMU_LIST_INSERT_HEAD (&s->card_head, card, entries);
    1.31  }
    1.32  
    1.33  void AUD_remove_card (QEMUSoundCard *card)
    1.34  {
    1.35 -    LIST_REMOVE (card, entries);
    1.36 +    QEMU_LIST_REMOVE (card, entries);
    1.37      card->audio = NULL;
    1.38      qemu_free (card->name);
    1.39  }
    1.40 @@ -1637,9 +1637,9 @@ AudioState *AUD_init (void)
    1.41      const char *drvname;
    1.42      AudioState *s = &glob_audio_state;
    1.43  
    1.44 -    LIST_INIT (&s->hw_head_out);
    1.45 -    LIST_INIT (&s->hw_head_in);
    1.46 -    LIST_INIT (&s->cap_head);
    1.47 +    QEMU_LIST_INIT (&s->hw_head_out);
    1.48 +    QEMU_LIST_INIT (&s->hw_head_in);
    1.49 +    QEMU_LIST_INIT (&s->cap_head);
    1.50      atexit (audio_atexit);
    1.51  
    1.52      s->ts = qemu_new_timer (vm_clock, audio_timer, s);
    1.53 @@ -1731,7 +1731,7 @@ AudioState *AUD_init (void)
    1.54          return NULL;
    1.55      }
    1.56  
    1.57 -    LIST_INIT (&s->card_head);
    1.58 +    QEMU_LIST_INIT (&s->card_head);
    1.59      register_savevm ("audio", 0, 1, audio_save, audio_load, s);
    1.60      qemu_mod_timer (s->ts, qemu_get_clock (vm_clock) + conf.period.ticks);
    1.61      return s;
    1.62 @@ -1769,7 +1769,7 @@ CaptureVoiceOut *AUD_add_capture (
    1.63  
    1.64      cap = audio_pcm_capture_find_specific (s, as);
    1.65      if (cap) {
    1.66 -        LIST_INSERT_HEAD (&cap->cb_head, cb, entries);
    1.67 +        QEMU_LIST_INSERT_HEAD (&cap->cb_head, cb, entries);
    1.68          return cap;
    1.69      }
    1.70      else {
    1.71 @@ -1784,8 +1784,8 @@ CaptureVoiceOut *AUD_add_capture (
    1.72          }
    1.73  
    1.74          hw = &cap->hw;
    1.75 -        LIST_INIT (&hw->sw_head);
    1.76 -        LIST_INIT (&cap->cb_head);
    1.77 +        QEMU_LIST_INIT (&hw->sw_head);
    1.78 +        QEMU_LIST_INIT (&cap->cb_head);
    1.79  
    1.80          /* XXX find a more elegant way */
    1.81          hw->samples = 4096 * 4;
    1.82 @@ -1813,8 +1813,8 @@ CaptureVoiceOut *AUD_add_capture (
    1.83              [hw->info.swap_endianness]
    1.84              [hw->info.bits == 16];
    1.85  
    1.86 -        LIST_INSERT_HEAD (&s->cap_head, cap, entries);
    1.87 -        LIST_INSERT_HEAD (&cap->cb_head, cb, entries);
    1.88 +        QEMU_LIST_INSERT_HEAD (&s->cap_head, cap, entries);
    1.89 +        QEMU_LIST_INSERT_HEAD (&cap->cb_head, cb, entries);
    1.90  
    1.91          hw = NULL;
    1.92          while ((hw = audio_pcm_hw_find_any_out (s, hw))) {
    1.93 @@ -1840,7 +1840,7 @@ void AUD_del_capture (CaptureVoiceOut *c
    1.94      for (cb = cap->cb_head.lh_first; cb; cb = cb->entries.le_next) {
    1.95          if (cb->opaque == cb_opaque) {
    1.96              cb->ops.destroy (cb_opaque);
    1.97 -            LIST_REMOVE (cb, entries);
    1.98 +            QEMU_LIST_REMOVE (cb, entries);
    1.99              qemu_free (cb);
   1.100  
   1.101              if (!cap->cb_head.lh_first) {
   1.102 @@ -1857,12 +1857,12 @@ void AUD_del_capture (CaptureVoiceOut *c
   1.103                          st_rate_stop (sw->rate);
   1.104                          sw->rate = NULL;
   1.105                      }
   1.106 -                    LIST_REMOVE (sw, entries);
   1.107 -                    LIST_REMOVE (sc, entries);
   1.108 +                    QEMU_LIST_REMOVE (sw, entries);
   1.109 +                    QEMU_LIST_REMOVE (sc, entries);
   1.110                      qemu_free (sc);
   1.111                      sw = sw1;
   1.112                  }
   1.113 -                LIST_REMOVE (cap, entries);
   1.114 +                QEMU_LIST_REMOVE (cap, entries);
   1.115                  qemu_free (cap);
   1.116              }
   1.117              return;
     2.1 --- a/tools/ioemu/audio/audio.h	Thu Feb 07 09:19:12 2008 +0000
     2.2 +++ b/tools/ioemu/audio/audio.h	Thu Feb 07 09:21:19 2008 +0000
     2.3 @@ -68,7 +68,7 @@ struct capture_ops {
     2.4  typedef struct CaptureState {
     2.5      void *opaque;
     2.6      struct capture_ops ops;
     2.7 -    LIST_ENTRY (CaptureState) entries;
     2.8 +    QEMU_LIST_ENTRY (CaptureState) entries;
     2.9  } CaptureState;
    2.10  
    2.11  typedef struct AudioState AudioState;
    2.12 @@ -79,7 +79,7 @@ typedef struct SWVoiceIn SWVoiceIn;
    2.13  typedef struct QEMUSoundCard {
    2.14      AudioState *audio;
    2.15      char *name;
    2.16 -    LIST_ENTRY (QEMUSoundCard) entries;
    2.17 +    QEMU_LIST_ENTRY (QEMUSoundCard) entries;
    2.18  } QEMUSoundCard;
    2.19  
    2.20  typedef struct QEMUAudioTimeStamp {
     3.1 --- a/tools/ioemu/audio/audio_int.h	Thu Feb 07 09:19:12 2008 +0000
     3.2 +++ b/tools/ioemu/audio/audio_int.h	Thu Feb 07 09:21:19 2008 +0000
     3.3 @@ -79,10 +79,10 @@ typedef struct HWVoiceOut {
     3.4      st_sample_t *mix_buf;
     3.5  
     3.6      int samples;
     3.7 -    LIST_HEAD (sw_out_listhead, SWVoiceOut) sw_head;
     3.8 -    LIST_HEAD (sw_cap_listhead, SWVoiceCap) cap_head;
     3.9 +    QEMU_LIST_HEAD (sw_out_listhead, SWVoiceOut) sw_head;
    3.10 +    QEMU_LIST_HEAD (sw_cap_listhead, SWVoiceCap) cap_head;
    3.11      struct audio_pcm_ops *pcm_ops;
    3.12 -    LIST_ENTRY (HWVoiceOut) entries;
    3.13 +    QEMU_LIST_ENTRY (HWVoiceOut) entries;
    3.14  } HWVoiceOut;
    3.15  
    3.16  typedef struct HWVoiceIn {
    3.17 @@ -98,9 +98,9 @@ typedef struct HWVoiceIn {
    3.18      st_sample_t *conv_buf;
    3.19  
    3.20      int samples;
    3.21 -    LIST_HEAD (sw_in_listhead, SWVoiceIn) sw_head;
    3.22 +    QEMU_LIST_HEAD (sw_in_listhead, SWVoiceIn) sw_head;
    3.23      struct audio_pcm_ops *pcm_ops;
    3.24 -    LIST_ENTRY (HWVoiceIn) entries;
    3.25 +    QEMU_LIST_ENTRY (HWVoiceIn) entries;
    3.26  } HWVoiceIn;
    3.27  
    3.28  struct SWVoiceOut {
    3.29 @@ -116,7 +116,7 @@ struct SWVoiceOut {
    3.30      char *name;
    3.31      volume_t vol;
    3.32      struct audio_callback callback;
    3.33 -    LIST_ENTRY (SWVoiceOut) entries;
    3.34 +    QEMU_LIST_ENTRY (SWVoiceOut) entries;
    3.35  };
    3.36  
    3.37  struct SWVoiceIn {
    3.38 @@ -131,7 +131,7 @@ struct SWVoiceIn {
    3.39      char *name;
    3.40      volume_t vol;
    3.41      struct audio_callback callback;
    3.42 -    LIST_ENTRY (SWVoiceIn) entries;
    3.43 +    QEMU_LIST_ENTRY (SWVoiceIn) entries;
    3.44  };
    3.45  
    3.46  struct audio_driver {
    3.47 @@ -165,20 +165,20 @@ struct audio_pcm_ops {
    3.48  struct capture_callback {
    3.49      struct audio_capture_ops ops;
    3.50      void *opaque;
    3.51 -    LIST_ENTRY (capture_callback) entries;
    3.52 +    QEMU_LIST_ENTRY (capture_callback) entries;
    3.53  };
    3.54  
    3.55  struct CaptureVoiceOut {
    3.56      HWVoiceOut hw;
    3.57      void *buf;
    3.58 -    LIST_HEAD (cb_listhead, capture_callback) cb_head;
    3.59 -    LIST_ENTRY (CaptureVoiceOut) entries;
    3.60 +    QEMU_LIST_HEAD (cb_listhead, capture_callback) cb_head;
    3.61 +    QEMU_LIST_ENTRY (CaptureVoiceOut) entries;
    3.62  };
    3.63  
    3.64  struct SWVoiceCap {
    3.65      SWVoiceOut sw;
    3.66      CaptureVoiceOut *cap;
    3.67 -    LIST_ENTRY (SWVoiceCap) entries;
    3.68 +    QEMU_LIST_ENTRY (SWVoiceCap) entries;
    3.69  };
    3.70  
    3.71  struct AudioState {
    3.72 @@ -186,10 +186,10 @@ struct AudioState {
    3.73      void *drv_opaque;
    3.74  
    3.75      QEMUTimer *ts;
    3.76 -    LIST_HEAD (card_listhead, QEMUSoundCard) card_head;
    3.77 -    LIST_HEAD (hw_in_listhead, HWVoiceIn) hw_head_in;
    3.78 -    LIST_HEAD (hw_out_listhead, HWVoiceOut) hw_head_out;
    3.79 -    LIST_HEAD (cap_listhead, CaptureVoiceOut) cap_head;
    3.80 +    QEMU_LIST_HEAD (card_listhead, QEMUSoundCard) card_head;
    3.81 +    QEMU_LIST_HEAD (hw_in_listhead, HWVoiceIn) hw_head_in;
    3.82 +    QEMU_LIST_HEAD (hw_out_listhead, HWVoiceOut) hw_head_out;
    3.83 +    QEMU_LIST_HEAD (cap_listhead, CaptureVoiceOut) cap_head;
    3.84      int nb_hw_voices_out;
    3.85      int nb_hw_voices_in;
    3.86  };
     4.1 --- a/tools/ioemu/audio/audio_template.h	Thu Feb 07 09:19:12 2008 +0000
     4.2 +++ b/tools/ioemu/audio/audio_template.h	Thu Feb 07 09:21:19 2008 +0000
     4.3 @@ -186,12 +186,12 @@ static void glue (audio_pcm_sw_fini_, TY
     4.4  
     4.5  static void glue (audio_pcm_hw_add_sw_, TYPE) (HW *hw, SW *sw)
     4.6  {
     4.7 -    LIST_INSERT_HEAD (&hw->sw_head, sw, entries);
     4.8 +    QEMU_LIST_INSERT_HEAD (&hw->sw_head, sw, entries);
     4.9  }
    4.10  
    4.11  static void glue (audio_pcm_hw_del_sw_, TYPE) (SW *sw)
    4.12  {
    4.13 -    LIST_REMOVE (sw, entries);
    4.14 +    QEMU_LIST_REMOVE (sw, entries);
    4.15  }
    4.16  
    4.17  static void glue (audio_pcm_hw_gc_, TYPE) (AudioState *s, HW **hwp)
    4.18 @@ -202,7 +202,7 @@ static void glue (audio_pcm_hw_gc_, TYPE
    4.19  #ifdef DAC
    4.20          audio_detach_capture (hw);
    4.21  #endif
    4.22 -        LIST_REMOVE (hw, entries);
    4.23 +        QEMU_LIST_REMOVE (hw, entries);
    4.24          glue (s->nb_hw_voices_, TYPE) += 1;
    4.25          glue (audio_pcm_hw_free_resources_ ,TYPE) (hw);
    4.26          glue (hw->pcm_ops->fini_, TYPE) (hw);
    4.27 @@ -267,9 +267,9 @@ static HW *glue (audio_pcm_hw_add_new_, 
    4.28      }
    4.29  
    4.30      hw->pcm_ops = drv->pcm_ops;
    4.31 -    LIST_INIT (&hw->sw_head);
    4.32 +    QEMU_LIST_INIT (&hw->sw_head);
    4.33  #ifdef DAC
    4.34 -    LIST_INIT (&hw->cap_head);
    4.35 +    QEMU_LIST_INIT (&hw->cap_head);
    4.36  #endif
    4.37      if (glue (hw->pcm_ops->init_, TYPE) (hw, as)) {
    4.38          goto err0;
    4.39 @@ -294,7 +294,7 @@ static HW *glue (audio_pcm_hw_add_new_, 
    4.40          goto err1;
    4.41      }
    4.42  
    4.43 -    LIST_INSERT_HEAD (&s->glue (hw_head_, TYPE), hw, entries);
    4.44 +    QEMU_LIST_INSERT_HEAD (&s->glue (hw_head_, TYPE), hw, entries);
    4.45      glue (s->nb_hw_voices_, TYPE) -= 1;
    4.46  #ifdef DAC
    4.47      audio_attach_capture (s, hw);
     5.1 --- a/tools/ioemu/audio/sys-queue.h	Thu Feb 07 09:19:12 2008 +0000
     5.2 +++ b/tools/ioemu/audio/sys-queue.h	Thu Feb 07 09:21:19 2008 +0000
     5.3 @@ -64,12 +64,12 @@
     5.4  /*
     5.5   * List definitions.
     5.6   */
     5.7 -#define LIST_HEAD(name, type)						\
     5.8 +#define QEMU_LIST_HEAD(name, type)					\
     5.9  struct name {								\
    5.10  	struct type *lh_first;	/* first element */			\
    5.11  }
    5.12  
    5.13 -#define LIST_ENTRY(type)						\
    5.14 +#define QEMU_LIST_ENTRY(type)						\
    5.15  struct {								\
    5.16  	struct type *le_next;	/* next element */			\
    5.17  	struct type **le_prev;	/* address of previous next element */	\
    5.18 @@ -78,11 +78,11 @@ struct {								\
    5.19  /*
    5.20   * List functions.
    5.21   */
    5.22 -#define	LIST_INIT(head) {						\
    5.23 +#define	QEMU_LIST_INIT(head) {						\
    5.24  	(head)->lh_first = NULL;					\
    5.25  }
    5.26  
    5.27 -#define LIST_INSERT_AFTER(listelm, elm, field) {			\
    5.28 +#define QEMU_LIST_INSERT_AFTER(listelm, elm, field) {			\
    5.29  	if (((elm)->field.le_next = (listelm)->field.le_next) != NULL)	\
    5.30  		(listelm)->field.le_next->field.le_prev =		\
    5.31  		    &(elm)->field.le_next;				\
    5.32 @@ -90,14 +90,14 @@ struct {								\
    5.33  	(elm)->field.le_prev = &(listelm)->field.le_next;		\
    5.34  }
    5.35  
    5.36 -#define LIST_INSERT_HEAD(head, elm, field) {				\
    5.37 +#define QEMU_LIST_INSERT_HEAD(head, elm, field) {			\
    5.38  	if (((elm)->field.le_next = (head)->lh_first) != NULL)		\
    5.39  		(head)->lh_first->field.le_prev = &(elm)->field.le_next;\
    5.40  	(head)->lh_first = (elm);					\
    5.41  	(elm)->field.le_prev = &(head)->lh_first;			\
    5.42  }
    5.43  
    5.44 -#define LIST_REMOVE(elm, field) {					\
    5.45 +#define QEMU_LIST_REMOVE(elm, field) {					\
    5.46  	if ((elm)->field.le_next != NULL)				\
    5.47  		(elm)->field.le_next->field.le_prev = 			\
    5.48  		    (elm)->field.le_prev;				\