mirror of
https://github.com/X11Libre/xserver.git
synced 2026-09-25 21:02:21 +00:00
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>
This commit is contained in:
parent
c4f9c3a07d
commit
ffd4874798
6 changed files with 94 additions and 16 deletions
|
|
@ -223,6 +223,24 @@ pad_to_int32(const int bytes) {
|
|||
extern char**
|
||||
xstrtokenize(const char *str, const char* separators);
|
||||
|
||||
/**
|
||||
* 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(uint16_t a_major, uint16_t a_minor,
|
||||
uint16_t b_major, uint16_t b_minor)
|
||||
{
|
||||
int a, b;
|
||||
|
||||
a = a_major << 16 | a_minor;
|
||||
b = b_major << 16 | b_minor;
|
||||
|
||||
return (a - b);
|
||||
}
|
||||
|
||||
/* some macros to help swap requests, replies, and events */
|
||||
|
||||
#define LengthRestB(stuff) \
|
||||
|
|
|
|||
Loading…
Reference in a new issue