Re: How to determine if running on a 32 or 64 bits kernel ?
- From: laurent.charmet@xxxxxxxxx
- Date: Thu, 14 Feb 2008 06:05:47 -0800 (PST)
On Feb 14, 3:42 pm, Bernhard Agthe <dark2s...@xxxxxxx> wrote:
laurent.char...@xxxxxxxxx wrote:
I'm looking for an API or whatever to determine if kernel/os is 32 or
64 bits. It must be dynamic, because my binary can be compiled on a
machine and run on another. So sizeof(void*) is useless since it give
4 if my program was compiled on a 32 bits linux, even if I run it on a
64 bits.
I do not find information in /proc nor in sysconf, sysinfo etc ...
The only solution, but very crappy is to make a popen of "file -b /usr/
bin/file" and search for string "64" ...
uname -a
It's not very reliable. Uname -m give me "x86_64" on a 64 bits intel
linux and "i686" on a 32 bits. But linux run on others platform not
only intel. And how to know for PPC (first PPC was 32 bits) etc ... I
do not want to use string.
sizeof (void*) will give you the size of a pointer to nothing ;-)
A program compiled on 32 bit and linked with 32 bit libs will always be
32 bit... Sizeof is usually evaluated during compile time.
Yes It's what I say, we both agree on that.
I'm a bit suprised that there is no simple solution to find this
information. On AIX sysconf(_SC_AIX_KERNEL_BITMODE) give the answer.
On HPUX it's about the same thing: sysconf(_SC_KERNEL_BITS). And I
want to have this information without any privilege (do not want to
open kernel for example !)
regards
.
- Follow-Ups:
- Re: How to determine if running on a 32 or 64 bits kernel ?
- From: phil-news-nospam
- Re: How to determine if running on a 32 or 64 bits kernel ?
- References:
- How to determine if running on a 32 or 64 bits kernel ?
- From: laurent . charmet
- Re: How to determine if running on a 32 or 64 bits kernel ?
- From: Bernhard Agthe
- How to determine if running on a 32 or 64 bits kernel ?
- Prev by Date: How to determine if running on a 32 or 64 bits kernel ?
- Next by Date: Re: How to determine if running on a 32 or 64 bits kernel ?
- Previous by thread: Re: How to determine if running on a 32 or 64 bits kernel ?
- Next by thread: Re: How to determine if running on a 32 or 64 bits kernel ?
- Index(es):
Relevant Pages
|