aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2016-06-20 13:25:23 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2016-06-21 04:09:17 +0200
commit19ebd772290681204bee15104fd2dcb5aae49c21 (patch)
tree0abc1781183c6850e719ea00e233d5d9569d2db5
parent21c3d20fb3e425206b0af228e9ebca6d0566afa4 (diff)
downloadnx-libs-19ebd772290681204bee15104fd2dcb5aae49c21.tar.gz
nx-libs-19ebd772290681204bee15104fd2dcb5aae49c21.tar.bz2
nx-libs-19ebd772290681204bee15104fd2dcb5aae49c21.zip
include: add version_compare helper function
Backported from X.org: commit 0df871cf34ee5f1a85586206027de9b02fb364ec Author: Robert Ancell <robert.ancell@canonical.com> Date: Thu May 22 10:43:52 2014 +1200 Fix overflow checking extension versions The easiest way to check for the version of an extension is to send the maximum possible version numbers in the QueryVersion request. The X server overflows on these as it assumes you will send a reasonable version number. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Keith Packard <keithp@keithp.com> commit ffd4874798ba54f86acac75779a15b4babeaa5f3 Author: Peter Hutterer <peter.hutterer@who-t.net> Date: Wed May 11 12:20:50 2011 +1000 include: add version_compare helper function Compare two version numbers in the major.minor form. Switch the few users of manual version switching over to the new function. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Jamey Sharp <jamey@minilop.net> Backport to nx-libs: Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
-rw-r--r--nx-X11/programs/Xserver/include/misc.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/nx-X11/programs/Xserver/include/misc.h b/nx-X11/programs/Xserver/include/misc.h
index 5f30823fa..d2cadace2 100644
--- a/nx-X11/programs/Xserver/include/misc.h
+++ b/nx-X11/programs/Xserver/include/misc.h
@@ -81,6 +81,7 @@ extern unsigned long serverGeneration;
#include <nx-X11/Xfuncproto.h>
#include <nx-X11/Xmd.h>
#include <nx-X11/X.h>
+#include <stdint.h>
#ifndef _XTYPEDEF_POINTER
/* Don't let Xdefs.h define 'pointer' */
@@ -237,6 +238,28 @@ pad_to_int32(const int bytes) {
return (((bytes) + 3) & ~3);
}
+/**
+ * Compare the two version numbers comprising of major.minor.
+ *
+ * @return A value less than 0 if a is less than b, 0 if a is equal to b,
+ * or a value greater than 0
+ */
+static inline int
+version_compare(uint32_t a_major, uint32_t a_minor,
+ uint32_t b_major, uint32_t b_minor)
+{
+ if (a_major > b_major)
+ return 1;
+ if (a_major < b_major)
+ return -1;
+ if (a_minor > b_minor)
+ return 1;
+ if (a_minor < b_minor)
+ return -1;
+
+ return 0;
+}
+
/* some macros to help swap requests, replies, and events */
#define LengthRestB(stuff) \