What is the best way to implement a bitwise memmove? The method should take an additional destination and source bit-offset and the count should be in bits too.
- I saw that ARM provides a non-standard
_membitmove, which does exactly what I need, but I couldn't find its source. - Bind's bitset includes
isc_bitstring_copy, but it's not efficient - I'm aware that the C standard library doesn't provide such a method, but I also couldn't find any third-party code providing a similar method.
Here is a partial implementation (not tested). There are obvious efficiency and usability improvements.
Copy
nbytes fromsrctodest(not overlappingsrc), and shift bits atdestrightwards bybitbits, 0 <=bit<= 7. This assumes that the least significant bits are at the right of the bytesSome improvements to be made:
bitbits at beginning ofdest.