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

[win-pv-devel] [PATCH xenvkbd] Work around yet another bug in SDV



It appears that SDV objects to the symbol 'Constrain' being defined,
presumably because it uses it internally in some way. This patch
therefore re-codes the static inline Constrain function in ring.c as a
macro to avoid the clash.

Signed-off-by: Paul Durrant <paul.durrant@xxxxxxxxxx>
---
 src/xenvkbd/ring.c | 27 ++++++++-------------------
 1 file changed, 8 insertions(+), 19 deletions(-)

diff --git a/src/xenvkbd/ring.c b/src/xenvkbd/ring.c
index bd9dc53..39d3779 100644
--- a/src/xenvkbd/ring.c
+++ b/src/xenvkbd/ring.c
@@ -128,19 +128,8 @@ __RingCopyBuffer(
     return STATUS_SUCCESS;
 }
 
-static FORCEINLINE LONG
-Constrain(
-    IN  LONG    Value,
-    IN  LONG    Min,
-    IN  LONG    Max
-    )
-{
-    if (Value < Min)
-        return Min;
-    if (Value > Max)
-        return Max;
-    return Value;
-}
+#define CONSTRAIN(_Value, _Min, _Max) \
+    (__min(__max((_Value), (_Min)), (_Max)))
 
 static FORCEINLINE UCHAR
 SetBit(
@@ -255,9 +244,9 @@ __RingEventMotion(
     IN  LONG            dZ
     )
 {
-    Ring->AbsMouseReport.X = (USHORT)Constrain(Ring->AbsMouseReport.X + dX, 0, 
32767);
-    Ring->AbsMouseReport.Y = (USHORT)Constrain(Ring->AbsMouseReport.Y + dY, 0, 
32767);
-    Ring->AbsMouseReport.dZ = -(CHAR)Constrain(dZ, -127, 127);
+    Ring->AbsMouseReport.X = (USHORT)CONSTRAIN(Ring->AbsMouseReport.X + dX, 0, 
32767);
+    Ring->AbsMouseReport.Y = (USHORT)CONSTRAIN(Ring->AbsMouseReport.Y + dY, 0, 
32767);
+    Ring->AbsMouseReport.dZ = -(CHAR)CONSTRAIN(dZ, -127, 127);
 
     Ring->AbsMousePending = HidSendReadReport(Ring->Hid,
                                               &Ring->AbsMouseReport,
@@ -319,9 +308,9 @@ __RingEventPosition(
     IN  LONG            dZ
     )
 {
-    Ring->AbsMouseReport.X = (USHORT)Constrain(X, 0, 32767);
-    Ring->AbsMouseReport.Y = (USHORT)Constrain(Y, 0, 32767);
-    Ring->AbsMouseReport.dZ = -(CHAR)Constrain(dZ, -127, 127);
+    Ring->AbsMouseReport.X = (USHORT)CONSTRAIN(X, 0, 32767);
+    Ring->AbsMouseReport.Y = (USHORT)CONSTRAIN(Y, 0, 32767);
+    Ring->AbsMouseReport.dZ = -(CHAR)CONSTRAIN(dZ, -127, 127);
 
     Ring->AbsMousePending = HidSendReadReport(Ring->Hid,
                                               &Ring->AbsMouseReport,
-- 
2.5.3


_______________________________________________
win-pv-devel mailing list
win-pv-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/win-pv-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.