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

Mike Loseke mike at verinet.com
Mon Jun 11 16:08:24 MDT 2001


Thus spake Tkil:
> >>>>> "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

 Sweet, I'll see if I can use that nice bit of code across platforms. Looks
like Bill tested it successfully on ia64 too.


> 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:

 Woops, now I remember. The versions of perl here is compiled with the
least common denominator in mind which required it being compiled on a
32-bit machine. Self-limiting there...


> 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.

 I'm using a couple other pieces of tried and true deduction, noted in
another email, I'm mainly looking for something similar here to use on
Linux. Your proggy looks to be the best so far.

> 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.  :)

 Oog. Not even gonna tackle the brute force method. :-)

 Thanks for the help!

-- 
   Mike Loseke    | If at first you don't succeed,
 mike at verinet.com | increase the amperage.



More information about the NCLUG mailing list