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