]> xenbits.xensource.com Git - pvdrivers/win/xenvkbd.git/commitdiff
Work around yet another bug in SDV
authorPaul Durrant <paul.durrant@citrix.com>
Thu, 19 Jul 2018 11:21:46 +0000 (12:21 +0100)
committerPaul Durrant <paul.durrant@citrix.com>
Thu, 19 Jul 2018 11:25:34 +0000 (12:25 +0100)
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@citrix.com>
src/xenvkbd/ring.c

index bd9dc534622494ebb3b74fb0a7456c6e04c4b1d8..39d377969f9872bd793b795678b89f4c519eacd6 100644 (file)
@@ -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,