From mboxrd@z Thu Jan 1 00:00:00 1970 From: prabhum@msys-tech.com (prabhu) Date: Thu, 27 Jan 2011 18:03:53 +0530 Subject: How to identity processor architecture In-Reply-To: References: <4D410BBF.10203@msys-tech.com> <4D411359.2010905@msys-tech.com> <4D412AC3.1060003@msys-tech.com> <21BC6FAC-048B-42A7-AA7C-4A89B2D0714A@cs.ucsd.edu> <4D414098.5010706@msys-tech.com> <20110127111549.GA13744@bimsstein> Message-ID: <4D416631.9000307@msys-tech.com> To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org Pravin Shedage wrote: > Hi, > > This C program might help you. > > #include > #include > #include > #include > #include > > 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 > > 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 > > 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