[libvirt] [PATCH 1/3] virutil: Introduce a new macro named CLAMP.
Eric Blake
eblake at redhat.com
Thu May 15 12:30:57 UTC 2014
On 05/15/2014 05:25 AM, Dongsheng Yang wrote:
>>> +# 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.
>
> I prefer inline function too, but I found MAX and MIN are implemented
> with macro, then
> appended CLAMP to them.
>
> Okey, I will use inline function in next version if this patch is
> acceptable.
Martin's suggestion of using MIN(MAX()) is also C99 compliant, and
usable as a macro. For this particular code, a macro is preferable to
an inline function, because it is type-agnostic.
--
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/30221509/attachment-0001.sig>
More information about the libvir-list
mailing list