]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
include/ceph_features: define HAVE_FEATURE helper
authorSage Weil <sage@redhat.com>
Fri, 3 Feb 2017 12:55:10 +0000 (07:55 -0500)
committerSage Weil <sage@redhat.com>
Mon, 6 Feb 2017 20:43:50 +0000 (15:43 -0500)
This lets you test a feature succintly by name, *AND* makes use of the
FEATUREMASK so that it can be used on bitmasks that may come from old
versions with prior usages of the bit.  This makes it usable for data
type encoding or with client-provided bits.

Signed-off-by: Sage Weil <sage@redhat.com>
src/include/ceph_features.h

index 0828b3dad2f35957973241eff54102f716dc9f4f..be5b52da2575eef17ff5c93c5bb6618cc00e2b42 100755 (executable)
 #define DEFINE_CEPH_FEATURE_RETIRED(bit, inc, name, unused, unadvertised)
 
 
+// test for a feature.  this test is safer than a typical mask against
+// the bit because it ensures that we have the bit AND the marker for the
+// bit's incarnation.  this must be used in any case where the features
+// bits may include an old meaning of the bit.
+#define HAVE_FEATURE(x, name)                          \
+       (((x) & (CEPH_FEATUREMASK_##name)) == (CEPH_FEATUREMASK_##name))
+
 
 /*
  * Notes on deprecation: