Patch: new primops for byte range copies ByteArray# <-> Addr#
Currently we have:
-
copyByteArray#
forByteArray#
toMutableByteArray#
-
copyMutableByteArray#
forMutableByteArray#
toMutableByteArray#
This patch adds primops for similar cases involving Addr#
s, that is pointers to pinned or foreign memory.
-
copyByteArrayToAddr#
forByteArray#
toAddr#
-
copyMutableByteArrayToAddr#
forMutableByteArray#
toAddr#
-
copyAddrToByteArray#
forAddr#
toMutableByteArray#
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.
Trac metadata
Trac field | Value |
---|---|
Version | 7.6.3 |
Type | FeatureRequest |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |