]> git.proxmox.com Git - mirror_qemu.git/commitdiff
glib: add compatibility interface for g_strcmp0()
authorGonglei <arei.gonglei@huawei.com>
Thu, 16 Oct 2014 10:59:37 +0000 (18:59 +0800)
committerPeter Maydell <peter.maydell@linaro.org>
Thu, 16 Oct 2014 22:02:31 +0000 (23:02 +0100)
This patch fixes compilation errors when building against glib < 2.16.0
due to the missing g_strcmp0() function.

Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Message-id: 1413457177-10132-1-git-send-email-arei.gonglei@huawei.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
include/glib-compat.h

index e29bf69849270ef8f745ee744c5af8094cf49e76..f0615c99c2a0928ecdd6d23a61296922cd0beea8 100644 (file)
@@ -45,6 +45,23 @@ static inline gint64 g_get_monotonic_time(void)
 }
 #endif
 
+#if !GLIB_CHECK_VERSION(2, 16, 0)
+static inline int g_strcmp0(const char *str1, const char *str2)
+{
+    int result;
+
+    if (!str1) {
+        result = -(str1 != str2);
+    } else if (!str2) {
+        result = (str1 != str2);
+    } else {
+        result = strcmp(str1, str2);
+    }
+
+    return result;
+}
+#endif
+
 #ifdef _WIN32
 /*
  * g_poll has a problem on Windows when using