[NCLUG] simple way to determine 32 or 64 bit?

Tkil tkil at scrye.com
Mon Jun 11 15:49:49 MDT 2001


>>>>> "Mike" == Mike Loseke <mike at verinet.com> writes:

Mike> Thus spake Tkil:
>> 
>> or, if you trust that perl was compiled sanely:
>> 
>> | $ perl -MConfig -le 'print $Config{longsize}*8' 
>> | 32

Mike> Returns 32 on my 64-bit Suns and HP's. :-) What compile-time
Mike> option did I miss in perl?

this bit of Configure seems to be the most apropriate:

| case "$usemorebits" in
| "$define"|true|[yY]*)
|         use64bitint="$define"
|         uselongdouble="$define"
|         usemorebits="$define"
|         ;;
| *)      usemorebits="$undef"
|         ;;
| esac

Mike> Userland definitely. 

well, it looks like the silly little C program i posted might do the
trick, since it lives in userspace all the time -- i'd only be worried
that you'd have to compile it correctly.  on a 64-bit HP-UX box:

| $ aCC -o bit-count bit-count.c      
| $ ./bit-count   
| 32
| $ aCC +DA2.0W -o bit-count-64 bit-count.c      
| $ ./bit-count-64
| 64

the perl on this box was also built as a 32-bit perl, so it's pretty
common -- i think there might even have been issues with the 64-bit
support as late as 5.004.  yeah, there's a chunk of changes to 64-bit
support in 5.6.0:

   There are actually two modes of 64-bitness: the first one is
   achieved using Configure -Duse64bitint and the second one using
   Configure -Duse64bitall.  The difference is that the first one is
   minimal and the second one maximal.  The first works in more places
   than the second.

along with the following caveat:

   NOTE: 64-bit support is still experimental on most platforms.
   Existing support only covers the LP64 data model.  In particular,
   the LLP64 data model is not yet supported.  64-bit libraries and
   system APIs on many platforms have not stabilized--your mileage may
   vary.

anyway, back to your current problem.  the bit-count program might
help, but there are the compilation issues above.  do you have
solutions that work on other platforms, and you're looking just for
linux solutions?  thorson did report that his IA64 box returned 64
from that program, but i don't know if there were special compilation
flags involved or not.

so, no real answer.  :( you might try grovelling through glibc docs,
to see if it has some variant on "sysconf" or similar.  or, you could
try the brute force approach -- try to run the program in question in
64-bit mode, and if it fails, fall back to the 32-bit version.  :)

good luck,
t.



More information about the NCLUG mailing list