aboutsummaryrefslogtreecommitdiffstats
path: root/version_info.c
diff options
context:
space:
mode:
authorJakub Zawadzki <darkjames@darkjames.pl>2014-05-31 11:22:56 +0200
committerMichael Mann <mmann78@netscape.net>2014-05-31 13:01:08 +0000
commit531541660b31e87922021158454b2441e67935fa (patch)
tree6594ab833afa6c6887627c8058e990ba931ebedc /version_info.c
parent799972425dc2178b28067e729abc99d31e0ccc67 (diff)
Move cpuid to seperate header file.
It'll be later used also for detecting sse4.2 Change-Id: I1930abb29026b455d453a79b5f301cdf37585160 Reviewed-on: https://code.wireshark.org/review/1803 Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'version_info.c')
-rw-r--r--version_info.c51
1 files changed, 5 insertions, 46 deletions
diff --git a/version_info.c b/version_info.c
index 293fb1d904..c400130fd5 100644
--- a/version_info.c
+++ b/version_info.c
@@ -40,6 +40,7 @@
#include "version_info.h"
#include "capture-pcap-util.h"
#include <wsutil/unicode-utils.h>
+#include <wsutil/ws_cpuid.h>
#include "version.h"
@@ -618,51 +619,9 @@ void get_os_version_info(GString *str)
* Get the CPU info, and append it to the GString
*/
-#if defined(_MSC_VER)
-static void
-do_cpuid(int *CPUInfo, guint32 selector){
- __cpuid(CPUInfo, selector);
-}
-#elif defined(__GNUC__)
-#if defined(__x86_64__)
-static inline void
-do_cpuid(guint32 *CPUInfo, int selector)
-{
- __asm__ __volatile__("cpuid"
- : "=a" (CPUInfo[0]),
- "=b" (CPUInfo[1]),
- "=c" (CPUInfo[2]),
- "=d" (CPUInfo[3])
- : "a"(selector));
-}
-#else /* (__i386__) */
-/* would need a test if older proccesors have the cpuid instruction */
-static void
-do_cpuid(guint32 *CPUInfo, int selector _U_){
- CPUInfo[0] = 0;
-}
-
-#endif /* defined(__x86_64__)*/
-#else /* Other compilers */
-static void
-do_cpuid(guint32 *CPUInfo, int selector _U_){
- CPUInfo[0] = 0;
-}
-#endif
-
-/*
- * Get CPU info on platforms where the cpuid instruction can be used skip 32 bit versions for GCC
- * http://www.intel.com/content/dam/www/public/us/en/documents/application-notes/processor-identification-cpuid-instruction-note.pdf
- * the get_cpuid() routine will return 0 in CPUInfo[0] if cpuinfo isn't available.
- */
-
static void get_cpu_info(GString *str _U_)
{
-#if defined(_MSC_VER)
- int CPUInfo[4];
-#else
guint32 CPUInfo[4];
-#endif
char CPUBrandString[0x40];
unsigned nExIds;
@@ -670,7 +629,7 @@ static void get_cpu_info(GString *str _U_)
/* Calling __cpuid with 0x80000000 as the InfoType argument*/
/* gets the number of valid extended IDs.*/
- do_cpuid(CPUInfo, 0x80000000);
+ ws_cpuid(CPUInfo, 0x80000000);
nExIds = CPUInfo[0];
if( nExIds<0x80000005)
@@ -678,11 +637,11 @@ static void get_cpu_info(GString *str _U_)
memset(CPUBrandString, 0, sizeof(CPUBrandString));
/* Interpret CPU brand string.*/
- do_cpuid(CPUInfo, 0x80000002);
+ ws_cpuid(CPUInfo, 0x80000002);
memcpy(CPUBrandString, CPUInfo, sizeof(CPUInfo));
- do_cpuid(CPUInfo, 0x80000003);
+ ws_cpuid(CPUInfo, 0x80000003);
memcpy(CPUBrandString + 16, CPUInfo, sizeof(CPUInfo));
- do_cpuid(CPUInfo, 0x80000004);
+ ws_cpuid(CPUInfo, 0x80000004);
memcpy(CPUBrandString + 32, CPUInfo, sizeof(CPUInfo));
g_string_append_printf(str, "\n%s", CPUBrandString);