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 09:14 PM, Eric Blake wrote:
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]

Okey, Thanx :)

Signed-off-by: Dongsheng Yang <yangds.fnst@xxxxxxxxxxxxxx>
---
  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.

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.

Thanx


--
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]