|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v4 02/11] x86/intel_pstate: add some calculation related support
> > +/*
> > + * clamp_t - return a value clamped to a given range using a given
> > +type
> > + * @type: the type of variable to use
> > + * @val: current value
> > + * @lo: minimum allowable value
> > + * @hi: maximum allowable value
> > + *
> > + * This macro does no typechecking and uses temporary variables of
> > +type
> > + * 'type' to make all the comparisons.
> > + */
> > +#define clamp_t(type, val, lo, hi) min_t(type, max_t(type, val, lo),
> > +hi)
>
> Shouldn't you also add a type checking variant then (which ought to be used
> instead of the one above wherever possible)?
>
Hi Jan, I think the max_t() and min_t() have handled the typechecking thing,
maybe we do not need to do it again here.
If you have a different opinion, how should we do a typechecking here? Is the
following what you expected?
#define clamp_t(type, val, lo, hi) \
({ type _val = (val); \
type _lo = (lo); \
type _hi = (hi); \
min_t(type, max_t(type, _val, _lo), _hi)
})
Best,
Wei
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |