]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - include/linux/bitfield.h
UBUNTU: SAUCE: LSM stacking: allow selecting multiple LSMs using kernel boot params
[mirror_ubuntu-artful-kernel.git] / include / linux / bitfield.h
index f6505d83069d4b0969688ee2e05e30bd08227fe7..8b9d6fff002db113cb2233a2d80b3186ff041ef0 100644 (file)
                                              (1ULL << __bf_shf(_mask))); \
        })
 
+/**
+ * FIELD_FIT() - check if value fits in the field
+ * @_mask: shifted mask defining the field's length and position
+ * @_val:  value to test against the field
+ *
+ * Return: true if @_val can fit inside @_mask, false if @_val is too big.
+ */
+#define FIELD_FIT(_mask, _val)                                         \
+       ({                                                              \
+               __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_FIT: ");     \
+               !((((typeof(_mask))_val) << __bf_shf(_mask)) & ~(_mask)); \
+       })
+
 /**
  * FIELD_PREP() - prepare a bitfield element
  * @_mask: shifted mask defining the field's length and position