- Determine CPU architecture
- Posted by idssl on April 9th, 2008
Hi,
Can the 'uname -p' (or 'uname -i') command be used to detect the CPU
architecture of a machine reliably? It seems to give different
outputs on SunOS and Linux kernels.
On an x86 Solaris installation:
uname -p gives : i386
uname -i gives : i86pc
On a Solaris Sparc version:
uname -p gives : sparc
uname -i gives : SUNW,Sun-Fire-V240
On a Linux installation on an AMD:
uname -p gives : athlon (this is the processor name, not architecture,
right?)
uname -i gives : i386 (this is the architecture?)
Is it correct to say that, on SunOS 'uname -p' gives the architecture
and on Linux the architecture is given by 'uname -i' ?
What is the reliable way to determine the cpu architecture across
different CPU/OS platforms?
Thanks,
Ishan.
PS:
SunOS man file does not recommend the use of 'uname -m'
- Posted by jpd on April 9th, 2008
Begin <0b8975fe-b4fc-407a-8833-bbf00700a613@a1g2000hsb.googlegroups.com>
On Wed, 9 Apr 2008 02:26:58 -0700 (PDT), idssl <ishan.desilva@gmail.com> wrote:
On EG. FreeBSD, -i returns ``the kernel identity'' which is a string
supplied by whoever named the custom kernel (``GENERIC'' for the default).
This kind of thing is best looked up in the reference manual. Compare
what the linux manpage says for those two options with what the solaris
manpage says.
Figure out what OS you're on, then adapt the hardware interrogation to
that. The closer you get to the hardware, the more unices diverge. For
extra fun, google ``rosetta stone unix''.
--
j p d (at) d s b (dot) t u d e l f t (dot) n l .
This message was originally posted on Usenet in plain text.
Any other representation, additions, or changes do not have my
consent and may be a violation of international copyright law.
- Posted by Michael Tosch on April 9th, 2008
idssl wrote:
Either man pages sais this is "platform".
uname -p
should be closest to the CPU model if implemented.
The following shell command should run on any OS,
and can be used to branch to CPU-optimized binaries:
uname -p 2>/dev/null || uname -m 2>/dev/null || uname
while
uname -m 2>/dev/null || uname
can branch to non-optimized code.
but is indeed better portable than "arch".
--
Michael Tosch @ hp : com