qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Amit Shah <amit.shah@redhat.com>
To: Andre Przywara <andre.przywara@amd.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 09/12] cpuid: simplify CPUID flag search function
Date: Fri, 11 Sep 2009 13:25:00 +0530	[thread overview]
Message-ID: <20090911075500.GE31399@amit-x200.redhat.com> (raw)
In-Reply-To: <1252621257-26364-10-git-send-email-andre.przywara@amd.com>

On (Fri) Sep 11 2009 [00:20:54], Andre Przywara wrote:
> avoid code duplication and handle the CPUID flag name search in a
> loop.
> 
> Signed-off-by: Andre Przywara <andre.przywara@amd.com>
> ---
>  target-i386/cpuid.c |   33 +++++++++++++--------------------
>  1 files changed, 13 insertions(+), 20 deletions(-)
> 
> diff --git a/target-i386/cpuid.c b/target-i386/cpuid.c
> index e62dc04..4be1449 100644
> --- a/target-i386/cpuid.c
> +++ b/target-i386/cpuid.c
> @@ -71,29 +71,22 @@ static void add_flagname_to_bitmaps(const char *flagname, uint32_t *features,
>                                      uint32_t *ext2_features,
>                                      uint32_t *ext3_features)
>  {
> -    int i;
> +    int i, j;
>      int found = 0;
> +    const char ** feature_names[4] = {feature_name, ext_feature_name,
> +        ext2_feature_name, ext3_feature_name};
> +    uint32_t* feature_flags[4] = {features, ext_features,
> +        ext2_features, ext3_features};
>  
> -    for ( i = 0 ; i < 32 ; i++ )
> -        if (feature_name[i] && !strcmp (flagname, feature_name[i])) {
> -            *features |= 1 << i;
> -            found = 1;
> -        }
> -    for ( i = 0 ; i < 32 ; i++ )
> -        if (ext_feature_name[i] && !strcmp (flagname, ext_feature_name[i])) {
> -            *ext_features |= 1 << i;
> -            found = 1;
> -        }
> -    for ( i = 0 ; i < 32 ; i++ )
> -        if (ext2_feature_name[i] && !strcmp (flagname, ext2_feature_name[i])) {
> -            *ext2_features |= 1 << i;
> -            found = 1;
> -        }
> -    for ( i = 0 ; i < 32 ; i++ )
> -        if (ext3_feature_name[i] && !strcmp (flagname, ext3_feature_name[i])) {
> -            *ext3_features |= 1 << i;
> -            found = 1;
> +    for (j = 0; j < 4; j++) {
> +        for (i = 0; i < 32; i++) {
> +            if (feature_names[j][i] &&
> +                !strcmp(flagname, feature_names[j][i])) {
> +                *feature_flags[j] |= 1 << i;
> +                found = 1;
> +            }
>          }
> +    }
>      if (!found) {
>          fprintf(stderr, "CPU feature %s not found\n", flagname);
>      }

This just reports the entire string, right? Not just the feature as the
printf suggests.

		Amit

  reply	other threads:[~2009-09-11  7:55 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-10 22:20 [Qemu-devel] [PATCH 0/12] cpuid: cleanup and some enhancements Andre Przywara
2009-09-10 22:20 ` [Qemu-devel] [PATCH 01/12] cpuid: move CPUID functions into separate file Andre Przywara
2009-09-10 22:20 ` [Qemu-devel] [PATCH 02/12] cpuid: fix over-long lines Andre Przywara
2009-09-10 22:20 ` [Qemu-devel] [PATCH 03/12] cpuid: replace magic number with named constant Andre Przywara
2009-09-10 22:20 ` [Qemu-devel] [PATCH 04/12] cpuid: fix comments Andre Przywara
2009-09-10 22:20 ` [Qemu-devel] [PATCH 05/12] cpuid: moved host_cpuid function and remove prototype Andre Przywara
2009-09-10 22:20 ` [Qemu-devel] [PATCH 06/12] cpuid: add missing CPUID feature flag names Andre Przywara
2009-09-10 22:20 ` [Qemu-devel] [PATCH 07/12] cpuid: list all known x86 CPUID feature flags Andre Przywara
2009-09-10 22:20 ` [Qemu-devel] [PATCH 08/12] cpuid: remove unnecessary kvm_trim function Andre Przywara
2009-09-10 22:20 ` [Qemu-devel] [PATCH 09/12] cpuid: simplify CPUID flag search function Andre Przywara
2009-09-11  7:55   ` Amit Shah [this message]
2009-09-11 19:30     ` Andre Przywara
2009-09-14  7:23       ` Amit Shah
2009-09-10 22:20 ` [Qemu-devel] [PATCH 10/12] cpuid: propagate further CPUID leafs when -cpu host Andre Przywara
2009-09-10 22:20 ` [Qemu-devel] [PATCH 11/12] cpuid: add TCG feature bit trimming Andre Przywara
2009-09-10 22:20 ` [Qemu-devel] [PATCH 12/12] cpuid: decrease L2 cache for Intel and add comments Andre Przywara
2009-09-11  7:55 ` [Qemu-devel] [PATCH 0/12] cpuid: cleanup and some enhancements Amit Shah
2009-09-14 17:08 ` Anthony Liguori

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=20090911075500.GE31399@amit-x200.redhat.com \
    --to=amit.shah@redhat.com \
    --cc=andre.przywara@amd.com \
    --cc=qemu-devel@nongnu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).