Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Determine CPU architecture

402 views
Skip to first unread message

idssl

unread,
Apr 9, 2008, 5:26:58 AM4/9/08
to
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'

jpd

unread,
Apr 9, 2008, 5:45:46 AM4/9/08
to
Begin <0b8975fe-b4fc-407a...@a1g2000hsb.googlegroups.com>

On Wed, 9 Apr 2008 02:26:58 -0700 (PDT), idssl <ishan....@gmail.com> wrote:
> 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 EG. FreeBSD, -i returns ``the kernel identity'' which is a string
supplied by whoever named the custom kernel (``GENERIC'' for the default).


> Is it correct to say that, on SunOS 'uname -p' gives the architecture
> and on Linux the architecture is given by 'uname -i' ?

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.


> What is the reliable way to determine the cpu architecture across
> different CPU/OS platforms?

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.

Michael Tosch

unread,
Apr 9, 2008, 1:07:02 PM4/9/08
to
idssl wrote:
> 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?)

Either man pages sais this is "platform".

>
> 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?

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.

>
> Thanks,
> Ishan.
>
> PS:
> SunOS man file does not recommend the use of 'uname -m'

but is indeed better portable than "arch".

--
Michael Tosch @ hp : com

0 new messages