iflag.h: fix IF_CPU_LEVEL_MASK, add missing CPU definitions

Fix the definition of IF_CPU_LEVEL_MASK (which was missing the top
bit, IFM_ANY itself).

Add CPU definitions that we actually have into directiv.c.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This commit is contained in:
H. Peter Anvin (Intel) 2019-08-06 22:33:14 -07:00
parent c9cbd03dba
commit d13a6f9708
2 changed files with 8 additions and 4 deletions

View File

@ -90,9 +90,13 @@ static iflag_t get_cpu(const char *value)
{ "itanium", IF_IA64 },
{ "itanic", IF_IA64 },
{ "merced", IF_IA64 },
{ "any", IF_PLEVEL },
{ "nehalem", IF_NEHALEM },
{ "westmere", IF_WESTMERE },
{ "sandybridge", IF_SANDYBRIDGE },
{ "ivybridge", IF_FUTURE },
{ "any", IF_ANY },
{ "all", IF_ANY },
{ "default", IF_PLEVEL },
{ "all", IF_PLEVEL },
{ NULL, IF_PLEVEL } /* Error and final default entry */
};

View File

@ -86,7 +86,7 @@ IF_GEN_HELPER(xor, ^)
* IF_ANY is the highest CPU level by definition
*/
#define IF_PLEVEL IF_ANY /* Default CPU level */
#define IF_CPU_LEVEL_MASK (IFM_ANY - 1)
#define IF_CPU_LEVEL_MASK ((IFM_ANY << 1) - 1)
static inline int iflag_cmp_cpu(const iflag_t *a, const iflag_t *b)
{
@ -106,7 +106,7 @@ static inline int iflag_cmp_cpu_level(const iflag_t *a, const iflag_t *b)
/* Returns true if the CPU level is at least a certain value */
static inline bool iflag_cpu_level_ok(const iflag_t *a, unsigned int bit)
{
return _iflag_cpu_level(a) >= IF_GENBIT(bit & 31);
return _iflag_cpu_level(a) >= IF_GENBIT(bit);
}
static inline void iflag_set_all_features(iflag_t *a)