xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@suse.com>
To: Wei W Wang <wei.w.wang@intel.com>
Cc: "andrew.cooper3@citrix.com" <andrew.cooper3@citrix.com>,
	"xen-devel@lists.xen.org" <xen-devel@lists.xen.org>
Subject: Re: [PATCH v4 02/11] x86/intel_pstate: add some calculation related support
Date: Tue, 11 Aug 2015 04:07:31 -0600	[thread overview]
Message-ID: <55C9E5830200007800099751@prv-mh.provo.novell.com> (raw)
In-Reply-To: <286AC319A985734F985F78AFA26841F79E4118@shsmsx102.ccr.corp.intel.com>

>>> On 27.07.15 at 07:48, <wei.w.wang@intel.com> wrote:
>> > +/*
>> > + * 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)
> })

I don't think you understood: I asked for a clamp() to accompany
clamp_t(), just like e.g. max_t() is a less preferred sibling of max().

Jan

  reply	other threads:[~2015-08-11 10:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-25 11:14 [PATCH v4 02/11] x86/intel_pstate: add some calculation related support Wei Wang
2015-07-24 13:16 ` Jan Beulich
2015-07-27  5:48   ` Wang, Wei W
2015-08-11 10:07     ` Jan Beulich [this message]
2015-07-24 13:17 ` Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55C9E5830200007800099751@prv-mh.provo.novell.com \
    --to=jbeulich@suse.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=wei.w.wang@intel.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).