Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^8: Module for 128-bit integer math?

by ikegami (Patriarch)
on Feb 09, 2011 at 16:07 UTC ( [id://887232]=note: print w/replies, xml ) Need Help??


in reply to Re^7: Module for 128-bit integer math?
in thread Module for 128-bit integer math?

So you say that newSV(16) always allocates the bytes on a suitable memory boundary. I didn't know of any such guarantee, thus my question.

Well, then you can replace those calls to Copy with casts and assignments

Update: Fixed bad grammar. Also, the second paragraph should be ignored because it makes sense to support passing OOK strings to native_to_int128 functions.

Replies are listed 'Best First'.
Re^9: Module for 128-bit integer math?
by salva (Canon) on Feb 09, 2011 at 17:07 UTC
    So you say that newSV(16) always allocates the bytes on a 128-bit aligned

    No, what I say is that the code generated by GCC uses 64bit operations to move data between the memory and the processor registers so a 128bits alignment is not really required.

    Any sane allocator will return memory aligned for 64bits or better. Perl custom allocator (used when set from Configure) guarantees that alignment would be suitable for doubles (so, 64bits)... or at least that's what a comment says in the place where MEM_ALIGNBYTES macro is introduced.

    update: Regarding the use of Copy, yes, it is because any string allocated outside the module can be unaligned. That includes SVs using the OOK hack and probably others.

      Thanks!

      Update: I guess the issue will need to be revisited when systems support native 128-bit operations.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-04-19 23:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found