From 1bf0791db87b9e616f12c74328dbc6648ee2ea14 Mon Sep 17 00:00:00 2001 From: Florian Krohm Date: Thu, 30 Aug 2012 18:47:56 +0000 Subject: [PATCH] Add FAC_BIT macro to simplify correct testing for facility bits. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@12919 --- tests/s390x_features.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/tests/s390x_features.c b/tests/s390x_features.c index 837d83eda..36305fadd 100644 --- a/tests/s390x_features.c +++ b/tests/s390x_features.c @@ -190,6 +190,11 @@ static model_info *get_host(void) return model; } + +/* Convenience macro that maps the facility bit number as given in the + Principles of Ops "facility indications" section to a bit mask */ +#define FAC_BIT(x) (1ULL << (63 - (x))) + static int go(char *feature, char *cpu) { unsigned long long facilities; @@ -200,25 +205,25 @@ static int go(char *feature, char *cpu) facilities = stfle(); if (strcmp(feature, "s390x-zarch") == 0 ) { - match = (facilities & (1ULL << 62) && (facilities & (1ULL << 61))); + match = (facilities & FAC_BIT(1)) && (facilities & FAC_BIT(2)); } else if (strcmp(feature, "s390x-n3") == 0 ) { - match = (facilities & (1ULL << 63)); + match = facilities & FAC_BIT(0); } else if (strcmp(feature, "s390x-stfle") == 0 ) { - match = (facilities & (1ULL << 56)); + match = facilities & FAC_BIT(7); } else if (strcmp(feature, "s390x-ldisp") == 0 ) { - match = (facilities & (1ULL << 45) && (facilities & (1ULL << 44))); + match = (facilities & FAC_BIT(18)) && (facilities & FAC_BIT(19)); } else if (strcmp(feature, "s390x-eimm") == 0 ) { - match = (facilities & (1ULL << 42)); + match = facilities & FAC_BIT(21); } else if (strcmp(feature, "s390x-stckf") == 0 ) { - match = (facilities & (1ULL << 38)); + match = facilities & FAC_BIT(25); } else if (strcmp(feature, "s390x-genins") == 0 ) { - match = (facilities & (1ULL << 29)); + match = facilities & FAC_BIT(34); } else if (strcmp(feature, "s390x-exrl") == 0 ) { - match = (facilities & (1ULL << 28)); + match = facilities & FAC_BIT(35); } else if (strcmp(feature, "s390x-etf3") == 0 ) { - match = (facilities & (1ULL << (63 - 30))); + match = facilities & FAC_BIT(30); } else { - return 2; // Unrecognised feature. + return 2; // Unrecognised feature. } if (match == 0) return 1; // facility not provided