yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
9ae3a8
From 6e14ac55a7b40804cf69de560f38561214129b07 Mon Sep 17 00:00:00 2001
9ae3a8
From: Fam Zheng <famz@redhat.com>
9ae3a8
Date: Mon, 11 Jul 2016 05:33:34 +0200
9ae3a8
Subject: [PATCH 1/7] util: introduce MIN_NON_ZERO
9ae3a8
9ae3a8
RH-Author: Fam Zheng <famz@redhat.com>
9ae3a8
Message-id: <1468215219-30793-2-git-send-email-famz@redhat.com>
9ae3a8
Patchwork-id: 71105
9ae3a8
O-Subject: [RHEL-7.3 qemu-kvm PATCH 1/6] util: introduce MIN_NON_ZERO
9ae3a8
Bugzilla: 1318199
9ae3a8
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
RH-Acked-by: John Snow <jsnow@redhat.com>
9ae3a8
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
9ae3a8
From: Peter Lieven <pl@kamp.de>
9ae3a8
9ae3a8
at least in block layer we have the case of limits being defined for a
9ae3a8
BlockDriverState. However, in this context often zero (0) has the special
9ae3a8
meanining of undefined which means no limit. If two of those limits are
9ae3a8
combined and the minimum is needed the minimum function should only return
9ae3a8
zero if both parameters are zero.
9ae3a8
9ae3a8
Signed-off-by: Peter Lieven <pl@kamp.de>
9ae3a8
Reviewed-by: Max Reitz <mreitz@redhat.com>
9ae3a8
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9ae3a8
(cherry picked from commit ac3a8726644d4783eacf54212d23db01d1d30044)
9ae3a8
Signed-off-by: Fam Zheng <famz@redhat.com>
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 include/qemu/osdep.h | 6 ++++++
9ae3a8
 1 file changed, 6 insertions(+)
9ae3a8
9ae3a8
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
9ae3a8
index 8984da0..c47a600 100644
9ae3a8
--- a/include/qemu/osdep.h
9ae3a8
+++ b/include/qemu/osdep.h
9ae3a8
@@ -68,6 +68,12 @@ typedef signed int              int_fast16_t;
9ae3a8
 #define MAX(a, b) (((a) > (b)) ? (a) : (b))
9ae3a8
 #endif
9ae3a8
 
9ae3a8
+/* Minimum function that returns zero only iff both values are zero.
9ae3a8
+ * Intended for use with unsigned values only. */
9ae3a8
+#ifndef MIN_NON_ZERO
9ae3a8
+#define MIN_NON_ZERO(a, b) (((a) != 0 && (a) < (b)) ? (a) : (b))
9ae3a8
+#endif
9ae3a8
+
9ae3a8
 #ifndef ROUND_UP
9ae3a8
 #define ROUND_UP(n,d) (((n) + (d) - 1) & -(d))
9ae3a8
 #endif
9ae3a8
-- 
9ae3a8
1.8.3.1
9ae3a8