Re: How to identity processor architecture

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx> 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

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



--


Thanks & Regards,
---------PraviN---------


_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux