From: prabhum@msys-tech.com (prabhu)
To: kernelnewbies@lists.kernelnewbies.org
Subject: How to identity processor architecture
Date: Thu, 27 Jan 2011 18:03:53 +0530 [thread overview]
Message-ID: <4D416631.9000307@msys-tech.com> (raw)
In-Reply-To: <AANLkTi=HAw8uu=2ipwDSrn325whYAtGJbCZFCEC9WY-M@mail.gmail.com>
Pravin Shedage wrote:
> Hi,
>
> This C program might help you.
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> #include <errno.h>
> #include <sys/utsname.h>
>
> int main()
> {
> struct utsname *buf = NULL;
>
>
>
> buf = malloc(sizeof(struct utsname));
> if (buf == NULL) {
> fprintf(stderr,"Memory Allocation Error: %s \n", strerror(errno));
> exit(-1);
> }
>
> if (uname(buf) < 0) {
> fprintf(stderr,"UName Error: %s \n", strerror(errno));
> exit(-1);
> }
>
> printf ("Processor arch =:>) %s \n", buf->machine);
>
> return 0;
> }
>
>
>
>
> On Thu, Jan 27, 2011 at 4:45 PM, Henry Gebhardt
> <hsggebhardt at googlemail.com <mailto:hsggebhardt@googlemail.com>> wrote:
>
> On Thu, Jan 27, 2011 at 03:23:28PM +0530, prabhu wrote:
> > Any C programming technique apart from using this /proc/cpuinfo
> detail?
>
> What about using the machine field of uname(2):
>
> $ man 2 uname
>
> Quoting from that man page:
>
> [...] the operating system presumably knows its name, release
> and version. It also knows what hardware it runs on.
>
> Perhaps a downside, it returns the machine type as a string. Does
> that
> do what you want?
>
> I also find "man linux32" rather interesting:
>
> setarch - change reported architecture in new program environment
> and set personality flags
>
> Might be useful for testing.
>
>
> Greetings,
> Henry
>
Both Ideas give the Kernel architecture not cpu architecture.
You can get exact cpu architecture through lshw command.
*-cpu
product: Intel(R) Pentium(R) Dual CPU E2160 @ 1.80GHz
vendor: Intel Corp.
physical id: 1
bus info: cpu at 0
version: 6.15.13
serial: 0000-06FD-0000-0000-0000-0000
size: 1200MHz
capacity: 1200MHz
width: 64 bits
capabilities: fpu fpu_exception wp vme de pse tsc msr pae mce
cx8 apic mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2
ss ht tm pbe nx x86-64 constant_tsc arch_perfmon pebs bts pni dtes64
monitor ds_cpl est tm2 ssse3 cx16 xtpr pdcm lahf_lm cpufreq
configuration: id=1
*-logicalcpu:0
description: Logical CPU
physical id: 1.1
width: 64 bits
capabilities: logical
*-logicalcpu:1
description: Logical CPU
physical id: 1.2
width: 64 bits
capabilities: logical
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> <mailto:Kernelnewbies@kernelnewbies.org>
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
>
>
>
> --
>
>
> Thanks & Regards,
> ---------PraviN---------
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110127/e8f6faf3/attachment.html
next prev parent reply other threads:[~2011-01-27 12:33 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-27 6:07 How to identity processor architecture prabhu
2011-01-27 6:26 ` Enrico Granata
2011-01-27 6:31 ` arun kumar
2011-01-27 6:40 ` prabhu
2011-01-27 6:45 ` Mulyadi Santosa
2011-01-27 6:54 ` Enrico Granata
2011-01-27 7:15 ` dharmvir kumar
2011-01-27 7:24 ` Mandeep Sandhu
2011-01-27 8:20 ` prabhu
2011-01-27 8:22 ` Enrico Granata
2011-01-27 9:53 ` prabhu
2011-01-27 11:15 ` Henry Gebhardt
2011-01-27 11:32 ` Thirugnanam Balamurugan
2011-01-27 11:44 ` Pravin Shedage
2011-01-27 12:33 ` prabhu [this message]
2011-01-27 9:23 ` Busybox for powerpc doesnt compile Giriprasad Deviprasad
2011-01-27 10:11 ` yy Hong
2011-01-27 13:47 ` Anuz Pratap Singh Tomar
2011-01-29 5:50 ` Giriprasad Deviprasad
2011-01-30 13:23 ` Giriprasad Deviprasad
2011-01-27 7:07 ` How to identity processor architecture prabhu
2011-01-27 7:13 ` Mulyadi Santosa
2011-01-27 19:27 ` mindentropy
2011-01-27 20:01 ` Denis Kirjanov
-- strict thread matches above, loose matches on Subject: below --
2011-01-27 3:28 Added about new kernel on old distro (was Re: most likely, i'll be giving a kernel talk at ottawa LUG next week) Mulyadi Santosa
2011-01-27 6:09 ` How to identity processor architecture prabhu
2011-01-26 18:08 most likely, i'll be giving a kernel talk at ottawa LUG next week Robert P. J. Day
2011-01-27 6:17 ` How to identity processor architecture prabhu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4D416631.9000307@msys-tech.com \
--to=prabhum@msys-tech.com \
--cc=kernelnewbies@lists.kernelnewbies.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.