Strongly Specify Alignment for FFI Allocation
dons at galois.com
Thu Sep 24 18:13:58 EDT 2009
> Aside from section 5.7 (storable) and comments on 'alignPtr', the only
> mention of alignment in the FFI addendum is on
> "The block of memory is sufficiently aligned for any of the basic
> foreign types (see Section 3.2) that fits into a memory block of the
> allocated size"
> It would be beneficial if this wording was applied to all allocation
> routines - such as mallocForeignPtrBytes, mallocForeignPtrArray, etc.
> For the curious, this proposal was born from the real-world issue of
> pulling Word32's from a ByteString in an efficient but portable manner
> (binary is portable but inefficient, a straight forward
> unsafePerformIO/peek is efficient but need alignment).
As a side issue, the get/put primitives on Data.Binary should be
efficient (though they're about twice as fast when specialized to a
strict bytestring... stay tuned for a package in this area).
More information about the Haskell-prime