Changeset View
Changeset View
Standalone View
Standalone View
sys/compat/linuxkpi/common/include/linux/bitfield.h
Show First 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | |||||
_leX_encode_bits(64) | _leX_encode_bits(64) | ||||
_leX_encode_bits(32) | _leX_encode_bits(32) | ||||
_leX_encode_bits(16) | _leX_encode_bits(16) | ||||
static __inline void | static __inline void | ||||
le32p_replace_bits(uint32_t *p, uint32_t v, uint32_t f) | le32p_replace_bits(uint32_t *p, uint32_t v, uint32_t f) | ||||
{ | { | ||||
*p = (*p & ~(cpu_to_le32(v))) | le32_encode_bits(v, f); | *p = (*p & ~(cpu_to_le32(f))) | le32_encode_bits(v, f); | ||||
} | } | ||||
#define __bf_shf(x) (__builtin_ffsll(x) - 1) | #define __bf_shf(x) (__builtin_ffsll(x) - 1) | ||||
#define FIELD_PREP(_mask, _value) \ | #define FIELD_PREP(_mask, _value) \ | ||||
(((typeof(_mask))(_value) << __bf_shf(_mask)) & (_mask)) | (((typeof(_mask))(_value) << __bf_shf(_mask)) & (_mask)) | ||||
#define FIELD_GET(_mask, _value) \ | #define FIELD_GET(_mask, _value) \ | ||||
((typeof(_mask))(((_value) & (_mask)) >> __bf_shf(_mask))) | ((typeof(_mask))(((_value) & (_mask)) >> __bf_shf(_mask))) | ||||
#endif /* _LINUX_BITFIELD_H */ | #endif /* _LINUX_BITFIELD_H */ |