Wrap always_inline and noinline attributes in compiler checks and use MSVC equivalent.
[mono.git] / eglib / src / glib.h
1 #ifndef __GLIB_H
2 #define __GLIB_H
3
4 #include <stdarg.h>
5 #include <stdlib.h>
6 #include <string.h>
7 #include <stdio.h>
8 #include <stddef.h>
9 #include <ctype.h>
10 #include <limits.h>
11
12 #ifdef _MSC_VER
13 #pragma include_alias(<eglib-config.h>, <eglib-config.hw>)
14 #endif
15
16 /* VS 2010 and later have stdint.h */
17 #if defined(_MSC_VER) && _MSC_VER < 1600
18 #else
19 #include <stdint.h>
20 #endif
21
22 #include <eglib-config.h>
23 #ifndef EGLIB_NO_REMAP
24 #include <eglib-remap.h>
25 #endif
26
27 #ifdef G_HAVE_ALLOCA_H
28 #include <alloca.h>
29 #endif
30
31 #ifdef WIN32
32 /* For alloca */
33 #include <malloc.h>
34 #endif
35
36 #ifndef offsetof
37 #   define offsetof(s_name,n_name) (size_t)(char *)&(((s_name*)0)->m_name)
38 #endif
39
40 #define __EGLIB_X11 1
41
42 #ifdef  __cplusplus
43 #define G_BEGIN_DECLS  extern "C" {
44 #define G_END_DECLS    }
45 #else
46 #define G_BEGIN_DECLS
47 #define G_END_DECLS
48 #endif
49
50 G_BEGIN_DECLS
51
52 #ifdef G_OS_WIN32
53 /* MSC and Cross-compilatin will use this */
54 int vasprintf (char **strp, const char *fmt, va_list ap);
55 #endif
56
57
58 /*
59  * Basic data types
60  */
61 typedef int            gint;
62 typedef unsigned int   guint;
63 typedef short          gshort;
64 typedef unsigned short gushort;
65 typedef long           glong;
66 typedef unsigned long  gulong;
67 typedef void *         gpointer;
68 typedef const void *   gconstpointer;
69 typedef char           gchar;
70 typedef unsigned char  guchar;
71
72 #if !G_TYPES_DEFINED
73 /* VS 2010 and later have stdint.h */
74 #if defined(_MSC_VER) && _MSC_VER < 1600
75 typedef __int8                  gint8;
76 typedef unsigned __int8         guint8;
77 typedef __int16                 gint16;
78 typedef unsigned __int16        guint16;
79 typedef __int32                 gint32;
80 typedef unsigned __int32        guint32;
81 typedef __int64                 gint64;
82 typedef unsigned __int64        guint64;
83 typedef float                   gfloat;
84 typedef double                  gdouble;
85 typedef int                     gboolean;
86 #else
87 /* Types defined in terms of the stdint.h */
88 typedef int8_t         gint8;
89 typedef uint8_t        guint8;
90 typedef int16_t        gint16;
91 typedef uint16_t       guint16;
92 typedef int32_t        gint32;
93 typedef uint32_t       guint32;
94 typedef int64_t        gint64;
95 typedef uint64_t       guint64;
96 typedef float          gfloat;
97 typedef double         gdouble;
98 typedef int32_t        gboolean;
99 #endif
100 #endif
101
102 typedef guint16 gunichar2;
103 typedef guint32 gunichar;
104
105 /*
106  * Macros
107  */
108 #define G_N_ELEMENTS(s)      (sizeof(s) / sizeof ((s) [0]))
109
110 #define FALSE                0
111 #define TRUE                 1
112
113 #define G_MINSHORT           SHRT_MIN
114 #define G_MAXSHORT           SHRT_MAX
115 #define G_MAXUSHORT          USHRT_MAX
116 #define G_MAXINT             INT_MAX
117 #define G_MININT             INT_MIN
118 #define G_MAXINT32           INT32_MAX
119 #define G_MAXUINT32          UINT32_MAX
120 #define G_MININT32           INT32_MIN
121 #define G_MININT64           INT64_MIN
122 #define G_MAXINT64           INT64_MAX
123 #define G_MAXUINT64          UINT64_MAX
124
125 #define G_LITTLE_ENDIAN 1234
126 #define G_BIG_ENDIAN    4321
127 #define G_STMT_START    do 
128 #define G_STMT_END      while (0)
129
130 #define G_USEC_PER_SEC  1000000
131
132 #ifndef ABS
133 #define ABS(a)         ((a) > 0 ? (a) : -(a))
134 #endif
135
136 #define G_STRUCT_OFFSET(p_type,field) offsetof(p_type,field)
137
138 #define EGLIB_STRINGIFY(x) #x
139 #define EGLIB_TOSTRING(x) EGLIB_STRINGIFY(x)
140 #define G_STRLOC __FILE__ ":" EGLIB_TOSTRING(__LINE__) ":"
141
142 #define G_CONST_RETURN const
143
144 /*
145  * Allocation
146  */
147 void g_free (void *ptr);
148 gpointer g_realloc (gpointer obj, gsize size);
149 gpointer g_malloc (gsize x);
150 gpointer g_malloc0 (gsize x);
151 gpointer g_try_malloc (gsize x);
152 gpointer g_try_realloc (gpointer obj, gsize size);
153
154 #define g_new(type,size)        ((type *) g_malloc (sizeof (type) * (size)))
155 #define g_new0(type,size)       ((type *) g_malloc0 (sizeof (type)* (size)))
156 #define g_newa(type,size)       ((type *) alloca (sizeof (type) * (size)))
157
158 #define g_memmove(dest,src,len) memmove (dest, src, len)
159 #define g_renew(struct_type, mem, n_structs) g_realloc (mem, sizeof (struct_type) * n_structs)
160 #define g_alloca(size)          alloca (size)
161
162 gpointer g_memdup (gconstpointer mem, guint byte_size);
163 static inline gchar   *g_strdup (const gchar *str) { if (str) {return strdup (str);} return NULL; }
164 gchar **g_strdupv (gchar **str_array);
165
166 typedef struct {
167         gpointer (*malloc)      (gsize    n_bytes);
168         gpointer (*realloc)     (gpointer mem, gsize n_bytes);
169         void     (*free)        (gpointer mem);
170         gpointer (*calloc)      (gsize    n_blocks, gsize n_block_bytes);
171         gpointer (*try_malloc)  (gsize    n_bytes);
172         gpointer (*try_realloc) (gpointer mem, gsize n_bytes);
173 } GMemVTable;
174
175 #define g_mem_set_vtable(x)
176
177 struct _GMemChunk {
178         guint alloc_size;
179 };
180
181 typedef struct _GMemChunk GMemChunk;
182 /*
183  * Misc.
184  */
185 #define g_atexit(func)  ((void) atexit (func))
186
187 const gchar *    g_getenv(const gchar *variable);
188 gboolean         g_setenv(const gchar *variable, const gchar *value, gboolean overwrite);
189 void             g_unsetenv(const gchar *variable);
190
191 gchar*           g_win32_getlocale(void);
192
193 /*
194  * Precondition macros
195  */
196 #define g_warn_if_fail(x)  G_STMT_START { if (!(x)) { g_warning ("%s:%d: assertion '%s' failed", __FILE__, __LINE__, #x); } } G_STMT_END
197 #define g_return_if_fail(x)  G_STMT_START { if (!(x)) { g_critical ("%s:%d: assertion '%s' failed", __FILE__, __LINE__, #x); return; } } G_STMT_END
198 #define g_return_val_if_fail(x,e)  G_STMT_START { if (!(x)) { g_critical ("%s:%d: assertion '%s' failed", __FILE__, __LINE__, #x); return (e); } } G_STMT_END
199
200 /*
201  * Errors
202  */
203 typedef struct {
204         /* In the real glib, this is a GQuark, but we dont use/need that */
205         gpointer domain;
206         gint     code;
207         gchar   *message;
208 } GError;
209
210 void    g_clear_error (GError **error);
211 void    g_error_free (GError *error);
212 GError *g_error_new  (gpointer domain, gint code, const char *format, ...);
213 void    g_set_error  (GError **err, gpointer domain, gint code, const gchar *format, ...);
214 void    g_propagate_error (GError **dest, GError *src);
215
216 /*
217  * Strings utility
218  */
219 gchar       *g_strdup_printf  (const gchar *format, ...);
220 gchar       *g_strdup_vprintf (const gchar *format, va_list args);
221 gchar       *g_strndup        (const gchar *str, gsize n);
222 const gchar *g_strerror       (gint errnum);
223 gchar       *g_strndup        (const gchar *str, gsize n);
224 void         g_strfreev       (gchar **str_array);
225 gchar       *g_strconcat      (const gchar *first, ...);
226 gchar      **g_strsplit       (const gchar *string, const gchar *delimiter, gint max_tokens);
227 gchar      **g_strsplit_set   (const gchar *string, const gchar *delimiter, gint max_tokens);
228 gchar       *g_strreverse     (gchar *str);
229 gboolean     g_str_has_prefix (const gchar *str, const gchar *prefix);
230 gboolean     g_str_has_suffix (const gchar *str, const gchar *suffix);
231 guint        g_strv_length    (gchar **str_array);
232 gchar       *g_strjoin        (const gchar *separator, ...);
233 gchar       *g_strjoinv       (const gchar *separator, gchar **str_array);
234 gchar       *g_strchug        (gchar *str);
235 gchar       *g_strchomp       (gchar *str);
236 void         g_strdown        (gchar *string);
237 gchar       *g_strnfill       (gsize length, gchar fill_char);
238
239 gchar       *g_strdelimit     (gchar *string, const gchar *delimiters, gchar new_delimiter);
240 gchar       *g_strescape      (const gchar *source, const gchar *exceptions);
241
242 gchar       *g_filename_to_uri   (const gchar *filename, const gchar *hostname, GError **error);
243 gchar       *g_filename_from_uri (const gchar *uri, gchar **hostname, GError **error);
244
245 gint         g_printf          (gchar const *format, ...);
246 gint         g_fprintf         (FILE *file, gchar const *format, ...);
247 gint         g_sprintf         (gchar *string, gchar const *format, ...);
248 gint         g_snprintf        (gchar *string, gulong n, gchar const *format, ...);
249 #define g_vprintf vprintf
250 #define g_vfprintf vfprintf
251 #define g_vsprintf vsprintf
252 #define g_vsnprintf vsnprintf
253 #define g_vasprintf vasprintf
254
255 gsize   g_strlcpy            (gchar *dest, const gchar *src, gsize dest_size);
256 gchar  *g_stpcpy             (gchar *dest, const char *src);
257
258
259 gchar   g_ascii_tolower      (gchar c);
260 gchar   g_ascii_toupper      (gchar c);
261 gchar  *g_ascii_strdown      (const gchar *str, gssize len);
262 gchar  *g_ascii_strup        (const gchar *str, gssize len);
263 gint    g_ascii_strncasecmp  (const gchar *s1, const gchar *s2, gsize n);
264 gint    g_ascii_strcasecmp   (const gchar *s1, const gchar *s2);
265 gint    g_ascii_xdigit_value (gchar c);
266 #define g_ascii_isspace(c)   (isspace (c) != 0)
267 #define g_ascii_isalpha(c)   (isalpha (c) != 0)
268 #define g_ascii_isprint(c)   (isprint (c) != 0)
269 #define g_ascii_isxdigit(c)  (isxdigit (c) != 0)
270
271 /* FIXME: g_strcasecmp supports utf8 unicode stuff */
272 #ifdef _MSC_VER
273 #define g_strcasecmp stricmp
274 #define g_strncasecmp strnicmp
275 #define g_strstrip(a) g_strchug (g_strchomp (a))
276 #else
277 #define g_strcasecmp strcasecmp
278 #define g_ascii_strtoull strtoull
279 #define g_strncasecmp strncasecmp
280 #define g_strstrip(a) g_strchug (g_strchomp (a))
281 #endif
282 #define g_ascii_strdup strdup
283
284
285 #define G_STR_DELIMITERS "_-|> <."
286
287 /*
288  * String type
289  */
290 typedef struct {
291         char *str;
292         gsize len;
293         gsize allocated_len;
294 } GString;
295
296 GString     *g_string_new           (const gchar *init);
297 GString     *g_string_new_len       (const gchar *init, gssize len);
298 GString     *g_string_sized_new     (gsize default_size);
299 gchar       *g_string_free          (GString *string, gboolean free_segment);
300 GString     *g_string_append        (GString *string, const gchar *val);
301 void         g_string_printf        (GString *string, const gchar *format, ...);
302 void         g_string_append_printf (GString *string, const gchar *format, ...);
303 void         g_string_append_vprintf (GString *string, const gchar *format, va_list args);
304 GString     *g_string_append_unichar (GString *string, gunichar c);
305 GString     *g_string_append_c      (GString *string, gchar c);
306 GString     *g_string_append        (GString *string, const gchar *val);
307 GString     *g_string_append_len    (GString *string, const gchar *val, gssize len);
308 GString     *g_string_truncate      (GString *string, gsize len);
309 GString     *g_string_prepend       (GString *string, const gchar *val);
310 GString     *g_string_insert        (GString *string, gssize pos, const gchar *val);
311 GString     *g_string_set_size      (GString *string, gsize len);
312 GString     *g_string_erase         (GString *string, gssize pos, gssize len);
313
314 #define g_string_sprintfa g_string_append_printf
315
316 typedef void     (*GFunc)          (gpointer data, gpointer user_data);
317 typedef gint     (*GCompareFunc)   (gconstpointer a, gconstpointer b);
318 typedef gint     (*GCompareDataFunc) (gconstpointer a, gconstpointer b, gpointer user_data);
319 typedef void     (*GHFunc)         (gpointer key, gpointer value, gpointer user_data);
320 typedef gboolean (*GHRFunc)        (gpointer key, gpointer value, gpointer user_data);
321 typedef void     (*GDestroyNotify) (gpointer data);
322 typedef guint    (*GHashFunc)      (gconstpointer key);
323 typedef gboolean (*GEqualFunc)     (gconstpointer a, gconstpointer b);
324 typedef void     (*GFreeFunc)      (gpointer       data);
325
326 /*
327  * Lists
328  */
329 typedef struct _GSList GSList;
330 struct _GSList {
331         gpointer data;
332         GSList *next;
333 };
334
335 GSList *g_slist_alloc         (void);
336 GSList *g_slist_append        (GSList        *list,
337                                gpointer       data);
338 GSList *g_slist_prepend       (GSList        *list,
339                                gpointer       data);
340 void    g_slist_free          (GSList        *list);
341 void    g_slist_free_1        (GSList        *list);
342 GSList *g_slist_copy          (GSList        *list);
343 GSList *g_slist_concat        (GSList        *list1,
344                                GSList        *list2);
345 void    g_slist_foreach       (GSList        *list,
346                                GFunc          func,
347                                gpointer       user_data);
348 GSList *g_slist_last          (GSList        *list);
349 GSList *g_slist_find          (GSList        *list,
350                                gconstpointer  data);
351 GSList *g_slist_find_custom   (GSList        *list,
352                                gconstpointer  data,
353                                GCompareFunc   func);
354 GSList *g_slist_remove        (GSList        *list,
355                                gconstpointer  data);
356 GSList *g_slist_remove_all    (GSList        *list,
357                                gconstpointer  data);
358 GSList *g_slist_reverse       (GSList        *list);
359 guint   g_slist_length        (GSList        *list);
360 GSList *g_slist_remove_link   (GSList        *list,
361                                GSList        *link);
362 GSList *g_slist_delete_link   (GSList        *list,
363                                GSList        *link);
364 GSList *g_slist_insert_sorted (GSList        *list,
365                                gpointer       data,
366                                GCompareFunc   func);
367 GSList *g_slist_insert_before (GSList        *list,
368                                GSList        *sibling,
369                                gpointer       data);
370 GSList *g_slist_sort          (GSList        *list,
371                                GCompareFunc   func);
372 gint    g_slist_index         (GSList        *list,
373                                gconstpointer  data);
374 GSList *g_slist_nth           (GSList        *list,
375                                guint          n);
376 gpointer g_slist_nth_data     (GSList        *list,
377                                guint          n);
378
379 #define g_slist_next(slist) ((slist) ? (((GSList *) (slist))->next) : NULL)
380
381
382 typedef struct _GList GList;
383 struct _GList {
384   gpointer data;
385   GList *next;
386   GList *prev;
387 };
388
389 #define g_list_next(list) ((list) ? (((GList *) (list))->next) : NULL)
390 #define g_list_previous(list) ((list) ? (((GList *) (list))->prev) : NULL)
391
392 GList *g_list_alloc         (void);
393 GList *g_list_append        (GList         *list,
394                              gpointer       data);
395 GList *g_list_prepend       (GList         *list,
396                              gpointer       data);
397 void   g_list_free          (GList         *list);
398 void   g_list_free_1        (GList         *list);
399 GList *g_list_copy          (GList         *list);
400 guint  g_list_length        (GList         *list);
401 gint   g_list_index         (GList         *list,
402                              gconstpointer  data);
403 GList *g_list_nth           (GList         *list,
404                              guint          n);
405 gpointer g_list_nth_data      (GList         *list,
406                              guint          n);
407 GList *g_list_last          (GList         *list);
408 GList *g_list_concat        (GList         *list1,
409                              GList         *list2);
410 void   g_list_foreach       (GList         *list,
411                              GFunc          func,
412                              gpointer       user_data);
413 GList *g_list_first         (GList         *list);
414 GList *g_list_find          (GList         *list,
415                              gconstpointer  data);
416 GList *g_list_find_custom   (GList         *list,
417                              gconstpointer  data,
418                              GCompareFunc   func);
419 GList *g_list_remove        (GList         *list,
420                              gconstpointer  data);
421 GList *g_list_remove_all    (GList         *list,
422                              gconstpointer  data);
423 GList *g_list_reverse       (GList         *list);
424 GList *g_list_remove_link   (GList         *list,
425                              GList         *link);
426 GList *g_list_delete_link   (GList         *list,
427                              GList         *link);
428 GList *g_list_insert_sorted (GList         *list,
429                              gpointer       data,
430                              GCompareFunc   func);
431 GList *g_list_insert_before (GList         *list,
432                              GList         *sibling,
433                              gpointer       data);
434 GList *g_list_sort          (GList         *sort,
435                              GCompareFunc   func);
436
437 /*
438  * Hashtables
439  */
440 typedef struct _GHashTable GHashTable;
441 typedef struct _GHashTableIter GHashTableIter;
442
443 /* Private, but needed for stack allocation */
444 struct _GHashTableIter
445 {
446         gpointer dummy [8];
447 };
448
449 GHashTable     *g_hash_table_new             (GHashFunc hash_func, GEqualFunc key_equal_func);
450 GHashTable     *g_hash_table_new_full        (GHashFunc hash_func, GEqualFunc key_equal_func,
451                                               GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func);
452 void            g_hash_table_insert_replace  (GHashTable *hash, gpointer key, gpointer value, gboolean replace);
453 guint           g_hash_table_size            (GHashTable *hash);
454 GList          *g_hash_table_get_keys        (GHashTable *hash);
455 GList          *g_hash_table_get_values      (GHashTable *hash);
456 gpointer        g_hash_table_lookup          (GHashTable *hash, gconstpointer key);
457 gboolean        g_hash_table_lookup_extended (GHashTable *hash, gconstpointer key, gpointer *orig_key, gpointer *value);
458 void            g_hash_table_foreach         (GHashTable *hash, GHFunc func, gpointer user_data);
459 gpointer        g_hash_table_find            (GHashTable *hash, GHRFunc predicate, gpointer user_data);
460 gboolean        g_hash_table_remove          (GHashTable *hash, gconstpointer key);
461 gboolean        g_hash_table_steal           (GHashTable *hash, gconstpointer key);
462 void            g_hash_table_remove_all      (GHashTable *hash);
463 guint           g_hash_table_foreach_remove  (GHashTable *hash, GHRFunc func, gpointer user_data);
464 guint           g_hash_table_foreach_steal   (GHashTable *hash, GHRFunc func, gpointer user_data);
465 void            g_hash_table_destroy         (GHashTable *hash);
466 void            g_hash_table_print_stats     (GHashTable *table);
467
468 void            g_hash_table_iter_init       (GHashTableIter *iter, GHashTable *hash_table);
469 gboolean        g_hash_table_iter_next       (GHashTableIter *iter, gpointer *key, gpointer *value);
470
471 guint           g_spaced_primes_closest      (guint x);
472
473 #define g_hash_table_insert(h,k,v)    g_hash_table_insert_replace ((h),(k),(v),FALSE)
474 #define g_hash_table_replace(h,k,v)   g_hash_table_insert_replace ((h),(k),(v),TRUE)
475
476 gboolean g_direct_equal (gconstpointer v1, gconstpointer v2);
477 guint    g_direct_hash  (gconstpointer v1);
478 gboolean g_int_equal    (gconstpointer v1, gconstpointer v2);
479 guint    g_int_hash     (gconstpointer v1);
480 gboolean g_str_equal    (gconstpointer v1, gconstpointer v2);
481 guint    g_str_hash     (gconstpointer v1);
482
483 /*
484  * ByteArray
485  */
486
487 typedef struct _GByteArray GByteArray;
488 struct _GByteArray {
489         guint8 *data;
490         gint len;
491 };
492
493 GByteArray *g_byte_array_new    (void);
494 GByteArray* g_byte_array_append (GByteArray *array, const guint8 *data, guint len);
495 guint8*  g_byte_array_free      (GByteArray *array, gboolean free_segment);
496
497 /*
498  * Array
499  */
500
501 typedef struct _GArray GArray;
502 struct _GArray {
503         gchar *data;
504         gint len;
505 };
506
507 GArray *g_array_new               (gboolean zero_terminated, gboolean clear_, guint element_size);
508 GArray *g_array_sized_new         (gboolean zero_terminated, gboolean clear_, guint element_size, guint reserved_size);
509 gchar*  g_array_free              (GArray *array, gboolean free_segment);
510 GArray *g_array_append_vals       (GArray *array, gconstpointer data, guint len);
511 GArray* g_array_insert_vals       (GArray *array, guint index_, gconstpointer data, guint len);
512 GArray* g_array_remove_index      (GArray *array, guint index_);
513 GArray* g_array_remove_index_fast (GArray *array, guint index_);
514 void    g_array_set_size          (GArray *array, gint length);
515
516 #define g_array_append_val(a,v)   (g_array_append_vals((a),&(v),1))
517 #define g_array_insert_val(a,i,v) (g_array_insert_vals((a),(i),&(v),1))
518 #define g_array_index(a,t,i)      *(t*)(((a)->data) + sizeof(t) * (i))
519
520 /*
521  * QSort
522 */
523
524 void g_qsort_with_data (gpointer base, size_t nmemb, size_t size, GCompareDataFunc compare, gpointer user_data);
525
526 /*
527  * Pointer Array
528  */
529
530 typedef struct _GPtrArray GPtrArray;
531 struct _GPtrArray {
532         gpointer *pdata;
533         guint len;
534 };
535
536 GPtrArray *g_ptr_array_new                (void);
537 GPtrArray *g_ptr_array_sized_new          (guint reserved_size);
538 void       g_ptr_array_add                (GPtrArray *array, gpointer data);
539 gboolean   g_ptr_array_remove             (GPtrArray *array, gpointer data);
540 gpointer   g_ptr_array_remove_index       (GPtrArray *array, guint index);
541 gboolean   g_ptr_array_remove_fast        (GPtrArray *array, gpointer data);
542 gpointer   g_ptr_array_remove_index_fast  (GPtrArray *array, guint index);
543 void       g_ptr_array_sort               (GPtrArray *array, GCompareFunc compare_func);
544 void       g_ptr_array_sort_with_data     (GPtrArray *array, GCompareDataFunc compare_func, gpointer user_data);
545 void       g_ptr_array_set_size           (GPtrArray *array, gint length);
546 gpointer  *g_ptr_array_free               (GPtrArray *array, gboolean free_seg);
547 void       g_ptr_array_foreach            (GPtrArray *array, GFunc func, gpointer user_data);
548 #define    g_ptr_array_index(array,index) (array)->pdata[(index)]
549
550 /*
551  * Queues
552  */
553 typedef struct {
554         GList *head;
555         GList *tail;
556         guint length;
557 } GQueue;
558
559 gpointer g_queue_pop_head  (GQueue   *queue);
560 void     g_queue_push_head (GQueue   *queue,
561                             gpointer  data);
562 void     g_queue_push_tail (GQueue   *queue,
563                             gpointer  data);
564 gboolean g_queue_is_empty  (GQueue   *queue);
565 GQueue  *g_queue_new       (void);
566 void     g_queue_free      (GQueue   *queue);
567 void     g_queue_foreach   (GQueue   *queue, GFunc func, gpointer user_data);
568
569 /*
570  * Messages
571  */
572 #ifndef G_LOG_DOMAIN
573 #define G_LOG_DOMAIN ((gchar*) 0)
574 #endif
575
576 typedef enum {
577         G_LOG_FLAG_RECURSION          = 1 << 0,
578         G_LOG_FLAG_FATAL              = 1 << 1,
579         
580         G_LOG_LEVEL_ERROR             = 1 << 2,
581         G_LOG_LEVEL_CRITICAL          = 1 << 3,
582         G_LOG_LEVEL_WARNING           = 1 << 4,
583         G_LOG_LEVEL_MESSAGE           = 1 << 5,
584         G_LOG_LEVEL_INFO              = 1 << 6,
585         G_LOG_LEVEL_DEBUG             = 1 << 7,
586         
587         G_LOG_LEVEL_MASK              = ~(G_LOG_FLAG_RECURSION | G_LOG_FLAG_FATAL)
588 } GLogLevelFlags;
589
590 void           g_print                (const gchar *format, ...);
591 void           g_printerr             (const gchar *format, ...);
592 GLogLevelFlags g_log_set_always_fatal (GLogLevelFlags fatal_mask);
593 GLogLevelFlags g_log_set_fatal_mask   (const gchar *log_domain, GLogLevelFlags fatal_mask);
594 void           g_logv                 (const gchar *log_domain, GLogLevelFlags log_level, const gchar *format, va_list args);
595 void           g_log                  (const gchar *log_domain, GLogLevelFlags log_level, const gchar *format, ...);
596 void           g_assertion_message    (const gchar *format, ...) G_GNUC_NORETURN;
597
598 #ifdef HAVE_C99_SUPPORT
599 /* The for (;;) tells gc thats g_error () doesn't return, avoiding warnings */
600 #define g_error(format, ...)    do { g_log (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, format, __VA_ARGS__); for (;;); } while (0)
601 #define g_critical(format, ...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, format, __VA_ARGS__)
602 #define g_warning(format, ...)  g_log (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, format, __VA_ARGS__)
603 #define g_message(format, ...)  g_log (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, format, __VA_ARGS__)
604 #define g_debug(format, ...)    g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format, __VA_ARGS__)
605 #else   /* HAVE_C99_SUPPORT */
606 #define g_error(...)    do { g_log (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, __VA_ARGS__); for (;;); } while (0)
607 #define g_critical(...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, __VA_ARGS__)
608 #define g_warning(...)  g_log (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, __VA_ARGS__)
609 #define g_message(...)  g_log (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, __VA_ARGS__)
610 #define g_debug(...)    g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, __VA_ARGS__)
611 #endif  /* ndef HAVE_C99_SUPPORT */
612 #define g_log_set_handler(a,b,c,d)
613
614 #define G_GNUC_INTERNAL
615
616 /*
617  * Conversions
618  */
619
620 gpointer g_convert_error_quark(void);
621
622
623 /*
624  * Unicode Manipulation: most of this is not used by Mono by default, it is
625  * only used if the old collation code is activated, so this is only the
626  * bare minimum to build.
627  */
628
629 typedef enum {
630         G_UNICODE_CONTROL,
631         G_UNICODE_FORMAT,
632         G_UNICODE_UNASSIGNED,
633         G_UNICODE_PRIVATE_USE,
634         G_UNICODE_SURROGATE,
635         G_UNICODE_LOWERCASE_LETTER,
636         G_UNICODE_MODIFIER_LETTER,
637         G_UNICODE_OTHER_LETTER,
638         G_UNICODE_TITLECASE_LETTER,
639         G_UNICODE_UPPERCASE_LETTER,
640         G_UNICODE_COMBINING_MARK,
641         G_UNICODE_ENCLOSING_MARK,
642         G_UNICODE_NON_SPACING_MARK,
643         G_UNICODE_DECIMAL_NUMBER,
644         G_UNICODE_LETTER_NUMBER,
645         G_UNICODE_OTHER_NUMBER,
646         G_UNICODE_CONNECT_PUNCTUATION,
647         G_UNICODE_DASH_PUNCTUATION,
648         G_UNICODE_CLOSE_PUNCTUATION,
649         G_UNICODE_FINAL_PUNCTUATION,
650         G_UNICODE_INITIAL_PUNCTUATION,
651         G_UNICODE_OTHER_PUNCTUATION,
652         G_UNICODE_OPEN_PUNCTUATION,
653         G_UNICODE_CURRENCY_SYMBOL,
654         G_UNICODE_MODIFIER_SYMBOL,
655         G_UNICODE_MATH_SYMBOL,
656         G_UNICODE_OTHER_SYMBOL,
657         G_UNICODE_LINE_SEPARATOR,
658         G_UNICODE_PARAGRAPH_SEPARATOR,
659         G_UNICODE_SPACE_SEPARATOR
660 } GUnicodeType;
661
662 typedef enum {
663         G_UNICODE_BREAK_MANDATORY,
664         G_UNICODE_BREAK_CARRIAGE_RETURN,
665         G_UNICODE_BREAK_LINE_FEED,
666         G_UNICODE_BREAK_COMBINING_MARK,
667         G_UNICODE_BREAK_SURROGATE,
668         G_UNICODE_BREAK_ZERO_WIDTH_SPACE,
669         G_UNICODE_BREAK_INSEPARABLE,
670         G_UNICODE_BREAK_NON_BREAKING_GLUE,
671         G_UNICODE_BREAK_CONTINGENT,
672         G_UNICODE_BREAK_SPACE,
673         G_UNICODE_BREAK_AFTER,
674         G_UNICODE_BREAK_BEFORE,
675         G_UNICODE_BREAK_BEFORE_AND_AFTER,
676         G_UNICODE_BREAK_HYPHEN,
677         G_UNICODE_BREAK_NON_STARTER,
678         G_UNICODE_BREAK_OPEN_PUNCTUATION,
679         G_UNICODE_BREAK_CLOSE_PUNCTUATION,
680         G_UNICODE_BREAK_QUOTATION,
681         G_UNICODE_BREAK_EXCLAMATION,
682         G_UNICODE_BREAK_IDEOGRAPHIC,
683         G_UNICODE_BREAK_NUMERIC,
684         G_UNICODE_BREAK_INFIX_SEPARATOR,
685         G_UNICODE_BREAK_SYMBOL,
686         G_UNICODE_BREAK_ALPHABETIC,
687         G_UNICODE_BREAK_PREFIX,
688         G_UNICODE_BREAK_POSTFIX,
689         G_UNICODE_BREAK_COMPLEX_CONTEXT,
690         G_UNICODE_BREAK_AMBIGUOUS,
691         G_UNICODE_BREAK_UNKNOWN,
692         G_UNICODE_BREAK_NEXT_LINE,
693         G_UNICODE_BREAK_WORD_JOINER,
694         G_UNICODE_BREAK_HANGUL_L_JAMO,
695         G_UNICODE_BREAK_HANGUL_V_JAMO,
696         G_UNICODE_BREAK_HANGUL_T_JAMO,
697         G_UNICODE_BREAK_HANGUL_LV_SYLLABLE,
698         G_UNICODE_BREAK_HANGUL_LVT_SYLLABLE
699 } GUnicodeBreakType;
700
701 gunichar       g_unichar_toupper (gunichar c);
702 gunichar       g_unichar_tolower (gunichar c);
703 gunichar       g_unichar_totitle (gunichar c);
704 GUnicodeType   g_unichar_type    (gunichar c);
705 gboolean       g_unichar_isspace (gunichar c);
706 gboolean       g_unichar_isxdigit (gunichar c);
707 gint           g_unichar_xdigit_value (gunichar c);
708 GUnicodeBreakType   g_unichar_break_type (gunichar c);
709
710 #ifndef MAX
711 #define MAX(a,b) (((a)>(b)) ? (a) : (b))
712 #endif
713
714 #ifndef MIN
715 #define MIN(a,b) (((a)<(b)) ? (a) : (b))
716 #endif
717
718 #ifndef CLAMP
719 #define CLAMP(a,low,high) (((a) < (low)) ? (low) : (((a) > (high)) ? (high) : (a)))
720 #endif
721
722 #if defined(__GNUC__) && (__GNUC__ > 2)
723 #define G_LIKELY(expr) (__builtin_expect ((expr) != 0, 1))
724 #define G_UNLIKELY(expr) (__builtin_expect ((expr) != 0, 0))
725 #else
726 #define G_LIKELY(x) (x)
727 #define G_UNLIKELY(x) (x)
728 #endif
729
730 #define  g_assert(x)     G_STMT_START { if (G_UNLIKELY (!(x))) g_assertion_message ("* Assertion at %s:%d, condition `%s' not met\n", __FILE__, __LINE__, #x);  } G_STMT_END
731 #define  g_assert_not_reached() G_STMT_START { g_assertion_message ("* Assertion: should not be reached at %s:%d\n", __FILE__, __LINE__); } G_STMT_END
732
733 /*
734  * Unicode conversion
735  */
736
737 #define G_CONVERT_ERROR g_convert_error_quark()
738
739 typedef enum {
740         G_CONVERT_ERROR_NO_CONVERSION,
741         G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
742         G_CONVERT_ERROR_FAILED,
743         G_CONVERT_ERROR_PARTIAL_INPUT,
744         G_CONVERT_ERROR_BAD_URI,
745         G_CONVERT_ERROR_NOT_ABSOLUTE_PATH
746 } GConvertError;
747
748 gchar     *g_utf8_strup (const gchar *str, gssize len);
749 gchar     *g_utf8_strdown (const gchar *str, gssize len);
750 gint       g_unichar_to_utf8 (gunichar c, gchar *outbuf);
751 gunichar  *g_utf8_to_ucs4_fast (const gchar *str, glong len, glong *items_written);
752 gunichar  *g_utf8_to_ucs4 (const gchar *str, glong len, glong *items_read, glong *items_written, GError **err);
753 gunichar2 *g_utf8_to_utf16 (const gchar *str, glong len, glong *items_read, glong *items_written, GError **err);
754 gchar     *g_utf16_to_utf8 (const gunichar2 *str, glong len, glong *items_read, glong *items_written, GError **err);
755 gunichar  *g_utf16_to_ucs4 (const gunichar2 *str, glong len, glong *items_read, glong *items_written, GError **err);
756 gchar     *g_ucs4_to_utf8  (const gunichar *str, glong len, glong *items_read, glong *items_written, GError **err);
757 gunichar2 *g_ucs4_to_utf16 (const gunichar *str, glong len, glong *items_read, glong *items_written, GError **err);
758
759 #define u8to16(str) g_utf8_to_utf16(str, (glong)strlen(str), NULL, NULL, NULL)
760
761 #ifdef G_OS_WIN32
762 #define u16to8(str) g_utf16_to_utf8((gunichar2 *) (str), (glong)wcslen((wchar_t *) (str)), NULL, NULL, NULL)
763 #else
764 #define u16to8(str) g_utf16_to_utf8(str, (glong)strlen(str), NULL, NULL, NULL)
765 #endif
766
767 /*
768  * Path
769  */
770 gchar  *g_build_path           (const gchar *separator, const gchar *first_element, ...);
771 #define g_build_filename(x, ...) g_build_path(G_DIR_SEPARATOR_S, x, __VA_ARGS__)
772 gchar  *g_path_get_dirname     (const gchar *filename);
773 gchar  *g_path_get_basename    (const char *filename);
774 gchar  *g_find_program_in_path (const gchar *program);
775 gchar  *g_get_current_dir      (void);
776 gboolean g_path_is_absolute    (const char *filename);
777
778 const gchar *g_get_home_dir    (void);
779 const gchar *g_get_tmp_dir     (void);
780 const gchar *g_get_user_name   (void);
781 gchar *g_get_prgname           (void);
782 void  g_set_prgname            (const gchar *prgname);
783
784 /*
785  * Shell
786  */
787
788 gboolean  g_shell_parse_argv (const gchar *command_line, gint *argcp, gchar ***argvp, GError **error);
789 gchar    *g_shell_unquote    (const gchar *quoted_string, GError **error);
790 gchar    *g_shell_quote      (const gchar *unquoted_string);
791
792 /*
793  * Spawn
794  */
795 typedef enum {
796         G_SPAWN_LEAVE_DESCRIPTORS_OPEN = 1,
797         G_SPAWN_DO_NOT_REAP_CHILD      = 1 << 1,
798         G_SPAWN_SEARCH_PATH            = 1 << 2,
799         G_SPAWN_STDOUT_TO_DEV_NULL     = 1 << 3,
800         G_SPAWN_STDERR_TO_DEV_NULL     = 1 << 4,
801         G_SPAWN_CHILD_INHERITS_STDIN   = 1 << 5,
802         G_SPAWN_FILE_AND_ARGV_ZERO     = 1 << 6
803 } GSpawnFlags;
804
805 typedef void (*GSpawnChildSetupFunc) (gpointer user_data);
806
807 gboolean g_spawn_command_line_sync (const gchar *command_line, gchar **standard_output, gchar **standard_error, gint *exit_status, GError **error);
808 gboolean g_spawn_async_with_pipes  (const gchar *working_directory, gchar **argv, gchar **envp, GSpawnFlags flags, GSpawnChildSetupFunc child_setup,
809                                 gpointer user_data, GPid *child_pid, gint *standard_input, gint *standard_output, gint *standard_error, GError **error);
810
811
812 /*
813  * Timer
814  */
815 typedef struct _GTimer GTimer;
816
817 GTimer *g_timer_new (void);
818 void g_timer_destroy (GTimer *timer);
819 gdouble g_timer_elapsed (GTimer *timer, gulong *microseconds);
820 void g_timer_stop (GTimer *timer);
821 void g_timer_start (GTimer *timer);
822
823 /*
824  * Date and time
825  */
826 typedef struct {
827         glong tv_sec;
828         glong tv_usec;
829 } GTimeVal;
830
831 void g_get_current_time (GTimeVal *result);
832 void g_usleep (gulong microseconds);
833
834 /*
835  * File
836  */
837
838 gpointer g_file_error_quark (void);
839
840 #define G_FILE_ERROR g_file_error_quark ()
841
842 typedef enum {
843         G_FILE_ERROR_EXIST,
844         G_FILE_ERROR_ISDIR,
845         G_FILE_ERROR_ACCES,
846         G_FILE_ERROR_NAMETOOLONG,
847         G_FILE_ERROR_NOENT,
848         G_FILE_ERROR_NOTDIR,
849         G_FILE_ERROR_NXIO,
850         G_FILE_ERROR_NODEV,
851         G_FILE_ERROR_ROFS,
852         G_FILE_ERROR_TXTBSY,
853         G_FILE_ERROR_FAULT,
854         G_FILE_ERROR_LOOP,
855         G_FILE_ERROR_NOSPC,
856         G_FILE_ERROR_NOMEM,
857         G_FILE_ERROR_MFILE,
858         G_FILE_ERROR_NFILE,
859         G_FILE_ERROR_BADF,
860         G_FILE_ERROR_INVAL,
861         G_FILE_ERROR_PIPE,
862         G_FILE_ERROR_AGAIN,
863         G_FILE_ERROR_INTR,
864         G_FILE_ERROR_IO,
865         G_FILE_ERROR_PERM,
866         G_FILE_ERROR_NOSYS,
867         G_FILE_ERROR_FAILED
868 } GFileError;
869
870 typedef enum {
871         G_FILE_TEST_IS_REGULAR = 1 << 0,
872         G_FILE_TEST_IS_SYMLINK = 1 << 1,
873         G_FILE_TEST_IS_DIR = 1 << 2,
874         G_FILE_TEST_IS_EXECUTABLE = 1 << 3,
875         G_FILE_TEST_EXISTS = 1 << 4
876 } GFileTest;
877
878
879 gboolean   g_file_set_contents (const gchar *filename, const gchar *contents, gssize length, GError **error);
880 gboolean   g_file_get_contents (const gchar *filename, gchar **contents, gsize *length, GError **error);
881 GFileError g_file_error_from_errno (gint err_no);
882 gint       g_file_open_tmp (const gchar *tmpl, gchar **name_used, GError **error);
883 gboolean   g_file_test (const gchar *filename, GFileTest test);
884
885 #define g_open open
886 #define g_rename rename
887 #define g_stat stat
888 #define g_unlink unlink
889 #define g_fopen fopen
890 #define g_lstat lstat
891 #define g_rmdir rmdir
892 #define g_mkstemp mkstemp
893 #define g_ascii_isdigit isdigit
894 #define g_ascii_strtod strtod
895 #define g_ascii_isalnum isalnum
896
897 /*
898  * Pattern matching
899  */
900 typedef struct _GPatternSpec GPatternSpec;
901 GPatternSpec * g_pattern_spec_new (const gchar *pattern);
902 void           g_pattern_spec_free (GPatternSpec *pspec);
903 gboolean       g_pattern_match_string (GPatternSpec *pspec, const gchar *string);
904
905 /*
906  * Directory
907  */
908 typedef struct _GDir GDir;
909 GDir        *g_dir_open (const gchar *path, guint flags, GError **error);
910 const gchar *g_dir_read_name (GDir *dir);
911 void         g_dir_rewind (GDir *dir);
912 void         g_dir_close (GDir *dir);
913
914 int          g_mkdir_with_parents (const gchar *pathname, int mode);
915 #define g_mkdir mkdir
916
917 /*
918  * GMarkup
919  */
920 typedef struct _GMarkupParseContext GMarkupParseContext;
921
922 typedef enum
923 {
924         G_MARKUP_DO_NOT_USE_THIS_UNSUPPORTED_FLAG = 1 << 0,
925         G_MARKUP_TREAT_CDATA_AS_TEXT              = 1 << 1
926 } GMarkupParseFlags;
927
928 typedef struct {
929         void (*start_element)  (GMarkupParseContext *context,
930                                 const gchar *element_name,
931                                 const gchar **attribute_names,
932                                 const gchar **attribute_values,
933                                 gpointer user_data,
934                                 GError **error);
935
936         void (*end_element)    (GMarkupParseContext *context,
937                                 const gchar         *element_name,
938                                 gpointer             user_data,
939                                 GError             **error);
940         
941         void (*text)           (GMarkupParseContext *context,
942                                 const gchar         *text,
943                                 gsize                text_len,  
944                                 gpointer             user_data,
945                                 GError             **error);
946         
947         void (*passthrough)    (GMarkupParseContext *context,
948                                 const gchar         *passthrough_text,
949                                 gsize                text_len,  
950                                 gpointer             user_data,
951                                 GError             **error);
952         void (*error)          (GMarkupParseContext *context,
953                                 GError              *error,
954                                 gpointer             user_data);
955 } GMarkupParser;
956
957 GMarkupParseContext *g_markup_parse_context_new   (const GMarkupParser *parser,
958                                                    GMarkupParseFlags flags,
959                                                    gpointer user_data,
960                                                    GDestroyNotify user_data_dnotify);
961 void                 g_markup_parse_context_free  (GMarkupParseContext *context);
962 gboolean             g_markup_parse_context_parse (GMarkupParseContext *context,
963                                                    const gchar *text, gssize text_len,
964                                                    GError **error);
965 gboolean         g_markup_parse_context_end_parse (GMarkupParseContext *context,
966                                                    GError **error);
967
968 /*
969  * Character set conversion
970  */
971 typedef struct _GIConv *GIConv;
972
973 gsize g_iconv (GIConv cd, gchar **inbytes, gsize *inbytesleft, gchar **outbytes, gsize *outbytesleft);
974 GIConv g_iconv_open (const gchar *to_charset, const gchar *from_charset);
975 int g_iconv_close (GIConv cd);
976
977 gboolean  g_get_charset        (G_CONST_RETURN char **charset);
978 gchar    *g_locale_to_utf8     (const gchar *opsysstring, gssize len,
979                                 gsize *bytes_read, gsize *bytes_written,
980                                 GError **error);
981 gchar    *g_locale_from_utf8   (const gchar *utf8string, gssize len, gsize *bytes_read,
982                                 gsize *bytes_written, GError **error);
983 gchar    *g_filename_from_utf8 (const gchar *utf8string, gssize len, gsize *bytes_read,
984                                 gsize *bytes_written, GError **error);
985 gchar    *g_convert            (const gchar *str, gssize len,
986                                 const gchar *to_codeset, const gchar *from_codeset,
987                                 gsize *bytes_read, gsize *bytes_written, GError **error);
988
989 /*
990  * Unicode manipulation
991  */
992 extern const guchar g_utf8_jump_table[256];
993
994 gboolean  g_utf8_validate      (const gchar *str, gssize max_len, const gchar **end);
995 gunichar  g_utf8_get_char_validated (const gchar *str, gssize max_len);
996 gchar    *g_utf8_find_prev_char (const char *str, const char *p);
997 gchar    *g_utf8_prev_char     (const char *str);
998 #define   g_utf8_next_char(p)  ((p) + g_utf8_jump_table[(guchar)(*p)])
999 gunichar  g_utf8_get_char      (const gchar *src);
1000 glong     g_utf8_strlen        (const gchar *str, gssize max);
1001 gchar    *g_utf8_offset_to_pointer (const gchar *str, glong offset);
1002 glong     g_utf8_pointer_to_offset (const gchar *str, const gchar *pos);
1003
1004 /*
1005  * priorities
1006  */
1007 #define G_PRIORITY_DEFAULT 0
1008 #define G_PRIORITY_DEFAULT_IDLE 200
1009
1010 /*
1011  * Empty thread functions, not used by eglib
1012  */
1013 #define g_thread_supported()   TRUE
1014 #define g_thread_init(x)       G_STMT_START { if (x != NULL) { g_error ("No vtable supported in g_thread_init"); } } G_STMT_END
1015
1016 #define G_LOCK_DEFINE(name)        int name;
1017 #define G_LOCK_DEFINE_STATIC(name) static int name;
1018 #define G_LOCK_EXTERN(name)
1019 #define G_LOCK(name)
1020 #define G_TRYLOCK(name)
1021 #define G_UNLOCK(name)
1022
1023 #define GUINT16_SWAP_LE_BE_CONSTANT(x) ((((guint16) x) >> 8) | ((((guint16) x) << 8)))
1024
1025 #define GUINT16_SWAP_LE_BE(x) ((guint16) (((guint16) x) >> 8) | ((((guint16)(x)) & 0xff) << 8))
1026 #define GUINT32_SWAP_LE_BE(x) ((guint32) \
1027                                ( (((guint32) (x)) << 24)| \
1028                                  ((((guint32) (x)) & 0xff0000) >> 8) | \
1029                                  ((((guint32) (x)) & 0xff00) << 8) | \
1030                                  (((guint32) (x)) >> 24)) )
1031  
1032 #define GUINT64_SWAP_LE_BE(x) ((guint64) (((guint64)(GUINT32_SWAP_LE_BE(((guint64)x) & 0xffffffff))) << 32) | \
1033                                GUINT32_SWAP_LE_BE(((guint64)x) >> 32))
1034
1035                                   
1036  
1037 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
1038 #   define GUINT64_FROM_BE(x) GUINT64_SWAP_LE_BE(x)
1039 #   define GUINT32_FROM_BE(x) GUINT32_SWAP_LE_BE(x)
1040 #   define GUINT16_FROM_BE(x) GUINT16_SWAP_LE_BE(x)
1041 #   define GUINT_FROM_BE(x)   GUINT32_SWAP_LE_BE(x)
1042 #   define GUINT64_FROM_LE(x) (x)
1043 #   define GUINT32_FROM_LE(x) (x)
1044 #   define GUINT16_FROM_LE(x) (x)
1045 #   define GUINT_FROM_LE(x)   (x)
1046 #   define GUINT64_TO_BE(x)   GUINT64_SWAP_LE_BE(x)
1047 #   define GUINT32_TO_BE(x)   GUINT32_SWAP_LE_BE(x)
1048 #   define GUINT16_TO_BE(x)   GUINT16_SWAP_LE_BE(x)
1049 #   define GUINT_TO_BE(x)     GUINT32_SWAP_LE_BE(x)
1050 #   define GUINT64_TO_LE(x)   (x)
1051 #   define GUINT32_TO_LE(x)   (x)
1052 #   define GUINT16_TO_LE(x)   (x)
1053 #   define GUINT_TO_LE(x)     (x)
1054 #else
1055 #   define GUINT64_FROM_BE(x) (x)
1056 #   define GUINT32_FROM_BE(x) (x)
1057 #   define GUINT16_FROM_BE(x) (x)
1058 #   define GUINT_FROM_BE(x)   (x)
1059 #   define GUINT64_FROM_LE(x) GUINT64_SWAP_LE_BE(x)
1060 #   define GUINT32_FROM_LE(x) GUINT32_SWAP_LE_BE(x)
1061 #   define GUINT16_FROM_LE(x) GUINT16_SWAP_LE_BE(x)
1062 #   define GUINT_FROM_LE(x)   GUINT32_SWAP_LE_BE(x)
1063 #   define GUINT64_TO_BE(x)   (x)
1064 #   define GUINT32_TO_BE(x)   (x)
1065 #   define GUINT16_TO_BE(x)   (x)
1066 #   define GUINT_TO_BE(x)     (x)
1067 #   define GUINT64_TO_LE(x)   GUINT64_SWAP_LE_BE(x)
1068 #   define GUINT32_TO_LE(x)   GUINT32_SWAP_LE_BE(x)
1069 #   define GUINT16_TO_LE(x)   GUINT16_SWAP_LE_BE(x)
1070 #   define GUINT_TO_LE(x)     GUINT32_SWAP_LE_BE(x)
1071 #endif
1072
1073 #define GINT64_FROM_BE(x)   (GUINT64_TO_BE (x))
1074 #define GINT32_FROM_BE(x)   (GUINT32_TO_BE (x))
1075 #define GINT16_FROM_BE(x)   (GUINT16_TO_BE (x))
1076 #define GINT64_FROM_LE(x)   (GUINT64_TO_LE (x))
1077 #define GINT32_FROM_LE(x)   (GUINT32_TO_LE (x))
1078 #define GINT16_FROM_LE(x)   (GUINT16_TO_LE (x))
1079
1080 #define _EGLIB_MAJOR  2
1081 #define _EGLIB_MIDDLE 4
1082 #define _EGLIB_MINOR  0
1083  
1084 #define GLIB_CHECK_VERSION(a,b,c) ((a < _EGLIB_MAJOR) || (a == _EGLIB_MAJOR && (b < _EGLIB_MIDDLE || (b == _EGLIB_MIDDLE && c <= _EGLIB_MINOR))))
1085  
1086 G_END_DECLS
1087
1088 #endif
1089
1090
1091