From: Sage Weil Date: Fri, 3 Feb 2017 12:55:10 +0000 (-0500) Subject: include/ceph_features: define HAVE_FEATURE helper X-Git-Tag: v12.0.1~467^2~25 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=311476187eac833cccfe9f5265aca01fd3ae2194;p=ceph-ci.git include/ceph_features: define HAVE_FEATURE helper 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 --- diff --git a/src/include/ceph_features.h b/src/include/ceph_features.h index 0828b3dad2f..be5b52da257 100755 --- a/src/include/ceph_features.h +++ b/src/include/ceph_features.h @@ -26,6 +26,13 @@ #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: