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