[libvirt] [PATCH 1/3] virutil: Introduce a new macro named CLAMP.

Eric Blake eblake at redhat.com
Thu May 15 12:14:25 UTC 2014


On 05/15/2014 03:39 AM, Dongsheng Yang wrote:
> This patch introduce a new macro to return a
> value clamped to a given range.

[when sending a series, it's nice to include a cover letter with 'git
send-email --cover-letter to generate the 0/N message that all other
messages in the series reply to]

> 
> Signed-off-by: Dongsheng Yang <yangds.fnst at cn.fujitsu.com>
> ---
>  src/util/virutil.h | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/src/util/virutil.h b/src/util/virutil.h
> index 2bb74e2..e8536d8 100644
> --- a/src/util/virutil.h
> +++ b/src/util/virutil.h
> @@ -37,6 +37,12 @@
>  # ifndef MAX
>  #  define MAX(a, b) ((a) > (b) ? (a) : (b))
>  # endif
> +# ifndef CLAMP
> +#  define CLAMP(v, min, max) ({         \

This is gcc-specific.  I'd rather avoid it, and stick to portable C99
code, if possible - which means doing this as an inline function rather
than a macro.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 604 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140515/e5f986a2/attachment-0001.sig>


More information about the libvir-list mailing list