3 * Pidgin is the legal property of its developers, whose names are too numerous
4 * to list here. Please refer to the COPYRIGHT file distributed with this
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
22 #ifndef _GLIBCOMPAT_H_
23 #define _GLIBCOMPAT_H_
26 * @section_id: libpurple-glibcompat
27 * @short_description: <filename>glibcompat.h</filename>
28 * @title: GLib version-dependent definitions
30 * This file is internal to libpurple. Do not use!
31 * Also, any public API should not depend on this file.
36 /* glib's definition of g_stat+GStatBuf seems to be broken on mingw64-w32 (and
37 * possibly other 32-bit windows), so instead of relying on it,
38 * we'll define our own.
40 #if defined(_WIN32) && !defined(_MSC_VER) && !defined(_WIN64)
41 # include <glib/gstdio.h>
42 typedef struct _stat GStatBufW32
;
44 purple_g_stat(const gchar
*filename
, GStatBufW32
*buf
)
46 return g_stat(filename
, (GStatBuf
*)buf
);
48 # define GStatBuf GStatBufW32
49 # define g_stat purple_g_stat
55 #undef G_GNUC_BEGIN_IGNORE_DEPRECATIONS
56 #define G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
57 _Pragma ("clang diagnostic push") \
58 _Pragma ("clang diagnostic ignored \"-Wdeprecated-declarations\"")
60 #undef G_GNUC_END_IGNORE_DEPRECATIONS
61 #define G_GNUC_END_IGNORE_DEPRECATIONS \
62 _Pragma ("clang diagnostic pop")
64 #endif /* __clang__ */
67 #if !GLIB_CHECK_VERSION(2, 44, 0)
68 #define G_IO_ERROR_CONNECTION_CLOSED G_IO_ERROR_BROKEN_PIPE
71 /******************************************************************************
73 *****************************************************************************/
74 #if !GLIB_CHECK_VERSION(2, 38, 0)
75 #define g_assert_true(expr) G_STMT_START { \
76 if G_LIKELY (expr) ; else \
77 g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
78 "'" #expr "' should be TRUE"); \
80 #define g_assert_false(expr) G_STMT_START { \
81 if G_LIKELY (!(expr)) ; else \
82 g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
83 "'" #expr "' should be FALSE"); \
85 #define g_assert_null(expr) G_STMT_START { if G_LIKELY ((expr) == NULL) ; else \
86 g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
87 "'" #expr "' should be NULL"); \
91 #if !GLIB_CHECK_VERSION(2, 40, 0)
92 #define g_assert_nonnull(expr) G_STMT_START { \
93 if G_LIKELY ((expr) != NULL) ; else \
94 g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
95 "'" #expr "' should not be NULL"); \
99 #if !GLIB_CHECK_VERSION(2, 46, 0)
100 #define g_assert_cmpmem(m1, l1, m2, l2) G_STMT_START {\
101 gconstpointer __m1 = m1, __m2 = m2; \
102 int __l1 = l1, __l2 = l2; \
104 g_assertion_message_cmpnum (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
105 #l1 " (len(" #m1 ")) == " #l2 " (len(" #m2 "))", __l1, "==", __l2, 'i'); \
106 else if (memcmp (__m1, __m2, __l1) != 0) \
107 g_assertion_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, \
108 "assertion failed (" #m1 " == " #m2 ")"); \
112 #endif /* _GLIBCOMPAT_H_ */