Spread value into buffer according to bit-mask. */
| 7614 | |
| 7615 | /** Spread value into buffer according to bit-mask. */ |
| 7616 | static size_t |
| 7617 | arg_entry_bf_fill(void *dst, uintmax_t val, const struct arg *arg) |
| 7618 | { |
| 7619 | uint32_t i = arg->size; |
| 7620 | uint32_t end = 0; |
| 7621 | int sub = 1; |
| 7622 | int add = 0; |
| 7623 | size_t len = 0; |
| 7624 | |
| 7625 | if (!arg->mask) |
| 7626 | return 0; |
| 7627 | #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN |
| 7628 | if (!arg->hton) { |
| 7629 | i = 0; |
| 7630 | end = arg->size; |
| 7631 | sub = 0; |
| 7632 | add = 1; |
| 7633 | } |
| 7634 | #endif |
| 7635 | while (i != end) { |
| 7636 | unsigned int shift = 0; |
| 7637 | uint8_t *buf = (uint8_t *)dst + arg->offset + (i -= sub); |
| 7638 | |
| 7639 | for (shift = 0; arg->mask[i] >> shift; ++shift) { |
| 7640 | if (!(arg->mask[i] & (1 << shift))) |
| 7641 | continue; |
| 7642 | ++len; |
| 7643 | if (!dst) |
| 7644 | continue; |
| 7645 | *buf &= ~(1 << shift); |
| 7646 | *buf |= (val & 1) << shift; |
| 7647 | val >>= 1; |
| 7648 | } |
| 7649 | i += add; |
| 7650 | } |
| 7651 | return len; |
| 7652 | } |
| 7653 | |
| 7654 | /** Compare a string with a partial one of a given length. */ |
| 7655 | static int |
no outgoing calls
no test coverage detected