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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Attachment: signature.asc
Description: OpenPGP digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]