_membitcpybl(), _membitcpybb(), _membitcpyhl(), _membitcpyhb(), _membitcpywl(), _membitcpywb(), _membitmovebl(), _membitmovebb(), _membitmovehl(), _membitmovehb(), _membitmovewl(), _membitmovewb()
Similar to the standard C library memcpy() and memmove() functions, these nonstandard C library functions provide bit-aligned memory operations.
They are defined in string.h.
void _membitcpy[b|h|w][b|l](void *dest, const void *src, int dest_offset, int src_offset, size_t nbits);
void _membitmove[b|h|w][b|l](void *dest, const void *src, int dest_offset, int src_offset, size_t nbits);
The number of contiguous bits specified by nbits is copied, or moved (depending on the function being used), from a memory location starting src_offset bits after (or before if a negative offset) the address pointed to by src , to a location starting dest_offset bits after (or before if a negative offset) the address pointed to by dest .
To define a contiguous sequence of bits, a form of ordering is required. The variants of each function define this order, as follows:
Functions whose second-last character is b, for example _membitcpybl(), are byte-oriented. Byte-oriented functions consider all of the bits in one byte to come before the bits in the next byte.
Functions whose second-last character is h are halfword-oriented.
Functions whose second-last character is w are word-oriented.
Within each byte, halfword, or word, the bits can be considered to go in different order depending on the endianness. Functions ending in b, for example _membitmovewb(), are bitwise big-endian. This means that the Most Significant Bit (MSB) of each byte, halfword, or word (as appropriate) is considered to be the first bit in the word, and the Least Significant Bit (LSB) is considered to be the last. Functions ending in l are bitwise little-endian. They consider the LSB to come first and the MSB to come last.
As with memcpy() and memmove(), the bitwise memory copying functions copy as fast as they can in their assumption that source and destination memory regions do not overlap, whereas the bitwise memory move functions ensure that source data in overlapping regions is copied before being overwritten.
On a little-endian platform, the bitwise big-endian functions are distinct, but the bitwise little-endian functions use the same bit ordering, so they are synonymous symbols that refer to the same function. On a big-endian platform, the bitwise big-endian functions are all effectively the same, but the bitwise little-endian functions are distinct.