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