Patch: new primops for byte range copies ByteArray# <-> Addr#
|Reported by:||duncan||Owned by:|
|Type of failure:||None/Unknown||Test Case:|
|Related Tickets:||Differential Revisions:|
Currently we have:
- copyByteArray# for ByteArray# to MutableByteArray#
- copyMutableByteArray# for MutableByteArray# to MutableByteArray#
This patch adds primops for similar cases involving Addr#s, that is pointers to pinned or foreign memory.
- copyByteArrayToAddr# for ByteArray# to Addr#
- copyMutableByteArrayToAddr# for MutableByteArray# to Addr#
- copyAddrToByteArray# for Addr# to MutableByteArray#
These are not covered by the existing primops of course, and are useful because ByteArray#s are a bit special, sometimes being unpinned, and being aligned, and being so primitve/built-in. It's true we could use FFI import of memcpy using the GHC's FFI extension to turn ByteArray# into a pointer on the C side. However we don't do that for the existing primops and we're following the same pattern here. (Good reasons for them all to be primops: abstracts the backend/platform better, can take advantage of known allignment and size info).
In particular, these primops would be useful in the impl of low level libs like bytestring, text, array, binary etc.
Change History (11)
Changed 21 months ago by duncan
Changed 20 months ago by duncan
comment:6 Changed 20 months ago by thoughtpolice
- Resolution set to fixed
- Status changed from patch to closed