Mercurial > pidgin
comparison libpurple/internal.h @ 29082:39716f7d2c93
Kill off unneeded GLIB_CHECK_VERSION checks in libpurple. Refs #10024.
author | John Bailey <rekkanoryo@rekkanoryo.org> |
---|---|
date | Sat, 22 Aug 2009 21:47:20 +0000 |
parents | 91b8a957776a |
children | f2e0b8f38e14 da81195f635e |
comparison
equal
deleted
inserted
replaced
29081:299ef6fd1a23 | 29082:39716f7d2c93 |
---|---|
116 # include <netdb.h> | 116 # include <netdb.h> |
117 # include <signal.h> | 117 # include <signal.h> |
118 # include <unistd.h> | 118 # include <unistd.h> |
119 #endif | 119 #endif |
120 | 120 |
121 /* MAXPATHLEN should only be used with readlink() on glib < 2.4.0. For | |
122 * anything else, use g_file_read_link() or other dynamic functions. This is | |
123 * important because Hurd has no hard limits on path length. */ | |
124 #if !GLIB_CHECK_VERSION(2,4,0) | |
125 # ifndef MAXPATHLEN | |
126 # ifdef PATH_MAX | |
127 # define MAXPATHLEN PATH_MAX | |
128 # else | |
129 # define MAXPATHLEN 1024 | |
130 # endif | |
131 # endif | |
132 #endif | |
133 | |
134 #ifndef HOST_NAME_MAX | 121 #ifndef HOST_NAME_MAX |
135 # define HOST_NAME_MAX 255 | 122 # define HOST_NAME_MAX 255 |
136 #endif | 123 #endif |
137 | 124 |
138 #include <glib.h> | 125 #include <glib.h> |
139 #if !GLIB_CHECK_VERSION(2,4,0) | 126 |
140 # define G_MAXUINT32 ((guint32) 0xffffffff) | 127 /* This wasn't introduced until Glib 2.14 :( */ |
141 #endif | |
142 | |
143 #ifndef G_MAXSIZE | |
144 # if GLIB_SIZEOF_LONG == 8 | |
145 # define G_MAXSIZE ((gsize) 0xffffffffffffffff) | |
146 # else | |
147 # define G_MAXSIZE ((gsize) 0xffffffff) | |
148 # endif | |
149 #endif | |
150 | |
151 #ifndef G_MAXSSIZE | 128 #ifndef G_MAXSSIZE |
152 # if GLIB_SIZEOF_LONG == 8 | 129 # if GLIB_SIZEOF_LONG == 8 |
153 # define G_MAXSSIZE ((gssize) 0x7fffffffffffffff) | 130 # define G_MAXSSIZE ((gssize) 0x7fffffffffffffff) |
154 # else | 131 # else |
155 # define G_MAXSSIZE ((gssize) 0x7fffffff) | 132 # define G_MAXSSIZE ((gssize) 0x7fffffff) |
156 # endif | 133 # endif |
157 #endif | 134 #endif |
158 | 135 |
159 #if GLIB_CHECK_VERSION(2,6,0) | 136 #include <glib/gstdio.h> |
160 # include <glib/gstdio.h> | |
161 #endif | |
162 | |
163 #if !GLIB_CHECK_VERSION(2,6,0) | |
164 # define g_freopen freopen | |
165 # define g_fopen fopen | |
166 # define g_rmdir rmdir | |
167 # define g_remove remove | |
168 # define g_unlink unlink | |
169 # define g_lstat lstat | |
170 # define g_stat stat | |
171 # define g_mkdir mkdir | |
172 # define g_rename rename | |
173 # define g_open open | |
174 #endif | |
175 | |
176 #if !GLIB_CHECK_VERSION(2,8,0) && !defined _WIN32 | |
177 # define g_access access | |
178 #endif | |
179 | |
180 #if !GLIB_CHECK_VERSION(2,10,0) | |
181 # define g_slice_new(type) g_new(type, 1) | |
182 # define g_slice_new0(type) g_new0(type, 1) | |
183 # define g_slice_free(type, mem) g_free(mem) | |
184 #endif | |
185 | 137 |
186 #ifdef _WIN32 | 138 #ifdef _WIN32 |
187 #include "win32dep.h" | 139 #include "win32dep.h" |
188 #endif | |
189 | |
190 /* ugly ugly ugly */ | |
191 /* This is a workaround for the fact that G_GINT64_MODIFIER and G_GSIZE_FORMAT | |
192 * are only defined in Glib >= 2.4 */ | |
193 #ifndef G_GINT64_MODIFIER | |
194 # if GLIB_SIZEOF_LONG == 8 | |
195 # define G_GINT64_MODIFIER "l" | |
196 # else | |
197 # define G_GINT64_MODIFIER "ll" | |
198 # endif | |
199 #endif | |
200 | |
201 #ifndef G_GSIZE_MODIFIER | |
202 # if GLIB_SIZEOF_LONG == 8 | |
203 # define G_GSIZE_MODIFIER "l" | |
204 # else | |
205 # define G_GSIZE_MODIFIER "" | |
206 # endif | |
207 #endif | |
208 | |
209 #ifndef G_GSIZE_FORMAT | |
210 # if GLIB_SIZEOF_LONG == 8 | |
211 # define G_GSIZE_FORMAT "lu" | |
212 # else | |
213 # define G_GSIZE_FORMAT "u" | |
214 # endif | |
215 #endif | |
216 | |
217 #ifndef G_GSSIZE_FORMAT | |
218 # if GLIB_SIZEOF_LONG == 8 | |
219 # define G_GSSIZE_FORMAT "li" | |
220 # else | |
221 # define G_GSSIZE_FORMAT "i" | |
222 # endif | |
223 #endif | |
224 | |
225 #ifndef G_GNUC_NULL_TERMINATED | |
226 # if __GNUC__ >= 4 | |
227 # define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__)) | |
228 # else | |
229 # define G_GNUC_NULL_TERMINATED | |
230 # endif | |
231 #endif | 140 #endif |
232 | 141 |
233 #ifdef HAVE_CONFIG_H | 142 #ifdef HAVE_CONFIG_H |
234 #if SIZEOF_TIME_T == 4 | 143 #if SIZEOF_TIME_T == 4 |
235 # define PURPLE_TIME_T_MODIFIER "lu" | 144 # define PURPLE_TIME_T_MODIFIER "lu" |
240 #endif | 149 #endif |
241 #endif | 150 #endif |
242 | 151 |
243 #include <glib-object.h> | 152 #include <glib-object.h> |
244 | 153 |
245 #ifndef G_DEFINE_TYPE | |
246 #define G_DEFINE_TYPE(TypeName, type_name, TYPE_PARENT) \ | |
247 \ | |
248 static void type_name##_init (TypeName *self); \ | |
249 static void type_name##_class_init (TypeName##Class *klass); \ | |
250 static gpointer type_name##_parent_class = NULL; \ | |
251 static void type_name##_class_intern_init (gpointer klass) \ | |
252 { \ | |
253 type_name##_parent_class = g_type_class_peek_parent (klass); \ | |
254 type_name##_class_init ((TypeName##Class*) klass); \ | |
255 } \ | |
256 \ | |
257 GType \ | |
258 type_name##_get_type (void) \ | |
259 { \ | |
260 static GType g_define_type_id = 0; \ | |
261 if (G_UNLIKELY (g_define_type_id == 0)) \ | |
262 { \ | |
263 g_define_type_id = \ | |
264 g_type_register_static_simple (TYPE_PARENT, \ | |
265 g_intern_static_string (#TypeName), \ | |
266 sizeof (TypeName##Class), \ | |
267 (GClassInitFunc)type_name##_class_intern_init, \ | |
268 sizeof (TypeName), \ | |
269 (GInstanceInitFunc)type_name##_init, \ | |
270 (GTypeFlags) 0); \ | |
271 } \ | |
272 return g_define_type_id; \ | |
273 } /* closes type_name##_get_type() */ | |
274 | |
275 #endif | |
276 | |
277 /* Safer ways to work with static buffers. When using non-static | 154 /* Safer ways to work with static buffers. When using non-static |
278 * buffers, either use g_strdup_* functions (preferred) or use | 155 * buffers, either use g_strdup_* functions (preferred) or use |
279 * g_strlcpy/g_strlcpy directly. */ | 156 * g_strlcpy/g_strlcpy directly. */ |
280 #define purple_strlcpy(dest, src) g_strlcpy(dest, src, sizeof(dest)) | 157 #define purple_strlcpy(dest, src) g_strlcpy(dest, src, sizeof(dest)) |
281 #define purple_strlcat(dest, src) g_strlcat(dest, src, sizeof(dest)) | 158 #define purple_strlcat(dest, src) g_strlcat(dest, src, sizeof(dest)) |