Click here to get back home

Conditional compile if 64-bit cpu, in .xs ?

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Conditional compile if 64-bit cpu, in .xs ? Peter Billam 08-28-2006
Posted by Peter Billam on August 28, 2006, 12:00 am
Please log in for more thread options


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

Posted by Ilya Zakharevich on August 28, 2006, 3:27 am
Please log in for more thread options


[A complimentary Cc of this posting was sent to
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 ?

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

Posted by Peter Billam on August 28, 2006, 7:56 pm
Please log in for more thread options


> 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) 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 ?

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

Posted by Sisyphus on August 28, 2006, 10:57 pm
Please log in for more thread options



.
.
> OK, I think I get it...
> You mean in Makefile.PL have, if ($Config) 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 ?
>

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



Posted by Peter Billam on August 29, 2006, 12:14 am
Please log in for more thread options


>> Presumably in this case I'd be looking for $Config ?
>
> 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 ...

I went with longsize, because the offending variables are defined as
unsigned long, and because then if I test $Config 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

Similar ThreadsPosted
Help Compiling XML::Parser On AIX 5.2 64bit September 18, 2005, 9:57 pm
Conditional compilation November 5, 2004, 5:20 pm
Net::Nessus 0.09 does not compile October 26, 2004, 9:04 am
How do we compile for perl? April 10, 2005, 11:01 pm
Compile of DB::DB2 on cygwin June 15, 2005, 7:38 pm
Help with Math::GMP compile on AIX 5.3 September 11, 2007, 4:47 pm
compile problems with XML::LibXML December 22, 2004, 5:41 pm
Des::Crypt Will not Compile On Solaris 8 Using GCC December 7, 2005, 2:58 pm
Trying to compile MP3::Info gives errors December 12, 2005, 11:17 am
Mac OSX Tiger getting module to compile January 3, 2006, 9:45 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap