From 93efc201159cb045325956f97570d65fe42fca8d Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Wed, 31 Dec 2014 13:25:13 -0800 Subject: "#else", not "#elif", for the last part of a chain of conditionals. Also give more details, for future reference, on how to determine whether the processor supports CPUID. Change-Id: I01e7173e45b0079f02338e51248238c05302dbd2 Reviewed-on: https://code.wireshark.org/review/6189 Reviewed-by: Guy Harris --- wsutil/ws_cpuid.h | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'wsutil/ws_cpuid.h') diff --git a/wsutil/ws_cpuid.h b/wsutil/ws_cpuid.h index 4ef0fc88f6..c6f92c8bda 100644 --- a/wsutil/ws_cpuid.h +++ b/wsutil/ws_cpuid.h @@ -55,10 +55,32 @@ ws_cpuid(guint32 *CPUInfo, int selector) static gboolean ws_cpuid(guint32 *CPUInfo _U_, int selector _U_) { - /* TODO: need a test if older proccesors have the cpuid instruction */ + /* + * TODO: need a test if older proccesors have the cpuid instruction. + * + * The correct way to test for this, according to the Intel64/IA-32 + * documentation from Intel, in section 17.1 "USING THE CPUID + * INSTRUCTION", is to try to change the ID bit (bit 21) in + * EFLAGS. If it can be changed, the machine supports CPUID, + * otherwise it doesn't. + * + * Some 486's, and all subsequent processors, support CPUID. + * + * For those who are curious, the way you distinguish between + * an 80386 and an 80486 is to try to set the flag in EFLAGS + * that causes unaligned accesses to fault - that's bit 18. + * However, if the SMAP bit is set in CR4, that bit controls + * whether explicit supervisor-mode access to user-mode pages + * are allowed, so that should presumably only be done in a + * very controlled environment, such as the system boot process. + * + * So, if you want to find out what type of CPU the system has, + * it's probably best to ask the OS, if it supplies the result + * of any CPU type testing it's done. + */ return FALSE; } -#elif +#else /* not x86 */ static gboolean ws_cpuid(guint32 *CPUInfo _U_, int selector _U_) { -- cgit v1.2.1