[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 10/21] cpuid: simplify CPUID flag search function
From: |
Andre Przywara |
Subject: |
[Qemu-devel] [PATCH v2 10/21] cpuid: simplify CPUID flag search function |
Date: |
Fri, 18 Sep 2009 13:48:03 +0200 |
avoid code duplication and handle the CPUID flag name search in a
loop.
Signed-off-by: Andre Przywara <address@hidden>
---
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 8243f44..9fdaa6c 100644
--- a/target-i386/cpuid.c
+++ b/target-i386/cpuid.c
@@ -84,29 +84,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);
}
--
1.6.1.3
- [Qemu-devel] [PATCH v2 00/21] cpuid: cleanup, fixes and some enhancements, Andre Przywara, 2009/09/18
- [Qemu-devel] [PATCH v2 04/21] cpuid: fix comments, Andre Przywara, 2009/09/18
- [Qemu-devel] [PATCH v2 06/21] cpuid: Replace strtok with get_opt_name, Andre Przywara, 2009/09/18
- [Qemu-devel] [PATCH v2 02/21] cpuid: fix over-long lines, Andre Przywara, 2009/09/18
- [Qemu-devel] [PATCH v2 07/21] cpuid: add missing CPUID feature flag names, Andre Przywara, 2009/09/18
- [Qemu-devel] [PATCH v2 10/21] cpuid: simplify CPUID flag search function,
Andre Przywara <=
- [Qemu-devel] [PATCH v2 09/21] cpuid: remove unnecessary kvm_trim function, Andre Przywara, 2009/09/18
- [Qemu-devel] [PATCH v2 13/21] cpuid: add TCG feature bit trimming, Andre Przywara, 2009/09/18
- [Qemu-devel] [PATCH v2 08/21] cpuid: list all known x86 CPUID feature flags, Andre Przywara, 2009/09/18
- [Qemu-devel] [PATCH v2 15/21] cpuid: Adjust feature bit constants, Andre Przywara, 2009/09/18
- [Qemu-devel] [PATCH v2 16/21] cpuid: Update qemu64/32 CPU models, Andre Przywara, 2009/09/18
- [Qemu-devel] [PATCH v2 14/21] cpuid: decrease L2 cache for Intel and add comments, Andre Przywara, 2009/09/18
- [Qemu-devel] [PATCH v2 01/21] cpuid: move CPUID functions into separate file, Andre Przywara, 2009/09/18
- [Qemu-devel] [PATCH v2 20/21] cpuid: Add kvm32 CPU model, Andre Przywara, 2009/09/18
- [Qemu-devel] [PATCH v2 12/21] cpuid: Fix multicore setup on Intel, Andre Przywara, 2009/09/18
- [Qemu-devel] [PATCH v2 05/21] cpuid: moved host_cpuid function and remove prototype, Andre Przywara, 2009/09/18