Determine CPU architecture - Unix

This is a discussion on Determine CPU architecture - Unix ; 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 : ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Determine CPU architecture

  1. Determine CPU architecture

    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'

  2. Re: Determine CPU architecture

    Begin <0b8975fe-b4fc-407a-8833-bbf00700a613@a1g2000hsb.googlegroups.com>
    On Wed, 9 Apr 2008 02:26:58 -0700 (PDT), idssl 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.

  3. Re: Determine CPU architecture

    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

+ Reply to Thread