From: "Michael S. Tsirkin" <mst@redhat.com>
To: Anthony Liguori <aliguori@us.ibm.com>
Cc: kvm@vger.kernel.org, Avi Kivity <avi@redhat.com>,
Dustin Kirkland <kirkland@canonical.com>
Subject: Re: [PATCH] Fix non-KVM build
Date: Wed, 15 Jul 2009 20:53:12 +0300 [thread overview]
Message-ID: <20090715175312.GH9642@redhat.com> (raw)
In-Reply-To: <1245867226-30604-1-git-send-email-aliguori@us.ibm.com>
On Wed, Jun 24, 2009 at 01:13:46PM -0500, Anthony Liguori wrote:
> This introduces some #ifdefs in pcspk to fix the build when KVM isn't enabled.
>
> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
> ---
> hw/pcspk.c | 15 +++++++++------
> 1 files changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/hw/pcspk.c b/hw/pcspk.c
> index 9e1b59a..236995a 100644
> --- a/hw/pcspk.c
> +++ b/hw/pcspk.c
> @@ -80,11 +80,6 @@ static void kvm_set_pit_ch2(PITState *pit,
> kvm_set_pit(kvm_context, inkernel_state);
> }
> }
> -#else
> -static inline void kvm_get_pit_ch2(PITState *pit,
> - kvm_pit_state *inkernel_state) { }
> -static inline void kvm_set_pit_ch2(PITState *pit,
> - kvm_pit_state *inkernel_state) { }
> #endif
>
The version with stubs looks cleaner to me. IMO we really should be
moving away from ifdefs for features, and only use them for
compiler-specific things. If for no other reason, then because it
increases the common code that is compiled for all platforms,
decreasing the chance that people submit a patch that does not
build on soe platform.
Is the issue with struct kvm_pit_state?
Can't we just stub it out as well?
struct kvm_pit_state {};
> static inline void generate_samples(PCSpkState *s)
> @@ -111,7 +106,9 @@ static void pcspk_callback(void *opaque, int free)
> PCSpkState *s = opaque;
> unsigned int n;
>
> +#ifdef USE_KVM_PIT
> kvm_get_pit_ch2(s->pit, NULL);
> +#endif
>
> if (pit_get_mode(s->pit, 2) != 3)
> return;
> @@ -158,7 +155,9 @@ static uint32_t pcspk_ioport_read(void *opaque, uint32_t addr)
> PCSpkState *s = opaque;
> int out;
>
> +#ifdef USE_KVM_PIT
> kvm_get_pit_ch2(s->pit, NULL);
> +#endif
>
> s->dummy_refresh_clock ^= (1 << 4);
> out = pit_get_out(s->pit, 2, qemu_get_clock(vm_clock)) << 5;
> @@ -168,11 +167,13 @@ static uint32_t pcspk_ioport_read(void *opaque, uint32_t addr)
>
> static void pcspk_ioport_write(void *opaque, uint32_t addr, uint32_t val)
> {
> - struct kvm_pit_state inkernel_state;
> PCSpkState *s = opaque;
> const int gate = val & 1;
> +#ifdef USE_KVM_PIT
> + struct kvm_pit_state inkernel_state;
>
> kvm_get_pit_ch2(s->pit, &inkernel_state);
> +#endif
>
> s->data_on = (val >> 1) & 1;
> pit_set_gate(s->pit, 2, gate);
> @@ -182,7 +183,9 @@ static void pcspk_ioport_write(void *opaque, uint32_t addr, uint32_t val)
> AUD_set_active_out(s->voice, gate & s->data_on);
> }
>
> +#ifdef USE_KVM_PIT
> kvm_set_pit_ch2(s->pit, &inkernel_state);
> +#endif
> }
>
> void pcspk_init(PITState *pit)
> --
> 1.6.2.5
>
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2009-07-15 17:54 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-24 18:13 [PATCH] Fix non-KVM build Anthony Liguori
2009-06-24 19:17 ` Dustin Kirkland
2009-07-15 17:53 ` Michael S. Tsirkin [this message]
2009-07-16 8:54 ` Jan Kiszka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090715175312.GH9642@redhat.com \
--to=mst@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=avi@redhat.com \
--cc=kirkland@canonical.com \
--cc=kvm@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.