1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(C) 2021 Marvell. 3 */ 4 5 #ifndef _ROC_BITFIELD_H_ 6 #define _ROC_BITFIELD_H_ 7 8 #define __bf_shf(x) (__builtin_ffsll(x) - 1) 9 10 #define FIELD_PREP(mask, val) (((typeof(mask))(val) << __bf_shf(mask)) & (mask)) 11 12 #define FIELD_GET(mask, reg) \ 13 ((typeof(mask))(((reg) & (mask)) >> __bf_shf(mask))) 14 15 #endif /* _ROC_BITFIELD_H_ */ 16