Compact cache info data structure for x86/x86-64.

This saves about 1.5kB in the DSO.
This commit is contained in:
Ulrich Drepper 2009-05-29 11:53:36 -07:00
parent 8ee84bd01f
commit 1de0c16183
3 changed files with 161 additions and 155 deletions

View File

@ -1,3 +1,9 @@
2009-05-29 Ulrich Drepper <drepper@redhat.com>
* sysdeps/x86_64/cacheinfo.c: Compact intel_02_known array. Adjust
code accessing it.
* sysdeps/unix/sysv/linux/i386/sysconf.c: Likewise.
2009-05-22 Andreas Schwab <schwab@linux-m68k.org> 2009-05-22 Andreas Schwab <schwab@linux-m68k.org>
* sysdeps/ieee754/ldbl-128ibm/s_sinl.c: Set errno for ±Inf. * sysdeps/ieee754/ldbl-128ibm/s_sinl.c: Set errno for ±Inf.

View File

@ -1,5 +1,5 @@
/* Get file-specific information about a file. Linux version. /* Get file-specific information about a file. Linux version.
Copyright (C) 2003, 2004, 2006, 2007 Free Software Foundation, Inc. Copyright (C) 2003, 2004, 2006, 2007, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or The GNU C Library is free software; you can redistribute it and/or
@ -67,76 +67,77 @@ handle_i486 (int name)
static const struct intel_02_cache_info static const struct intel_02_cache_info
{ {
unsigned int idx; unsigned char idx;
int name; unsigned char assoc;
long int size; unsigned char linesize;
long int assoc; unsigned char rel_name;
long int linesize; unsigned int size;
} intel_02_known[] = } intel_02_known [] =
{ {
{ 0x06, _SC_LEVEL1_ICACHE_SIZE, 8192, 4, 32 }, #define M(sc) ((sc) - _SC_LEVEL1_ICACHE_SIZE)
{ 0x08, _SC_LEVEL1_ICACHE_SIZE, 16384, 4, 32 }, { 0x06, 4, 32, M(_SC_LEVEL1_ICACHE_SIZE), 8192 },
{ 0x09, _SC_LEVEL1_ICACHE_SIZE, 32768, 4, 32 }, { 0x08, 4, 32, M(_SC_LEVEL1_ICACHE_SIZE), 16384 },
{ 0x0a, _SC_LEVEL1_DCACHE_SIZE, 8192, 2, 32 }, { 0x09, 4, 32, M(_SC_LEVEL1_ICACHE_SIZE), 32768 },
{ 0x0c, _SC_LEVEL1_DCACHE_SIZE, 16384, 4, 32 }, { 0x0a, 2, 32, M(_SC_LEVEL1_DCACHE_SIZE), 8192 },
{ 0x0d, _SC_LEVEL1_DCACHE_SIZE, 16384, 4, 64 }, { 0x0c, 4, 32, M(_SC_LEVEL1_DCACHE_SIZE), 16384 },
{ 0x21, _SC_LEVEL2_CACHE_SIZE, 262144, 8, 64 }, { 0x0d, 4, 64, M(_SC_LEVEL1_DCACHE_SIZE), 16384 },
{ 0x22, _SC_LEVEL3_CACHE_SIZE, 524288, 4, 64 }, { 0x21, 8, 64, M(_SC_LEVEL2_CACHE_SIZE), 262144 },
{ 0x23, _SC_LEVEL3_CACHE_SIZE, 1048576, 8, 64 }, { 0x22, 4, 64, M(_SC_LEVEL3_CACHE_SIZE), 524288 },
{ 0x25, _SC_LEVEL3_CACHE_SIZE, 2097152, 8, 64 }, { 0x23, 8, 64, M(_SC_LEVEL3_CACHE_SIZE), 1048576 },
{ 0x29, _SC_LEVEL3_CACHE_SIZE, 4194304, 8, 64 }, { 0x25, 8, 64, M(_SC_LEVEL3_CACHE_SIZE), 2097152 },
{ 0x2c, _SC_LEVEL1_DCACHE_SIZE, 32768, 8, 64 }, { 0x29, 8, 64, M(_SC_LEVEL3_CACHE_SIZE), 4194304 },
{ 0x30, _SC_LEVEL1_ICACHE_SIZE, 32768, 8, 64 }, { 0x2c, 8, 64, M(_SC_LEVEL1_DCACHE_SIZE), 32768 },
{ 0x39, _SC_LEVEL2_CACHE_SIZE, 131072, 4, 64 }, { 0x30, 8, 64, M(_SC_LEVEL1_ICACHE_SIZE), 32768 },
{ 0x3a, _SC_LEVEL2_CACHE_SIZE, 196608, 6, 64 }, { 0x39, 4, 64, M(_SC_LEVEL2_CACHE_SIZE), 131072 },
{ 0x3b, _SC_LEVEL2_CACHE_SIZE, 131072, 2, 64 }, { 0x3a, 6, 64, M(_SC_LEVEL2_CACHE_SIZE), 196608 },
{ 0x3c, _SC_LEVEL2_CACHE_SIZE, 262144, 4, 64 }, { 0x3b, 2, 64, M(_SC_LEVEL2_CACHE_SIZE), 131072 },
{ 0x3d, _SC_LEVEL2_CACHE_SIZE, 393216, 6, 64 }, { 0x3c, 4, 64, M(_SC_LEVEL2_CACHE_SIZE), 262144 },
{ 0x3e, _SC_LEVEL2_CACHE_SIZE, 524288, 4, 64 }, { 0x3d, 6, 64, M(_SC_LEVEL2_CACHE_SIZE), 393216 },
{ 0x3f, _SC_LEVEL2_CACHE_SIZE, 262144, 2, 64 }, { 0x3e, 4, 64, M(_SC_LEVEL2_CACHE_SIZE), 524288 },
{ 0x41, _SC_LEVEL2_CACHE_SIZE, 131072, 4, 32 }, { 0x3f, 2, 64, M(_SC_LEVEL2_CACHE_SIZE), 262144 },
{ 0x42, _SC_LEVEL2_CACHE_SIZE, 262144, 4, 32 }, { 0x41, 4, 32, M(_SC_LEVEL2_CACHE_SIZE), 131072 },
{ 0x43, _SC_LEVEL2_CACHE_SIZE, 524288, 4, 32 }, { 0x42, 4, 32, M(_SC_LEVEL2_CACHE_SIZE), 262144 },
{ 0x44, _SC_LEVEL2_CACHE_SIZE, 1048576, 4, 32 }, { 0x43, 4, 32, M(_SC_LEVEL2_CACHE_SIZE), 524288 },
{ 0x45, _SC_LEVEL2_CACHE_SIZE, 2097152, 4, 32 }, { 0x44, 4, 32, M(_SC_LEVEL2_CACHE_SIZE), 1048576 },
{ 0x46, _SC_LEVEL3_CACHE_SIZE, 4194304, 4, 64 }, { 0x45, 4, 32, M(_SC_LEVEL2_CACHE_SIZE), 2097152 },
{ 0x47, _SC_LEVEL3_CACHE_SIZE, 8388608, 8, 64 }, { 0x46, 4, 64, M(_SC_LEVEL3_CACHE_SIZE), 4194304 },
{ 0x48, _SC_LEVEL2_CACHE_SIZE, 3145728, 12, 64 }, { 0x47, 8, 64, M(_SC_LEVEL3_CACHE_SIZE), 8388608 },
{ 0x49, _SC_LEVEL2_CACHE_SIZE, 4194304, 16, 64 }, { 0x48, 12, 64, M(_SC_LEVEL2_CACHE_SIZE), 3145728 },
{ 0x4a, _SC_LEVEL3_CACHE_SIZE, 6291456, 12, 64 }, { 0x49, 16, 64, M(_SC_LEVEL2_CACHE_SIZE), 4194304 },
{ 0x4b, _SC_LEVEL3_CACHE_SIZE, 8388608, 16, 64 }, { 0x4a, 12, 64, M(_SC_LEVEL3_CACHE_SIZE), 6291456 },
{ 0x4c, _SC_LEVEL3_CACHE_SIZE, 12582912, 12, 64 }, { 0x4b, 16, 64, M(_SC_LEVEL3_CACHE_SIZE), 8388608 },
{ 0x4d, _SC_LEVEL3_CACHE_SIZE, 16777216, 16, 64 }, { 0x4c, 12, 64, M(_SC_LEVEL3_CACHE_SIZE), 12582912 },
{ 0x4e, _SC_LEVEL2_CACHE_SIZE, 6291456, 24, 64 }, { 0x4d, 16, 64, M(_SC_LEVEL3_CACHE_SIZE), 16777216 },
{ 0x60, _SC_LEVEL1_DCACHE_SIZE, 16384, 8, 64 }, { 0x4e, 24, 64, M(_SC_LEVEL2_CACHE_SIZE), 6291456 },
{ 0x66, _SC_LEVEL1_DCACHE_SIZE, 8192, 4, 64 }, { 0x60, 8, 64, M(_SC_LEVEL1_DCACHE_SIZE), 16384 },
{ 0x67, _SC_LEVEL1_DCACHE_SIZE, 16384, 4, 64 }, { 0x66, 4, 64, M(_SC_LEVEL1_DCACHE_SIZE), 8192 },
{ 0x68, _SC_LEVEL1_DCACHE_SIZE, 32768, 4, 64 }, { 0x67, 4, 64, M(_SC_LEVEL1_DCACHE_SIZE), 16384 },
{ 0x78, _SC_LEVEL2_CACHE_SIZE, 1048576, 8, 64 }, { 0x68, 4, 64, M(_SC_LEVEL1_DCACHE_SIZE), 32768 },
{ 0x79, _SC_LEVEL2_CACHE_SIZE, 131072, 8, 64 }, { 0x78, 8, 64, M(_SC_LEVEL2_CACHE_SIZE), 1048576 },
{ 0x7a, _SC_LEVEL2_CACHE_SIZE, 262144, 8, 64 }, { 0x79, 8, 64, M(_SC_LEVEL2_CACHE_SIZE), 131072 },
{ 0x7b, _SC_LEVEL2_CACHE_SIZE, 524288, 8, 64 }, { 0x7a, 8, 64, M(_SC_LEVEL2_CACHE_SIZE), 262144 },
{ 0x7c, _SC_LEVEL2_CACHE_SIZE, 1048576, 8, 64 }, { 0x7b, 8, 64, M(_SC_LEVEL2_CACHE_SIZE), 524288 },
{ 0x7d, _SC_LEVEL2_CACHE_SIZE, 2097152, 8, 64 }, { 0x7c, 8, 64, M(_SC_LEVEL2_CACHE_SIZE), 1048576 },
{ 0x7f, _SC_LEVEL2_CACHE_SIZE, 524288, 2, 64 }, { 0x7d, 8, 64, M(_SC_LEVEL2_CACHE_SIZE), 2097152 },
{ 0x82, _SC_LEVEL2_CACHE_SIZE, 262144, 8, 32 }, { 0x7f, 2, 64, M(_SC_LEVEL2_CACHE_SIZE), 524288 },
{ 0x83, _SC_LEVEL2_CACHE_SIZE, 524288, 8, 32 }, { 0x82, 8, 32, M(_SC_LEVEL2_CACHE_SIZE), 262144 },
{ 0x84, _SC_LEVEL2_CACHE_SIZE, 1048576, 8, 32 }, { 0x83, 8, 32, M(_SC_LEVEL2_CACHE_SIZE), 524288 },
{ 0x85, _SC_LEVEL2_CACHE_SIZE, 2097152, 8, 32 }, { 0x84, 8, 32, M(_SC_LEVEL2_CACHE_SIZE), 1048576 },
{ 0x86, _SC_LEVEL2_CACHE_SIZE, 524288, 4, 64 }, { 0x85, 8, 32, M(_SC_LEVEL2_CACHE_SIZE), 2097152 },
{ 0x87, _SC_LEVEL2_CACHE_SIZE, 1048576, 8, 64 }, { 0x86, 4, 64, M(_SC_LEVEL2_CACHE_SIZE), 524288 },
{ 0xd0, _SC_LEVEL3_CACHE_SIZE, 524288, 4, 64 }, { 0x87, 8, 64, M(_SC_LEVEL2_CACHE_SIZE), 1048576 },
{ 0xd1, _SC_LEVEL3_CACHE_SIZE, 1048576, 4, 64 }, { 0xd0, 4, 64, M(_SC_LEVEL3_CACHE_SIZE), 524288 },
{ 0xd2, _SC_LEVEL3_CACHE_SIZE, 2097152, 4, 64 }, { 0xd1, 4, 64, M(_SC_LEVEL3_CACHE_SIZE), 1048576 },
{ 0xd6, _SC_LEVEL3_CACHE_SIZE, 1048576, 8, 64 }, { 0xd2, 4, 64, M(_SC_LEVEL3_CACHE_SIZE), 2097152 },
{ 0xd7, _SC_LEVEL3_CACHE_SIZE, 2097152, 8, 64 }, { 0xd6, 8, 64, M(_SC_LEVEL3_CACHE_SIZE), 1048576 },
{ 0xd8, _SC_LEVEL3_CACHE_SIZE, 4194304, 8, 64 }, { 0xd7, 8, 64, M(_SC_LEVEL3_CACHE_SIZE), 2097152 },
{ 0xdc, _SC_LEVEL3_CACHE_SIZE, 2097152, 12, 64 }, { 0xd8, 8, 64, M(_SC_LEVEL3_CACHE_SIZE), 4194304 },
{ 0xdd, _SC_LEVEL3_CACHE_SIZE, 4194304, 12, 64 }, { 0xdc, 12, 64, M(_SC_LEVEL3_CACHE_SIZE), 2097152 },
{ 0xde, _SC_LEVEL3_CACHE_SIZE, 8388608, 12, 64 }, { 0xdd, 12, 64, M(_SC_LEVEL3_CACHE_SIZE), 4194304 },
{ 0xe3, _SC_LEVEL3_CACHE_SIZE, 2097152, 16, 64 }, { 0xde, 12, 64, M(_SC_LEVEL3_CACHE_SIZE), 8388608 },
{ 0xe3, _SC_LEVEL3_CACHE_SIZE, 4194304, 16, 64 }, { 0xe3, 16, 64, M(_SC_LEVEL3_CACHE_SIZE), 2097152 },
{ 0xe4, _SC_LEVEL3_CACHE_SIZE, 8388608, 16, 64 }, { 0xe3, 16, 64, M(_SC_LEVEL3_CACHE_SIZE), 4194304 },
{ 0xe4, 16, 64, M(_SC_LEVEL3_CACHE_SIZE), 8388608 },
}; };
#define nintel_02_known (sizeof (intel_02_known) / sizeof (intel_02_known[0])) #define nintel_02_known (sizeof (intel_02_known) / sizeof (intel_02_known[0]))
@ -168,8 +169,7 @@ intel_check_word (int name, unsigned int value, bool *has_level_2,
/* Fold the name. The _SC_ constants are always in the order SIZE, /* Fold the name. The _SC_ constants are always in the order SIZE,
ASSOC, LINESIZE. */ ASSOC, LINESIZE. */
int folded_name = (_SC_LEVEL1_ICACHE_SIZE int folded_rel_name = (M(name) / 3) * 3;
+ ((name - _SC_LEVEL1_ICACHE_SIZE) / 3) * 3);
while (value != 0) while (value != 0)
{ {
@ -179,13 +179,13 @@ intel_check_word (int name, unsigned int value, bool *has_level_2,
{ {
*no_level_2_or_3 = true; *no_level_2_or_3 = true;
if (folded_name == _SC_LEVEL3_CACHE_SIZE) if (folded_rel_name == M(_SC_LEVEL3_CACHE_SIZE))
/* No need to look further. */ /* No need to look further. */
break; break;
} }
else else
{ {
if (byte == 0x49 && folded_name == _SC_LEVEL3_CACHE_SIZE) if (byte == 0x49 && folded_rel_name == M(_SC_LEVEL3_CACHE_SIZE))
{ {
/* Intel reused this value. For family 15, model 6 it /* Intel reused this value. For family 15, model 6 it
specifies the 3rd level cache. Otherwise the 2nd specifies the 3rd level cache. Otherwise the 2nd
@ -208,7 +208,7 @@ intel_check_word (int name, unsigned int value, bool *has_level_2,
the caller asked for the level 2 cache. */ the caller asked for the level 2 cache. */
name = (_SC_LEVEL2_CACHE_SIZE name = (_SC_LEVEL2_CACHE_SIZE
+ (name - _SC_LEVEL3_CACHE_SIZE)); + (name - _SC_LEVEL3_CACHE_SIZE));
folded_name = _SC_LEVEL3_CACHE_SIZE; folded_rel_name = M(_SC_LEVEL2_CACHE_SIZE);
} }
} }
@ -220,9 +220,9 @@ intel_check_word (int name, unsigned int value, bool *has_level_2,
sizeof (intel_02_known[0]), intel_02_known_compare); sizeof (intel_02_known[0]), intel_02_known_compare);
if (found != NULL) if (found != NULL)
{ {
if (found->name == folded_name) if (found->rel_name == folded_rel_name)
{ {
unsigned int offset = name - folded_name; unsigned int offset = M(name) - folded_rel_name;
if (offset == 0) if (offset == 0)
/* Cache size. */ /* Cache size. */
@ -234,7 +234,7 @@ intel_check_word (int name, unsigned int value, bool *has_level_2,
return found->linesize; return found->linesize;
} }
if (found->name == _SC_LEVEL2_CACHE_SIZE) if (found->rel_name == M(_SC_LEVEL2_CACHE_SIZE))
*has_level_2 = true; *has_level_2 = true;
} }
} }

View File

@ -1,5 +1,5 @@
/* x86_64 cache info. /* x86_64 cache info.
Copyright (C) 2003, 2004, 2006, 2007 Free Software Foundation, Inc. Copyright (C) 2003, 2004, 2006, 2007, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or The GNU C Library is free software; you can redistribute it and/or
@ -29,76 +29,77 @@
static const struct intel_02_cache_info static const struct intel_02_cache_info
{ {
unsigned int idx; unsigned char idx;
int name; unsigned char assoc;
long int size; unsigned char linesize;
long int assoc; unsigned char rel_name;
long int linesize; unsigned int size;
} intel_02_known [] = } intel_02_known [] =
{ {
{ 0x06, _SC_LEVEL1_ICACHE_SIZE, 8192, 4, 32 }, #define M(sc) ((sc) - _SC_LEVEL1_ICACHE_SIZE)
{ 0x08, _SC_LEVEL1_ICACHE_SIZE, 16384, 4, 32 }, { 0x06, 4, 32, M(_SC_LEVEL1_ICACHE_SIZE), 8192 },
{ 0x09, _SC_LEVEL1_ICACHE_SIZE, 32768, 4, 32 }, { 0x08, 4, 32, M(_SC_LEVEL1_ICACHE_SIZE), 16384 },
{ 0x0a, _SC_LEVEL1_DCACHE_SIZE, 8192, 2, 32 }, { 0x09, 4, 32, M(_SC_LEVEL1_ICACHE_SIZE), 32768 },
{ 0x0c, _SC_LEVEL1_DCACHE_SIZE, 16384, 4, 32 }, { 0x0a, 2, 32, M(_SC_LEVEL1_DCACHE_SIZE), 8192 },
{ 0x0d, _SC_LEVEL1_DCACHE_SIZE, 16384, 4, 64 }, { 0x0c, 4, 32, M(_SC_LEVEL1_DCACHE_SIZE), 16384 },
{ 0x21, _SC_LEVEL2_CACHE_SIZE, 262144, 8, 64 }, { 0x0d, 4, 64, M(_SC_LEVEL1_DCACHE_SIZE), 16384 },
{ 0x22, _SC_LEVEL3_CACHE_SIZE, 524288, 4, 64 }, { 0x21, 8, 64, M(_SC_LEVEL2_CACHE_SIZE), 262144 },
{ 0x23, _SC_LEVEL3_CACHE_SIZE, 1048576, 8, 64 }, { 0x22, 4, 64, M(_SC_LEVEL3_CACHE_SIZE), 524288 },
{ 0x25, _SC_LEVEL3_CACHE_SIZE, 2097152, 8, 64 }, { 0x23, 8, 64, M(_SC_LEVEL3_CACHE_SIZE), 1048576 },
{ 0x29, _SC_LEVEL3_CACHE_SIZE, 4194304, 8, 64 }, { 0x25, 8, 64, M(_SC_LEVEL3_CACHE_SIZE), 2097152 },
{ 0x2c, _SC_LEVEL1_DCACHE_SIZE, 32768, 8, 64 }, { 0x29, 8, 64, M(_SC_LEVEL3_CACHE_SIZE), 4194304 },
{ 0x30, _SC_LEVEL1_ICACHE_SIZE, 32768, 8, 64 }, { 0x2c, 8, 64, M(_SC_LEVEL1_DCACHE_SIZE), 32768 },
{ 0x39, _SC_LEVEL2_CACHE_SIZE, 131072, 4, 64 }, { 0x30, 8, 64, M(_SC_LEVEL1_ICACHE_SIZE), 32768 },
{ 0x3a, _SC_LEVEL2_CACHE_SIZE, 196608, 6, 64 }, { 0x39, 4, 64, M(_SC_LEVEL2_CACHE_SIZE), 131072 },
{ 0x3b, _SC_LEVEL2_CACHE_SIZE, 131072, 2, 64 }, { 0x3a, 6, 64, M(_SC_LEVEL2_CACHE_SIZE), 196608 },
{ 0x3c, _SC_LEVEL2_CACHE_SIZE, 262144, 4, 64 }, { 0x3b, 2, 64, M(_SC_LEVEL2_CACHE_SIZE), 131072 },
{ 0x3d, _SC_LEVEL2_CACHE_SIZE, 393216, 6, 64 }, { 0x3c, 4, 64, M(_SC_LEVEL2_CACHE_SIZE), 262144 },
{ 0x3e, _SC_LEVEL2_CACHE_SIZE, 524288, 4, 64 }, { 0x3d, 6, 64, M(_SC_LEVEL2_CACHE_SIZE), 393216 },
{ 0x3f, _SC_LEVEL2_CACHE_SIZE, 262144, 2, 64 }, { 0x3e, 4, 64, M(_SC_LEVEL2_CACHE_SIZE), 524288 },
{ 0x41, _SC_LEVEL2_CACHE_SIZE, 131072, 4, 32 }, { 0x3f, 2, 64, M(_SC_LEVEL2_CACHE_SIZE), 262144 },
{ 0x42, _SC_LEVEL2_CACHE_SIZE, 262144, 4, 32 }, { 0x41, 4, 32, M(_SC_LEVEL2_CACHE_SIZE), 131072 },
{ 0x43, _SC_LEVEL2_CACHE_SIZE, 524288, 4, 32 }, { 0x42, 4, 32, M(_SC_LEVEL2_CACHE_SIZE), 262144 },
{ 0x44, _SC_LEVEL2_CACHE_SIZE, 1048576, 4, 32 }, { 0x43, 4, 32, M(_SC_LEVEL2_CACHE_SIZE), 524288 },
{ 0x45, _SC_LEVEL2_CACHE_SIZE, 2097152, 4, 32 }, { 0x44, 4, 32, M(_SC_LEVEL2_CACHE_SIZE), 1048576 },
{ 0x46, _SC_LEVEL3_CACHE_SIZE, 4194304, 4, 64 }, { 0x45, 4, 32, M(_SC_LEVEL2_CACHE_SIZE), 2097152 },
{ 0x47, _SC_LEVEL3_CACHE_SIZE, 8388608, 8, 64 }, { 0x46, 4, 64, M(_SC_LEVEL3_CACHE_SIZE), 4194304 },
{ 0x48, _SC_LEVEL2_CACHE_SIZE, 3145728, 12, 64 }, { 0x47, 8, 64, M(_SC_LEVEL3_CACHE_SIZE), 8388608 },
{ 0x49, _SC_LEVEL2_CACHE_SIZE, 4194304, 16, 64 }, { 0x48, 12, 64, M(_SC_LEVEL2_CACHE_SIZE), 3145728 },
{ 0x4a, _SC_LEVEL3_CACHE_SIZE, 6291456, 12, 64 }, { 0x49, 16, 64, M(_SC_LEVEL2_CACHE_SIZE), 4194304 },
{ 0x4b, _SC_LEVEL3_CACHE_SIZE, 8388608, 16, 64 }, { 0x4a, 12, 64, M(_SC_LEVEL3_CACHE_SIZE), 6291456 },
{ 0x4c, _SC_LEVEL3_CACHE_SIZE, 12582912, 12, 64 }, { 0x4b, 16, 64, M(_SC_LEVEL3_CACHE_SIZE), 8388608 },
{ 0x4d, _SC_LEVEL3_CACHE_SIZE, 16777216, 16, 64 }, { 0x4c, 12, 64, M(_SC_LEVEL3_CACHE_SIZE), 12582912 },
{ 0x4e, _SC_LEVEL2_CACHE_SIZE, 6291456, 24, 64 }, { 0x4d, 16, 64, M(_SC_LEVEL3_CACHE_SIZE), 16777216 },
{ 0x60, _SC_LEVEL1_DCACHE_SIZE, 16384, 8, 64 }, { 0x4e, 24, 64, M(_SC_LEVEL2_CACHE_SIZE), 6291456 },
{ 0x66, _SC_LEVEL1_DCACHE_SIZE, 8192, 4, 64 }, { 0x60, 8, 64, M(_SC_LEVEL1_DCACHE_SIZE), 16384 },
{ 0x67, _SC_LEVEL1_DCACHE_SIZE, 16384, 4, 64 }, { 0x66, 4, 64, M(_SC_LEVEL1_DCACHE_SIZE), 8192 },
{ 0x68, _SC_LEVEL1_DCACHE_SIZE, 32768, 4, 64 }, { 0x67, 4, 64, M(_SC_LEVEL1_DCACHE_SIZE), 16384 },
{ 0x78, _SC_LEVEL2_CACHE_SIZE, 1048576, 8, 64 }, { 0x68, 4, 64, M(_SC_LEVEL1_DCACHE_SIZE), 32768 },
{ 0x79, _SC_LEVEL2_CACHE_SIZE, 131072, 8, 64 }, { 0x78, 8, 64, M(_SC_LEVEL2_CACHE_SIZE), 1048576 },
{ 0x7a, _SC_LEVEL2_CACHE_SIZE, 262144, 8, 64 }, { 0x79, 8, 64, M(_SC_LEVEL2_CACHE_SIZE), 131072 },
{ 0x7b, _SC_LEVEL2_CACHE_SIZE, 524288, 8, 64 }, { 0x7a, 8, 64, M(_SC_LEVEL2_CACHE_SIZE), 262144 },
{ 0x7c, _SC_LEVEL2_CACHE_SIZE, 1048576, 8, 64 }, { 0x7b, 8, 64, M(_SC_LEVEL2_CACHE_SIZE), 524288 },
{ 0x7d, _SC_LEVEL2_CACHE_SIZE, 2097152, 8, 64 }, { 0x7c, 8, 64, M(_SC_LEVEL2_CACHE_SIZE), 1048576 },
{ 0x7f, _SC_LEVEL2_CACHE_SIZE, 524288, 2, 64 }, { 0x7d, 8, 64, M(_SC_LEVEL2_CACHE_SIZE), 2097152 },
{ 0x82, _SC_LEVEL2_CACHE_SIZE, 262144, 8, 32 }, { 0x7f, 2, 64, M(_SC_LEVEL2_CACHE_SIZE), 524288 },
{ 0x83, _SC_LEVEL2_CACHE_SIZE, 524288, 8, 32 }, { 0x82, 8, 32, M(_SC_LEVEL2_CACHE_SIZE), 262144 },
{ 0x84, _SC_LEVEL2_CACHE_SIZE, 1048576, 8, 32 }, { 0x83, 8, 32, M(_SC_LEVEL2_CACHE_SIZE), 524288 },
{ 0x85, _SC_LEVEL2_CACHE_SIZE, 2097152, 8, 32 }, { 0x84, 8, 32, M(_SC_LEVEL2_CACHE_SIZE), 1048576 },
{ 0x86, _SC_LEVEL2_CACHE_SIZE, 524288, 4, 64 }, { 0x85, 8, 32, M(_SC_LEVEL2_CACHE_SIZE), 2097152 },
{ 0x87, _SC_LEVEL2_CACHE_SIZE, 1048576, 8, 64 }, { 0x86, 4, 64, M(_SC_LEVEL2_CACHE_SIZE), 524288 },
{ 0xd0, _SC_LEVEL3_CACHE_SIZE, 524288, 4, 64 }, { 0x87, 8, 64, M(_SC_LEVEL2_CACHE_SIZE), 1048576 },
{ 0xd1, _SC_LEVEL3_CACHE_SIZE, 1048576, 4, 64 }, { 0xd0, 4, 64, M(_SC_LEVEL3_CACHE_SIZE), 524288 },
{ 0xd2, _SC_LEVEL3_CACHE_SIZE, 2097152, 4, 64 }, { 0xd1, 4, 64, M(_SC_LEVEL3_CACHE_SIZE), 1048576 },
{ 0xd6, _SC_LEVEL3_CACHE_SIZE, 1048576, 8, 64 }, { 0xd2, 4, 64, M(_SC_LEVEL3_CACHE_SIZE), 2097152 },
{ 0xd7, _SC_LEVEL3_CACHE_SIZE, 2097152, 8, 64 }, { 0xd6, 8, 64, M(_SC_LEVEL3_CACHE_SIZE), 1048576 },
{ 0xd8, _SC_LEVEL3_CACHE_SIZE, 4194304, 8, 64 }, { 0xd7, 8, 64, M(_SC_LEVEL3_CACHE_SIZE), 2097152 },
{ 0xdc, _SC_LEVEL3_CACHE_SIZE, 2097152, 12, 64 }, { 0xd8, 8, 64, M(_SC_LEVEL3_CACHE_SIZE), 4194304 },
{ 0xdd, _SC_LEVEL3_CACHE_SIZE, 4194304, 12, 64 }, { 0xdc, 12, 64, M(_SC_LEVEL3_CACHE_SIZE), 2097152 },
{ 0xde, _SC_LEVEL3_CACHE_SIZE, 8388608, 12, 64 }, { 0xdd, 12, 64, M(_SC_LEVEL3_CACHE_SIZE), 4194304 },
{ 0xe3, _SC_LEVEL3_CACHE_SIZE, 2097152, 16, 64 }, { 0xde, 12, 64, M(_SC_LEVEL3_CACHE_SIZE), 8388608 },
{ 0xe3, _SC_LEVEL3_CACHE_SIZE, 4194304, 16, 64 }, { 0xe3, 16, 64, M(_SC_LEVEL3_CACHE_SIZE), 2097152 },
{ 0xe4, _SC_LEVEL3_CACHE_SIZE, 8388608, 16, 64 }, { 0xe3, 16, 64, M(_SC_LEVEL3_CACHE_SIZE), 4194304 },
{ 0xe4, 16, 64, M(_SC_LEVEL3_CACHE_SIZE), 8388608 },
}; };
#define nintel_02_known (sizeof (intel_02_known) / sizeof (intel_02_known [0])) #define nintel_02_known (sizeof (intel_02_known) / sizeof (intel_02_known [0]))
@ -130,8 +131,7 @@ intel_check_word (int name, unsigned int value, bool *has_level_2,
/* Fold the name. The _SC_ constants are always in the order SIZE, /* Fold the name. The _SC_ constants are always in the order SIZE,
ASSOC, LINESIZE. */ ASSOC, LINESIZE. */
int folded_name = (_SC_LEVEL1_ICACHE_SIZE int folded_rel_name = (M(name) / 3) * 3;
+ ((name - _SC_LEVEL1_ICACHE_SIZE) / 3) * 3);
while (value != 0) while (value != 0)
{ {
@ -141,13 +141,13 @@ intel_check_word (int name, unsigned int value, bool *has_level_2,
{ {
*no_level_2_or_3 = true; *no_level_2_or_3 = true;
if (folded_name == _SC_LEVEL3_CACHE_SIZE) if (folded_rel_name == M(_SC_LEVEL3_CACHE_SIZE))
/* No need to look further. */ /* No need to look further. */
break; break;
} }
else else
{ {
if (byte == 0x49 && folded_name == _SC_LEVEL3_CACHE_SIZE) if (byte == 0x49 && folded_rel_name == M(_SC_LEVEL3_CACHE_SIZE))
{ {
/* Intel reused this value. For family 15, model 6 it /* Intel reused this value. For family 15, model 6 it
specifies the 3rd level cache. Otherwise the 2nd specifies the 3rd level cache. Otherwise the 2nd
@ -170,7 +170,7 @@ intel_check_word (int name, unsigned int value, bool *has_level_2,
the caller asked for the level 2 cache. */ the caller asked for the level 2 cache. */
name = (_SC_LEVEL2_CACHE_SIZE name = (_SC_LEVEL2_CACHE_SIZE
+ (name - _SC_LEVEL3_CACHE_SIZE)); + (name - _SC_LEVEL3_CACHE_SIZE));
folded_name = _SC_LEVEL3_CACHE_SIZE; folded_rel_name = M(_SC_LEVEL2_CACHE_SIZE);
} }
} }
@ -182,9 +182,9 @@ intel_check_word (int name, unsigned int value, bool *has_level_2,
sizeof (intel_02_known[0]), intel_02_known_compare); sizeof (intel_02_known[0]), intel_02_known_compare);
if (found != NULL) if (found != NULL)
{ {
if (found->name == folded_name) if (found->rel_name == folded_rel_name)
{ {
unsigned int offset = name - folded_name; unsigned int offset = M(name) - folded_rel_name;
if (offset == 0) if (offset == 0)
/* Cache size. */ /* Cache size. */
@ -196,7 +196,7 @@ intel_check_word (int name, unsigned int value, bool *has_level_2,
return found->linesize; return found->linesize;
} }
if (found->name == _SC_LEVEL2_CACHE_SIZE) if (found->rel_name == M(_SC_LEVEL2_CACHE_SIZE))
*has_level_2 = true; *has_level_2 = true;
} }
} }