Unaligned word-sized reads on ByteArray#

Johan Tibell johan.tibell at gmail.com
Sun Oct 24 05:02:50 EDT 2010


I noticed that indexWordArray# only allows for aligned reads (by
forcing the offset to be in words, rather than in bytes.) Is it
possible to perform unaligned reads on a ByteArray# e.g. going via
Addr#? There's the byteArrayContent# primitive but I don't know how to
force the ByteArray# to stay pinned in memory while performing my
reads. The ByteArray# is not guaranteed to be pinned in my case.

A somewhat related question: are there any defines (in e.g.
MachDeps.h) that I could use to detect whether the machine supports
unaligned reads? For example, if I knew the processor architecture, I
could figure that out.


More information about the Glasgow-haskell-users mailing list