Strongly Specify Alignment for FFI Allocation

Thomas DuBuisson thomas.dubuisson at
Thu Sep 24 17:02:04 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).

If no glaring issue comes up then I'll formalize / make a ticket,

More information about the Haskell-prime mailing list