aboutsummaryrefslogtreecommitdiff
path: root/include/glib-compat.h
diff options
context:
space:
mode:
authorGonglei <arei.gonglei@huawei.com>2014-10-16 18:59:37 +0800
committerPeter Maydell <peter.maydell@linaro.org>2014-10-16 23:02:31 +0100
commit5f77ef69a195098baddfdc6d189f1b4a94587378 (patch)
tree841f241d6cee4a86cf76401878094cb8edaf3ccf /include/glib-compat.h
parent8a2c26362426a7698c344ecbd13fc96e0d590e22 (diff)
glib: add compatibility interface for g_strcmp0()
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>
Diffstat (limited to 'include/glib-compat.h')
-rw-r--r--include/glib-compat.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/include/glib-compat.h b/include/glib-compat.h
index e29bf69849..f0615c99c2 100644
--- a/include/glib-compat.h
+++ b/include/glib-compat.h
@@ -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