MCPcopy Create free account
hub / github.com/F-Stack/f-stack / write_unaligned_byte

Function write_unaligned_byte

dpdk/lib/hash/rte_thash.c:747–764  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

745}
746
747static inline void
748write_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
766static inline void
767write_unaligned_bits(uint8_t *ptr, int len, int offset, uint32_t val)

Callers 1

write_unaligned_bitsFunction · 0.85

Calls 1

get_bits_maskFunction · 0.85

Tested by

no test coverage detected