Professional Web Applications Themes

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

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

  1. #1

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

    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
    Peter Guest

  2. #2

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

    [A complimentary Cc of this posting was sent to
    Peter Billam
    <pjb.com.au>], who wrote in article <localdomain>: 

    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
    Ilya Guest

  3. #3

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


    "Peter Billam" <dpiwe.tas.gov.au> wrote in message
    news:localdomain... 

    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



    Sisyphus Guest

  4. #4

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

    On 2006-08-28, Ilya Zakharevich <org> wrote: 
    >
    > Why? Just add -DMY_64bit_FIX_NEEDED in Makefile.PL
    >[/ref]
    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 ?
     
    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
    Peter Guest

  5. #5

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


    "Peter Billam" <dpiwe.tas.gov.au>
    ..
    .. 

    Yep - that's what he means.
     
    ..
    .. 

    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


    Sisyphus Guest

  6. #6

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

    On 2006-08-29, Sisyphus <afraid.org> wrote: 
    >
    > 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) ....[/ref]

    Ah, that's just because it was the obvious common factor in where
    the test failures had occurred; no informed judgement was involved.
     

    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
    Peter Guest

  7. #7

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

    [A complimentary Cc of this posting was sent to
    Peter Billam
    <pjb.com.au>], who wrote in article <localdomain>: 

    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
    Ilya Guest

Similar Threads

  1. conditional format
    By Jim Franklin in forum Macromedia Exchange Dreamweaver Extensions
    Replies: 2
    Last Post: January 27th, 08:58 PM
  2. Conditional formating
    By Willem in forum ASP.NET Data Grid Control
    Replies: 2
    Last Post: November 29th, 02:37 PM
  3. Conditional compilation
    By Douglas Harter in forum PERL Beginners
    Replies: 4
    Last Post: November 6th, 05:50 PM
  4. Conditional sum?
    By Fred in forum FileMaker
    Replies: 2
    Last Post: October 28th, 04:16 PM
  5. conditional sql statements
    By Bill in forum ASP
    Replies: 2
    Last Post: August 29th, 07:51 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139