Conditional compile if 64-bit cpu, in .xs ?
Conditional compile if 64-bit cpu, in .xs ?
am 28.08.2006 06:00:01 von Peter Billam
Greetings xs folk. Suppose I have a bug-fix in a .xs file looking like
v0 &= 0xffffffff;
which is only necessary on 64-bit architectures... For speed reasons
I'd like to not include that line on 32-bit machines. Is there some
convenient
#ifdef 64whatever
v0 &= 0xffffffff;
#endif
defined by the xs that I can use ?
Regards, Peter
--
AUS/TAS/DPIW/CIT/Servers hbt/lnd/l8 6233 3061 http://www.pjb.com.au
Pasaré, pasarémos dice el agua y canta la verdad contra la piedra
-- Pablo Neruda
Re: Conditional compile if 64-bit cpu, in .xs ?
am 28.08.2006 09:27:22 von Ilya Zakharevich
[A complimentary Cc of this posting was sent to
Peter Billam
], who wrote in article :
> Greetings xs folk. Suppose I have a bug-fix in a .xs file looking like
> v0 &= 0xffffffff;
> which is only necessary on 64-bit architectures... For speed reasons
> I'd like to not include that line on 32-bit machines. Is there some
> convenient
> #ifdef 64whatever
> v0 &= 0xffffffff;
> #endif
> defined by the xs that I can use ?
Why? Just add -DMY_64bit_FIX_NEEDED in Makefile.PL after inspecting
%Config *for the conditions you need*, not some "random thing" being
64-bit...
Hope this helps,
Ilya
Re: Conditional compile if 64-bit cpu, in .xs ?
am 28.08.2006 09:56:06 von Sisyphus
"Peter Billam" wrote in message
news:slrnef4u2h.mnv.peter@localhost.localdomain...
> Greetings xs folk. Suppose I have a bug-fix in a .xs file looking like
> v0 &= 0xffffffff;
> which is only necessary on 64-bit architectures... For speed reasons
> I'd like to not include that line on 32-bit machines. Is there some
> convenient
> #ifdef 64whatever
> v0 &= 0xffffffff;
> #endif
> defined by the xs that I can use ?
>
I don't really know, and am not in a position to test .... is there
something in config.h that can be used ?
Cheers,
Rob
Re: Conditional compile if 64-bit cpu, in .xs ?
am 29.08.2006 01:56:59 von Peter Billam
On 2006-08-28, Ilya Zakharevich wrote:
> Peter Billam wrote:
>> Greetings xs folk. Suppose I have a bug-fix in a .xs file looking like
>> v0 &= 0xffffffff;
>> which is only necessary on 64-bit architectures... For speed reasons
>> I'd like to not include that line on 32-bit machines. Is there some
>> convenient
>> #ifdef 64whatever
>> v0 &= 0xffffffff;
>> #endif
>> defined by the xs that I can use ?
>
> Why? Just add -DMY_64bit_FIX_NEEDED in Makefile.PL
>
OK, I think I get it...
You mean in Makefile.PL have, if ($Config{use64bitint}) then
DEFINE => '-DMY_64bit_FIX_NEEDED',
and then put
#ifdef MY_64bit_FIX_NEEDED
v0 &= 0xffffffff;
#endif
in the .xs ?
> after inspecting %Config *for the conditions you need*,
> not some "random thing" being 64-bit...
>
Presumably in this case I'd be looking for $Config{use64bitint} ?
Thanks for your help, Peter
--
AUS/TAS/DPIW/CIT/Servers hbt/lnd/l8 6233 3061 http://www.pjb.com.au
Pasaré, pasarémos dice el agua y canta la verdad contra la piedra
-- Pablo Neruda
Re: Conditional compile if 64-bit cpu, in .xs ?
am 29.08.2006 04:57:54 von Sisyphus
"Peter Billam"
..
..
> OK, I think I get it...
> You mean in Makefile.PL have, if ($Config{use64bitint}) then
> DEFINE => '-DMY_64bit_FIX_NEEDED',
> and then put
> #ifdef MY_64bit_FIX_NEEDED
> v0 &= 0xffffffff;
> #endif
> in the .xs ?
Yep - that's what he means.
>
..
..
> Presumably in this case I'd be looking for $Config{use64bitint} ?
>
I think you can configure a perl with 'use64bitint' on a 32-bit architecture
iff the compiler supports the 'long long' type.
Maybe that doesn't matter wrt what you're trying to do (though your original
post specified 64-bit architectures) .... or maybe there's a need to also
check $Config{longsize} ... or maybe something else .
I found this in config.h:
---------------------------------------
/* USE_64_BIT_INT:
* This symbol, if defined, indicates that 64-bit integers should
* be used when available. If not defined, the native integers
* will be employed (be they 32 or 64 bits). The minimal possible
* 64-bitness is used, just enough to get 64-bit integers into Perl.
* This may mean using for example "long longs", while your memory
* may still be limited to 2 gigabytes.
*/
/* USE_64_BIT_ALL:
* This symbol, if defined, indicates that 64-bit integers should
* be used when available. If not defined, the native integers
* will be used (be they 32 or 64 bits). The maximal possible
* 64-bitness is employed: LP64 or ILP64, meaning that you will
* be able to use more than 2 gigabytes of memory. This mode is
* even more binary incompatible than USE_64_BIT_INT. You may not
* be able to run the resulting executable in a 32-bit CPU at all or
* you may need at least to reboot your OS to 64-bit mode.
*/
--------------------------------------------
Cheers,
Rob
Re: Conditional compile if 64-bit cpu, in .xs ?
am 29.08.2006 06:14:18 von Peter Billam
On 2006-08-29, Sisyphus wrote:
> "Peter Billam" wrote:
>> Presumably in this case I'd be looking for $Config{use64bitint} ?
>
> I think you can configure a perl with 'use64bitint' on a 32-bit
> architecture iff the compiler supports the 'long long' type.
> Maybe that doesn't matter wrt what you're trying to do (though
> your original post specified 64-bit architectures) ....
Ah, that's just because it was the obvious common factor in where
the test failures had occurred; no informed judgement was involved.
> or maybe there's a need to also check $Config{longsize} ...
I went with longsize, because the offending variables are defined as
unsigned long, and because then if I test $Config{longsize} ne '4'
hopefully it will deal with 128-bit and 256-bit machines too.
Crypt-Tea_JS-2.19.tar.gz seems to work perfectly, and is about to hit
the mirrors :-)
Thanks again for your help, Regards, Peter
--
AUS/TAS/DPIW/CIT/Servers hbt/lnd/l8 6233 3061 http://www.pjb.com.au
Pasaré, pasarémos dice el agua y canta la verdad contra la piedra
-- Pablo Neruda
Re: Conditional compile if 64-bit cpu, in .xs ?
am 29.08.2006 11:23:56 von Ilya Zakharevich
[A complimentary Cc of this posting was sent to
Peter Billam
], who wrote in article :
> You mean in Makefile.PL have, if ($Config{use64bitint}) then
> DEFINE => '-DMY_64bit_FIX_NEEDED',
> and then put
> #ifdef MY_64bit_FIX_NEEDED
> v0 &= 0xffffffff;
> #endif
> in the .xs ?
Definitely not. You use some "random indication" of 64-bitness. Do
you know the EXACT SEMANTIC of 'use64bitint'?
You need to FIND EXACT CONDITIONS for when you NEED your "&=". E.g.,
is it intsize, longsize, ptrsize, longlongsize, or ivsize (or
something else) which should trigger this assignment?
Hope this helps,
Ilya