| 745 | } |
| 746 | |
| 747 | static inline void |
| 748 | write_unaligned_byte(uint8_t *ptr, unsigned int len, |
| 749 | unsigned int offset, uint8_t val) |
| 750 | { |
| 751 | uint8_t tmp; |
| 752 | |
| 753 | tmp = ptr[offset / CHAR_BIT]; |
| 754 | tmp &= ~get_bits_mask(len, offset); |
| 755 | tmp |= ((val << (CHAR_BIT - len)) >> (offset % CHAR_BIT)); |
| 756 | ptr[offset / CHAR_BIT] = tmp; |
| 757 | if (((offset + len) / CHAR_BIT) != (offset / CHAR_BIT)) { |
| 758 | int rest_len = (offset + len) % CHAR_BIT; |
| 759 | tmp = ptr[(offset + len) / CHAR_BIT]; |
| 760 | tmp &= ~get_bits_mask(rest_len, 0); |
| 761 | tmp |= val << (CHAR_BIT - rest_len); |
| 762 | ptr[(offset + len) / CHAR_BIT] = tmp; |
| 763 | } |
| 764 | } |
| 765 | |
| 766 | static inline void |
| 767 | write_unaligned_bits(uint8_t *ptr, int len, int offset, uint32_t val) |
no test coverage detected