| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Hmssql.Tds.Bytes.Unsafe
Description
Unchecked little-endian loads and stores through raw pointers.
Use Hmssql.Tds.Bytes for bounds-checked reads from a ByteString.
Every operation needs a valid span of 2, 4 or 8 bytes at the given byte offset. A read needs memory that is initialized and readable, and a write needs memory that is writable and that nothing else expects to stay as it was. The caller keeps the allocation alive for the whole call and makes sure the offset arithmetic doesn't overflow. Nothing here checks a capacity, an initialization, an ownership or a lifetime.
Alignment is handled here: on targets known to load and store words at any address an operation is one word access, and elsewhere it goes byte by byte. The functions are public for codecs and transports written outside hmssql.
Unchecked pointer reads
peekWord16LE :: Ptr Word8 -> Int -> IO Word16 Source #
A little-endian 16-bit word at a byte offset from the pointer.
peekWord32LE :: Ptr Word8 -> Int -> IO Word32 Source #
A little-endian 32-bit word at a byte offset from the pointer.
peekWord64LE :: Ptr Word8 -> Int -> IO Word64 Source #
A little-endian 64-bit word at a byte offset from the pointer.
Unchecked pointer writes
pokeWord16LE :: Ptr Word8 -> Int -> Word16 -> IO () Source #
Store a 16-bit word little-endian at a byte offset from the pointer.