How to identify a 32 or 64 bit OS?

T

T

Greetings:

How could I identify if the OS is 32 bit or 64 bit? I need to find a
way to do this that will work on Windows as well as Linux. Thus even
if the processor is 64, you might be running just Windows XP or is it
running Windows XP 64? Same would be true for Linux, although I think
I can use "uname -a" for that. Yes/No?

Thanks in Advance!
Tom
 
T

Ted Zlatanov

T> How could I identify if the OS is 32 bit or 64 bit? I need to find a
T> way to do this that will work on Windows as well as Linux. Thus even
T> if the processor is 64, you might be running just Windows XP or is it
T> running Windows XP 64? Same would be true for Linux, although I think
T> I can use "uname -a" for that. Yes/No?

Leon's suggestions is good, and you can also do

pack "q", 1;

If it fails, you don't have 64 bit support.

(I mention this because recently I argued that the "q" template should
not require 64-bit support, as it does now :)

Ted
 
B

Ben Morrow

Quoth Leon Timmermans said:
Yeah, I also don't understand why "q" can't work on 32bit platforms. Most
common 32 bit platforms support 64 bit integers these days. It has to be
possible to make some kind of hack to include this support. Math::Int64
seems to be able to do it, so I don't see why perl itself can't.

It can, you just need to build perl correctly:

~% uname -m
i386
~% sysctl hw.model
hw.model: Intel(R) Pentium(R) 4 CPU 1500MHz
~% perl -V:'(ptr|long|iv)size'
ivsize='8';
longsize='4';
ptrsize='4';
~% perl -le'print unpack "q", pack "q", 2**54'
18014398509481984
~% perl -v

This is perl, v5.8.8 built for i386-freebsd-64int

Ben
 
T

Ted Zlatanov

BM> It can, you just need to build perl correctly:

Why should a 32-bit build be unable to construct or interpret a 64-bit
value? It's not particularly hard, after all, and it could take/return
a string or a bigint. I'll continue this in perl5-porters.

Ted
 
T

T

T> How could I identify if the OS is 32 bit or 64 bit? I need to find a
T> way to do this that will work on Windows as well as Linux. Thus even
T> if the processor is 64, you might be running just Windows XP or is it
T> running Windows XP 64? Same would be true for Linux, although I think
T> I can use "uname -a" for that. Yes/No?

Leon's suggestions is good, and you can also do

pack "q", 1;

If it fails, you don't have 64 bit support.

(I mention this because recently I argued that the "q" template should
not require 64-bit support, as it does now :)

Ted

I thought that was it, however when I try that I get:

64 bit machine:

% test
Useless use of pack in void context at test line 4.
1

% perl -v

This is perl, v5.8.8 built for i686-linux-ld

On the 32 bit machine I get:

% test
Useless use of pack in void context at test line 4.
Invalid type 'q' in pack at test line 4.

% perl -v

This is perl, v5.8.8 built for i686-linux-ld

Copyright 1987-2006, Larry Wall

Thanks
Tom
 
I

Ilya Zakharevich

[A complimentary Cc of this posting was sent to
Ted Zlatanov
LT> Yeah, I also don't understand why "q" can't work on 32bit platforms. Most
LT> common 32 bit platforms support 64 bit integers these days. It has to be
LT> possible to make some kind of hack to include this support. Math::Int64
LT> seems to be able to do it, so I don't see why perl itself can't.

I asked on perl5-porters, let's see what they say.

The perl's I build support this for many years. I submitted the patch
about 2003.

Hope this helps,
Ilya
 
T

Ted Zlatanov

T> How could I identify if the OS is 32 bit or 64 bit? I need to find a
T> way to do this that will work on Windows as well as Linux. Thus even
T> if the processor is 64, you might be running just Windows XP or is it
T> running Windows XP 64? Same would be true for Linux, although I think
T> I can use "uname -a" for that. Yes/No?
T> I thought that was it, however when I try that I get:

T> 64 bit machine:

T> % test
T> Useless use of pack in void context at test line 4.
T> 1

I would recommend Leon's solution instead of mine, as I am arguing that
the "q" template SHOULD be provided in 32-bit Perl.

Ted
 
T

Ted Zlatanov

IZ> [A complimentary Cc of this posting was sent to
IZ> Ted Zlatanov
LT> Yeah, I also don't understand why "q" can't work on 32bit platforms. Most
LT> common 32 bit platforms support 64 bit integers these days. It has to be
LT> possible to make some kind of hack to include this support. Math::Int64
LT> seems to be able to do it, so I don't see why perl itself can't.
IZ> The perl's I build support this for many years. I submitted the patch
IZ> about 2003.

Do you know why the patch hasn't been accepted yet? I couldn't find it
through Google or archive searches.

Ted
 
I

Ilya Zakharevich

[A complimentary Cc of this posting was sent to
Ted Zlatanov
IZ> The perl's I build support this for many years. I submitted the patch
IZ> about 2003.

Do you know why the patch hasn't been accepted yet? I couldn't find it
through Google or archive searches.

I have no idea. I think I'm sitting on a hundred of such patches... :-(

Yours,
Ilya

P.S. I tried to google for it, and could not find it either...
I have 2 versions, for 5.8.2, and for 5.8.7.
 
S

szr

Ted Zlatanov wrote:
[...]
I would recommend Leon's solution instead of mine, as I am arguing
that the "q" template SHOULD be provided in 32-bit Perl.

It's not 32bit Perl that doesn't 'q' - it very much does - it's whether
or not perl was compiled with 64 bit integer *support*, for example:

cd perl-5.10.0
./Configure -Dprefix=/usr/local/perl5.10.0 -Duse64bitint
make && make test && make install

That will set the option on by default. It will still ask you but it
will already be on so you can just hit enter.

This works perfectly fine on a 32bit Linux machine.
 
I

Ilya Zakharevich

[A complimentary Cc of this posting was sent to
szr
It's not 32bit Perl that doesn't 'q' - it very much does - it's whether
or not perl was compiled with 64 bit integer *support*, for example:

cd perl-5.10.0
./Configure -Dprefix=/usr/local/perl5.10.0 -Duse64bitint
make && make test && make install

That will set the option on by default. It will still ask you but it
will already be on so you can just hit enter.

This works perfectly fine on a 32bit Linux machine.

Nobody said anything about 32bit OSes, so it you who changed the
topic - from 32bit Perl's.

No, (without my patches) quad operations do not work in Perl even if
it has 64bit integer support. They work only if perl uses 64bit
integers for its "integer slots".

The difference is between $Config{d_longlong} (has SUPPORT for 64bit
int) and $Config{use64bitint} (USES 64bit int).

Hope this helps,
Ilya
 
S

sisyphus

.
.
No, (without my patches) quad operations do not work in Perl even if
it has 64bit integer support.  They work only if perl uses 64bit
integers for its "integer slots".

Which, I envisage, is what Ben Morrow was getting at when he said "It
can, you just need to build perl correctly".

Is it correct to paraphrase that second sentence of Ilya's that I've
quoted as:

"They work only if $Config{ivsize} == 8"

I would think that's correct ... but I'm not a lawyer.

Anyway, if those are the conditions for quad operations working, then
it seems to me that Ilya's patches (or equivalent) have already been
implemented - since, on a 32-bit OS (linux), I can 'pack "q", 1;' iff
$Config{ivsize} == 8.

And even if $Config{d_longlong} eq 'define', I find that quad
operations will not work unless $Config{ivsize} == 8.

I gather Ted's argument would be that quad operations should work if
*either* $Config{d_longlong} eq 'define' *or* $Config{ivsize} == 8.

As an aside, on the only 64-bit perl (ActivePerl) that I have on Win32
(Vista 64), $Config{d_longlong} eq 'undef', $Config{use64bitint} eq
'define', $Config{ivsize} == 8, and quad operations work fine. (This
is just meant to demonstrate that the value of $Config{d_longlong}
ought not be the *sole* consideration - but everyone probably knew
that, anyway :)

Cheers,
Rob
 
I

Ilya Zakharevich

[A complimentary Cc of this posting was sent to
sisyphus
Anyway, if those are the conditions for quad operations working, then
it seems to me that Ilya's patches (or equivalent) have already been
implemented - since, on a 32-bit OS (linux), I can 'pack "q", 1;' iff
$Config{ivsize} =3D=3D 8.

No. Obviously, which processor opcodes the kernel uses is not
relevant to the discussion, so the question of 32bit OS vs 64bit OS is
orthogonal to the discussion. The question is whether Perl is
compiled with 32bit integers (quick, takes smaller memory footprint)
or with 64bit integers (slower, larger memory).
And even if $Config{d_longlong} eq 'define', I find that quad
operations will not work unless $Config{ivsize} =3D=3D 8.

As I said: as expected without my patch.

Hope this helps,
Ilya
 
T

Ted Zlatanov

IZ> [A complimentary Cc of this posting was sent to
IZ> sisyphus

IZ> As I said: as expected without my patch.

I mentioned it on perl5-porters and CC-d you but the mail bounced. Do
you want to put the effort into putting something together?

Ted
 
M

Mark L Pappin

Ilya Zakharevich said:
Nobody said anything about 32bit OSes,

Seems to me that the OP did, in the Subject header.

That the OS's 64-bitness *does not matter* seems to have escaped those
who've continued this thread with Subject unchanged.

mlp
 
I

Ilya Zakharevich

[A complimentary Cc of this posting was sent to
Ted Zlatanov
I mentioned it on perl5-porters and CC-d you but the mail bounced.

To the mail in this posting? Strange, at least some spam is reaching
me on this address... :-( ;-)
Do you want to put the effort into putting something together?

As I said, I'm sitting on zillions of such patches... Without
external funding, I'm afraid I would not be able to go through them
again...

Yours,
Ilya
 
T

Ted Zlatanov

IZ> [A complimentary Cc of this posting was sent to
IZ> Ted Zlatanov

IZ> To the mail in this posting? Strange, at least some spam is reaching
IZ> me on this address... :-( ;-)

OK, I'll try again next time.

IZ> As I said, I'm sitting on zillions of such patches... Without
IZ> external funding, I'm afraid I would not be able to go through them
IZ> again...

Send me the files you think may contain the patch and I'll see if I can
figure it out, unless that's not possible either.

Thanks
Ted
 
I

Ilya Zakharevich

[A complimentary Cc of this posting was sent to
Ted Zlatanov
IZ> As I said, I'm sitting on zillions of such patches... Without
IZ> external funding, I'm afraid I would not be able to go through them
IZ> again...

Send me the files you think may contain the patch and I'll see if I can
figure it out, unless that's not possible either.

ilyaz.org/software/tmp/diff_582_21574_quad-tot

is last directly applicable to 5.8.7.

Hope this helps,
Ilya
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,434
Messages
2,571,691
Members
48,796
Latest member
Greg L.

Latest Threads

Top