Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^3: Perl XS portable uint32_t

by almut (Canon)
on Jun 07, 2008 at 10:27 UTC ( [id://690823]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Perl XS portable uint32_t
in thread Perl XS portable uint32_t

I would rather not just compile in the & MASK32 if it is not needed.

That's not what I was trying to say :)   Rather, I meant to imply two things: (a) it might be easier to just do the 32-bit masking yourself, in case you can't easily figure out what the respective magic non-standard __I32_ulong__t incantation is to get the proper 32-bit type on that yet unknown weird 64-bit platform/compiler combo, (b) the performance penalty of doing so is not as big as one might expect.

But you're right, the amount of masking statements actually required may be simplified (I must admit, I hadn't put too much thought into the details here). In particular, masking a, b, c centrally at the beginning of the macro, saves you from having to do so at the end of various other code paths that you do come along...  Interestingly though, there's not much gain in performance from the reduced masking — I now get on average:

Rate u32 u64 u32 56.2/s -- -12% u64 63.7/s 13% --

(under otherwise identical conditions)

Anyhow, I tested your simplified code suggestion, and it's working fine (at least on x86_64-linux).

Thanks for adding another useful module to CPAN!

Replies are listed 'Best First'.
Re^4: Perl XS portable uint32_t
by tachyon-II (Chaplain) on Jun 08, 2008 at 04:15 UTC

    Thanks for testing that. I uploaded version 0.05 a couple of days ago that implemented the dual macro, but did not set the define(s) in the Makefile.PL (I forgot!). The defines used are from Digest::MD5 which have quite a complex makefile setup. Anyway I also changed from using long to perl's U32. Now although the macro must still be the old simple macro it seems to pass on the 64 bit systems it was failing on before (4 of them).

    To test the theory that although perl warns you that you can't depend on U32 being exactly 32 bits wide I uploaded Test::U32 - so far it has not detected a failure case. I will be interesting to know.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://690823]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-03-28 16:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found