Wireshark-dev: Re: [Wireshark-dev] Get_cpu_info on platforms other than Windows?

From: Guy Harris <guy@xxxxxxxxxxxx>
Date: Wed, 6 Feb 2013 13:48:45 -0800
On Feb 6, 2013, at 12:13 PM, Guy Harris <guy@xxxxxxxxxxxx> wrote:

> Whether an asm would work would depend more on the compiler than on the OS;

...but, then again, maybe the OS has already done all the heavy lifting for you:

	$ uname -sr
	Darwin 12.2.1
	$ sysctl machdep.cpu.brand_string
	machdep.cpu.brand_string: Intel(R) Core(TM) i7-3820QM CPU @ 2.70GHz 

I.e, on OS X, you can use sysctl() to get the brand string, at least on some x86 processors.

On FreeBSD 7 and 9, and OpenBSD 4.8, at least, hw.model gives you that information (it gives you the *system* model, e.g. MacBookPro10,1, on OS X).

On NetBSD 5.1, machdep.cpu_brand does it.

On at least some versions of Linux:

	$ uname -sr
	Linux 2.6.22-16-generic
	$ egrep 'model name' /proc/cpuinfo
	model name      :       Intel(R) Core(TM) i7-3820QM CPU @ 2.70GHz
	model name      :       Intel(R) Core(TM) i7-3820QM CPU @ 2.70GHz

The virtual machine in question is, to quote VMware, "configured to use: 2 processor cores"; I don't know whether that means that it looks like a single chip with two cores, or two separate chips, and I don't know whether Linux reports one or N model names for a single N-core chip.  Do we want to report the number of CPU cores?  (I don't know if any SMP machines have a mix of different CPU models, so I don't know if we need to worry about reporting multiple brand strings.)