On Wed, Jun 22, 2016 at 08:19:44AM +0200, David Hildenbrand wrote: > > On 22.06.2016 15:02, David Hildenbrand wrote: > > > Let's use the generated groups to create feature group representations for > > > the user. These groups can later be used to enable/disable multiple > > > features in one shot and will be used to reduce the amount of reported > > > features to the user if all subfeatures are in place. > > > > > > Acked-by: Cornelia Huck <cornelia.h...@de.ibm.com> > > > Signed-off-by: David Hildenbrand <d...@linux.vnet.ibm.com> > > > --- > > > target-s390x/cpu_features.c | 44 > > > +++++++++++++++++++++++++++++++++++++++++++- > > > target-s390x/cpu_features.h | 23 +++++++++++++++++++++++ > > > 2 files changed, 66 insertions(+), 1 deletion(-) > > > > > > diff --git a/target-s390x/cpu_features.c b/target-s390x/cpu_features.c > > > index c78a189..6ec2bfc 100644 > > > --- a/target-s390x/cpu_features.c > > > +++ b/target-s390x/cpu_features.c > > > @@ -12,6 +12,7 @@ > > > > > > #include "qemu/osdep.h" > > > #include "cpu_features.h" > > > +#include "gen-features.h" > > > > > > #define FEAT_INIT(_name, _type, _bit, _desc) \ > > > { \ > > > @@ -321,14 +322,55 @@ void s390_add_from_feat_block(S390FeatBitmap > > > features, S390FeatType type, > > > } > > > } > > > > > > -void s390_feat_bitmap_to_ascii(const S390FeatBitmap bitmap, void *opaque, > > > +void s390_feat_bitmap_to_ascii(const S390FeatBitmap features, void > > > *opaque, > > > void (*fn)(const char *name, void > > > *opaque)) > > > { > > > + S390FeatBitmap bitmap, tmp; > > > + S390FeatGroup group; > > > S390Feat feat; > > > > > > + bitmap_copy(bitmap, features, S390_FEAT_MAX); > > > + > > > + /* process whole groups first */ > > > + for (group = 0; group < S390_FEAT_GROUP_MAX; group++) { > > > + const S390FeatGroupDef *def = s390_feat_group_def(group); > > > + > > > + bitmap_and(tmp, bitmap, def->feat, S390_FEAT_MAX); > > > + if (bitmap_equal(tmp, def->feat, S390_FEAT_MAX)) { > > > + bitmap_andnot(bitmap, bitmap, def->feat, S390_FEAT_MAX); > > > + (*fn)(def->name, opaque); > > > > Maybe simply write > > fn(dev->name, opaque); > > instead? > > Will that work? As fn is a pointer I am not a 100% sure. If so, I'll change > it!
Both are 100% equivalent. Actually, the expression denoting the function to be called has to be a function pointer, but (*fn) happens to be magically converted back to a function pointer because the spec says so. -- Eduardo