C/C++ call to detect cpu?
Garrett Cooper
youshi10 at u.washington.edu
Sat Jan 21 18:26:28 PST 2006
On Jan 21, 2006, at 12:33 PM, John Levine wrote:
>> Other than 'grep'ing dmesg, is there a way to know the current cpu
>> such as a
>> struct with the machine's cpu and cpu feature (kinda like a time_t
>> struct)?
>
> $ sysctl hw.model
> hw.model: AMD Athlon(tm) 64 Processor 3000+
>
> If you want more details write a tiny assembler routine that does a
> CPUID instruction and decode the result. Intel has a detailed
> application
> note about it at
> http://developer.intel.ru/design/xeon/applnots/241618.htm
>
> R's,
> John
As for gcc, CFLAGS and CXXFLAGS, doing some searching on google for
"-march" gcc will prove to help you in finding out what is and is not
supported by your processor. There's also a link from the Gentoo
Linux docs somewhere in the handbook, but you will have to hunt that
down on your own ;).
There's also a better (or perhaps, just more relevant) doc somewhere
on FreeBSD's site about CFLAGS and CXXFLAGS which also addresses gcc
variables and architectures I think.
-Garrett
More information about the freebsd-questions
mailing list