4 // Ask stdint.h and inttypes.h for the full C99 features for CentOS 6 g++ 4.4, Android, etc.
6 // $HOME/android-toolchain/toolchains/armeabi-v7a-clang/sysroot/usr/include/inttypes.h
7 // $HOME/android-toolchain/toolchains/armeabi-v7a-clang/sysroot/usr/include/stdint.h
9 #ifndef __STDC_LIMIT_MACROS
10 #define __STDC_LIMIT_MACROS
12 #ifndef __STDC_CONSTANT_MACROS
13 #define __STDC_CONSTANT_MACROS
15 #ifndef __STDC_FORMAT_MACROS
16 #define __STDC_FORMAT_MACROS
30 #include <eglib-config.hw>
32 #include <eglib-config.h>
35 // - Pointers should only be converted to or from pointer-sized integers.
36 // - Any size integer can be converted to any other size integer.
37 // - Therefore a pointer-sized integer is the intermediary between
38 // a pointer and any integer type.
39 #define GPOINTER_TO_INT(ptr) ((gint)(gssize)(ptr))
40 #define GPOINTER_TO_UINT(ptr) ((guint)(gsize)(ptr))
41 #define GINT_TO_POINTER(v) ((gpointer)(gssize)(v))
42 #define GUINT_TO_POINTER(v) ((gpointer)(gsize)(v))
44 #ifndef EGLIB_NO_REMAP
45 #include <eglib-remap.h>
48 #ifdef G_HAVE_ALLOCA_H
57 #ifdef G_HAVE_UNISTD_H
62 # define offsetof(s_name,n_name) (size_t)(char *)&(((s_name*)0)->m_name)
66 #define G_BEGIN_DECLS extern "C" {
68 #define G_EXTERN_C extern "C"
70 #define G_BEGIN_DECLS /* nothing */
71 #define G_END_DECLS /* nothing */
72 #define G_EXTERN_C /* nothing */
77 #define g_cast monoeg_g_cast // in case not inlined (see eglib-remap.h)
79 // g_cast converts void* to T*.
80 // e.g. #define malloc(x) (g_cast (malloc (x)))
81 // FIXME It used to do more. Rename?
87 explicit g_cast (void volatile *y
) : x((void*)y
) { }
88 // Lack of rvalue constructor inhibits ternary operator.
89 // Either don't use ternary, or cast each side.
90 // sa = (salen <= 128) ? g_alloca (salen) : g_malloc (salen);
91 // w32socket.c:1045:24: error: call to deleted constructor of 'monoeg_g_cast'
92 //g_cast (g_cast&& y) : x(y.x) { }
93 g_cast (g_cast
&&) = delete;
95 g_cast (const g_cast
&) = delete;
97 template <typename TTo
>
98 operator TTo
* () const
106 // FIXME? Parens are omitted to preserve prior meaning.
111 // G++4.4 breaks opeq below without this.
112 #if defined (__GNUC__) || defined (__clang__)
113 #define G_MAY_ALIAS __attribute__((__may_alias__))
115 #define G_MAY_ALIAS /* nothing */
120 // Provide for bit operations on enums, but not all integer operations.
121 // This alleviates a fair number of casts in porting C to C++.
123 // Forward declare template with no generic implementation.
124 template <size_t> struct g_size_to_int
;
126 // Template specializations.
127 template <> struct g_size_to_int
<1> { typedef int8_t type
; };
128 template <> struct g_size_to_int
<2> { typedef int16_t type
; };
129 template <> struct g_size_to_int
<4> { typedef int32_t type
; };
130 template <> struct g_size_to_int
<8> { typedef int64_t type
; };
132 // g++4.4 does not accept:
133 //template <typename T>
134 //using g_size_to_int_t = typename g_size_to_int <sizeof (T)>::type;
135 #define g_size_to_int_t(x) g_size_to_int <sizeof (x)>::type
137 #define G_ENUM_BINOP(Enum, op, opeq) \
139 operator op (Enum a, Enum b) \
141 typedef g_size_to_int_t (Enum) type; \
142 return static_cast<Enum>(static_cast<type>(a) op b); \
146 operator opeq (Enum& a, Enum b) \
148 typedef g_size_to_int_t (Enum) G_MAY_ALIAS type; \
149 return (Enum&)((type&)a opeq b); \
152 #define G_ENUM_FUNCTIONS(Enum) \
153 extern "C++" { /* in case within extern "C" */ \
157 typedef g_size_to_int_t (Enum) type; \
158 return static_cast<Enum>(~static_cast<type>(a)); \
161 G_ENUM_BINOP (Enum, |, |=) \
162 G_ENUM_BINOP (Enum, &, &=) \
163 G_ENUM_BINOP (Enum, ^, ^=) \
168 #define G_ENUM_FUNCTIONS(Enum) /* nothing */
177 typedef unsigned int guint
;
178 typedef short gshort
;
179 typedef unsigned short gushort
;
181 typedef unsigned long gulong
;
182 typedef void * gpointer
;
183 typedef const void * gconstpointer
;
185 typedef unsigned char guchar
;
187 /* Types defined in terms of the stdint.h */
188 typedef int8_t gint8
;
189 typedef uint8_t guint8
;
190 typedef int16_t gint16
;
191 typedef uint16_t guint16
;
192 typedef int32_t gint32
;
193 typedef uint32_t guint32
;
194 typedef int64_t gint64
;
195 typedef uint64_t guint64
;
196 typedef float gfloat
;
197 typedef double gdouble
;
198 typedef int32_t gboolean
;
200 #if defined (HOST_WIN32) || defined (_WIN32)
203 typedef wchar_t gunichar2
;
206 typedef guint16 gunichar2
;
208 typedef guint32 gunichar
;
213 #define G_N_ELEMENTS(s) (sizeof(s) / sizeof ((s) [0]))
215 // e.g. strncmp (foo, G_STRING_CONSTANT_AND_LENGTH ("version"))
216 #define G_STRING_CONSTANT_AND_LENGTH(x) (x), G_N_ELEMENTS (x) - 1
221 #define G_MINSHORT SHRT_MIN
222 #define G_MAXSHORT SHRT_MAX
223 #define G_MAXUSHORT USHRT_MAX
224 #define G_MAXINT INT_MAX
225 #define G_MININT INT_MIN
226 #define G_MAXINT8 INT8_MAX
227 #define G_MAXUINT8 UINT8_MAX
228 #define G_MININT8 INT8_MIN
229 #define G_MAXINT16 INT16_MAX
230 #define G_MAXUINT16 UINT16_MAX
231 #define G_MININT16 INT16_MIN
232 #define G_MAXINT32 INT32_MAX
233 #define G_MAXUINT32 UINT32_MAX
234 #define G_MININT32 INT32_MIN
235 #define G_MININT64 INT64_MIN
236 #define G_MAXINT64 INT64_MAX
237 #define G_MAXUINT64 UINT64_MAX
239 #define G_LITTLE_ENDIAN 1234
240 #define G_BIG_ENDIAN 4321
241 #define G_STMT_START do
242 #define G_STMT_END while (0)
244 #define G_USEC_PER_SEC 1000000
247 #define ABS(a) ((a) > 0 ? (a) : -(a))
251 #define ALIGN_TO(val,align) ((((gssize)val) + ((align) - 1)) & ~((align) - 1))
255 #define ALIGN_PTR_TO(ptr,align) (gpointer)((((gssize)(ptr)) + (align - 1)) & (~(align - 1)))
258 #define G_STRUCT_OFFSET(p_type,field) offsetof(p_type,field)
260 #define EGLIB_STRINGIFY(x) #x
261 #define EGLIB_TOSTRING(x) EGLIB_STRINGIFY(x)
262 #define G_STRLOC __FILE__ ":" EGLIB_TOSTRING(__LINE__) ":"
264 #define G_CONST_RETURN const
266 #define G_GUINT64_FORMAT PRIu64
267 #define G_GINT64_FORMAT PRIi64
268 #define G_GUINT32_FORMAT PRIu32
269 #define G_GINT32_FORMAT PRIi32
272 #define G_ATTR_FORMAT_PRINTF(fmt_pos,arg_pos) __attribute__((__format__(__printf__,fmt_pos,arg_pos)))
274 #define G_ATTR_FORMAT_PRINTF(fmt_pos,arg_pos)
280 G_EXTERN_C
// Used by MonoPosixHelper or MonoSupportW, at least.
281 void g_free (void *ptr
);
282 G_EXTERN_C
// Used by MonoPosixHelper or MonoSupportW, at least.
283 gpointer
g_realloc (gpointer obj
, gsize size
);
284 G_EXTERN_C
// Used by MonoPosixHelper or MonoSupportW, at least.
285 gpointer
g_malloc (gsize x
);
286 G_EXTERN_C
// Used by MonoPosixHelper or MonoSupportW, at least.
287 gpointer
g_malloc0 (gsize x
);
288 G_EXTERN_C
// Used by profilers, at least.
289 gpointer
g_calloc (gsize n
, gsize x
);
290 gpointer
g_try_malloc (gsize x
);
291 gpointer
g_try_realloc (gpointer obj
, gsize size
);
293 #define g_new(type,size) ((type *) g_malloc (sizeof (type) * (size)))
294 #define g_new0(type,size) ((type *) g_malloc0 (sizeof (type)* (size)))
295 #define g_newa(type,size) ((type *) alloca (sizeof (type) * (size)))
297 #define g_memmove(dest,src,len) memmove (dest, src, len)
298 #define g_renew(struct_type, mem, n_structs) ((struct_type*)g_realloc (mem, sizeof (struct_type) * n_structs))
299 #define g_alloca(size) (g_cast (alloca (size)))
301 G_EXTERN_C
// Used by libtest, at least.
302 gpointer
g_memdup (gconstpointer mem
, guint byte_size
);
303 static inline gchar
*g_strdup (const gchar
*str
) { if (str
) { return (gchar
*) g_memdup (str
, (guint
)strlen (str
) + 1); } return NULL
; }
304 gchar
**g_strdupv (gchar
**str_array
);
307 gpointer (*malloc
) (gsize n_bytes
);
308 gpointer (*realloc
) (gpointer mem
, gsize n_bytes
);
309 void (*free
) (gpointer mem
);
310 gpointer (*calloc
) (gsize n_blocks
, gsize n_block_bytes
);
313 void g_mem_set_vtable (GMemVTable
* vtable
);
314 void g_mem_get_vtable (GMemVTable
* vtable
);
320 typedef struct _GMemChunk GMemChunk
;
325 gboolean
g_hasenv(const gchar
*variable
);
326 gchar
* g_getenv(const gchar
*variable
);
328 G_EXTERN_C
// sdks/wasm/driver.c is C and uses this
329 gboolean
g_setenv(const gchar
*variable
, const gchar
*value
, gboolean overwrite
);
331 void g_unsetenv(const gchar
*variable
);
333 gchar
* g_win32_getlocale(void);
336 * Precondition macros
338 #define g_warn_if_fail(x) G_STMT_START { if (!(x)) { g_warning ("%s:%d: assertion '%s' failed\n", __FILE__, __LINE__, #x); } } G_STMT_END
339 #define g_return_if_fail(x) G_STMT_START { if (!(x)) { g_critical ("%s:%d: assertion '%s' failed\n", __FILE__, __LINE__, #x); return; } } G_STMT_END
340 #define g_return_val_if_fail(x,e) G_STMT_START { if (!(x)) { g_critical ("%s:%d: assertion '%s' failed\n", __FILE__, __LINE__, #x); return (e); } } G_STMT_END
346 /* In the real glib, this is a GQuark, but we dont use/need that */
352 void g_clear_error (GError
**gerror
);
353 void g_error_free (GError
*gerror
);
354 GError
*g_error_new (gpointer domain
, gint code
, const char *format
, ...);
355 void g_set_error (GError
**err
, gpointer domain
, gint code
, const gchar
*format
, ...);
356 void g_propagate_error (GError
**dest
, GError
*src
);
361 G_EXTERN_C
// Used by libtest, at least.
362 gchar
*g_strdup_printf (const gchar
*format
, ...) G_ATTR_FORMAT_PRINTF(1, 2);
363 gchar
*g_strdup_vprintf (const gchar
*format
, va_list args
);
364 gchar
*g_strndup (const gchar
*str
, gsize n
);
365 const gchar
*g_strerror (gint errnum
);
366 gchar
*g_strndup (const gchar
*str
, gsize n
);
367 void g_strfreev (gchar
**str_array
);
368 gchar
*g_strconcat (const gchar
*first
, ...);
369 gchar
**g_strsplit (const gchar
*string
, const gchar
*delimiter
, gint max_tokens
);
370 gchar
**g_strsplit_set (const gchar
*string
, const gchar
*delimiter
, gint max_tokens
);
371 gchar
*g_strreverse (gchar
*str
);
372 gboolean
g_str_has_prefix (const gchar
*str
, const gchar
*prefix
);
373 gboolean
g_str_has_suffix (const gchar
*str
, const gchar
*suffix
);
374 guint
g_strv_length (gchar
**str_array
);
375 gchar
*g_strjoin (const gchar
*separator
, ...);
376 gchar
*g_strjoinv (const gchar
*separator
, gchar
**str_array
);
377 gchar
*g_strchug (gchar
*str
);
378 gchar
*g_strchomp (gchar
*str
);
379 void g_strdown (gchar
*string
);
380 gchar
*g_strnfill (gsize length
, gchar fill_char
);
381 gsize
g_strnlen (const char*, gsize
);
383 void g_strdelimit (char *string
, char delimiter
, char new_delimiter
);
384 gchar
*g_strescape (const gchar
*source
, const gchar
*exceptions
);
386 gchar
*g_filename_to_uri (const gchar
*filename
, const gchar
*hostname
, GError
**gerror
);
387 gchar
*g_filename_from_uri (const gchar
*uri
, gchar
**hostname
, GError
**gerror
);
389 gint
g_printf (gchar
const *format
, ...) G_ATTR_FORMAT_PRINTF(1, 2);
390 gint
g_fprintf (FILE *file
, gchar
const *format
, ...) G_ATTR_FORMAT_PRINTF(2, 3);
391 gint
g_sprintf (gchar
*string
, gchar
const *format
, ...) G_ATTR_FORMAT_PRINTF(2, 3);
392 gint
g_snprintf (gchar
*string
, gulong n
, gchar
const *format
, ...) G_ATTR_FORMAT_PRINTF(3, 4);
393 gint
g_vasprintf (gchar
**ret
, const gchar
*fmt
, va_list ap
);
394 #define g_vprintf vprintf
395 #define g_vfprintf vfprintf
396 #define g_vsprintf vsprintf
397 #define g_vsnprintf vsnprintf
399 gsize
g_strlcpy (gchar
*dest
, const gchar
*src
, gsize dest_size
);
400 gchar
*g_stpcpy (gchar
*dest
, const char *src
);
403 gchar
g_ascii_tolower (gchar c
);
404 gchar
g_ascii_toupper (gchar c
);
405 gchar
*g_ascii_strdown (const gchar
*str
, gssize len
);
406 void g_ascii_strdown_no_alloc (char* dst
, const char* src
, gsize len
);
407 gchar
*g_ascii_strup (const gchar
*str
, gssize len
);
408 gint
g_ascii_strncasecmp (const gchar
*s1
, const gchar
*s2
, gsize n
);
409 gint
g_ascii_strcasecmp (const gchar
*s1
, const gchar
*s2
);
410 gint
g_ascii_xdigit_value (gchar c
);
411 #define g_ascii_isspace(c) (isspace (c) != 0)
412 #define g_ascii_isalpha(c) (isalpha (c) != 0)
413 #define g_ascii_isprint(c) (isprint (c) != 0)
414 #define g_ascii_isxdigit(c) (isxdigit (c) != 0)
415 gboolean
g_utf16_ascii_equal (const gunichar2
*utf16
, size_t ulen
, const char *ascii
, size_t alen
);
416 gboolean
g_utf16_asciiz_equal (const gunichar2
*utf16
, const char *ascii
);
419 gboolean
g_ascii_equal (const char *s1
, gsize len1
, const char *s2
, gsize len2
)
421 return len1
== len2
&& (s1
== s2
|| memcmp (s1
, s2
, len1
) == 0);
425 gboolean
g_asciiz_equal (const char *s1
, const char *s2
)
427 return s1
== s2
|| strcmp (s1
, s2
) == 0;
432 g_ascii_equal_caseinsensitive (const char *s1
, gsize len1
, const char *s2
, gsize len2
)
434 return len1
== len2
&& (s1
== s2
|| g_ascii_strncasecmp (s1
, s2
, len1
) == 0);
439 g_asciiz_equal_caseinsensitive (const char *s1
, const char *s2
)
441 return s1
== s2
|| g_ascii_strcasecmp (s1
, s2
) == 0;
444 /* FIXME: g_strcasecmp supports utf8 unicode stuff */
446 #define g_strcasecmp _stricmp
447 #define g_strncasecmp _strnicmp
448 #define g_strstrip(a) g_strchug (g_strchomp (a))
450 #define g_strcasecmp strcasecmp
451 #define g_ascii_strtoull strtoull
452 #define g_strncasecmp strncasecmp
453 #define g_strstrip(a) g_strchug (g_strchomp (a))
455 #define g_ascii_strdup strdup
466 GString
*g_string_new (const gchar
*init
);
467 GString
*g_string_new_len (const gchar
*init
, gssize len
);
468 GString
*g_string_sized_new (gsize default_size
);
469 gchar
*g_string_free (GString
*string
, gboolean free_segment
);
470 GString
*g_string_append (GString
*string
, const gchar
*val
);
472 void g_string_printf (GString
*string
, const gchar
*format
, ...) G_ATTR_FORMAT_PRINTF(2, 3);
473 void g_string_append_printf (GString
*string
, const gchar
*format
, ...) G_ATTR_FORMAT_PRINTF(2, 3);
474 void g_string_append_vprintf (GString
*string
, const gchar
*format
, va_list args
);
475 GString
*g_string_append_unichar (GString
*string
, gunichar c
);
476 GString
*g_string_append_c (GString
*string
, gchar c
);
477 GString
*g_string_append (GString
*string
, const gchar
*val
);
478 GString
*g_string_append_len (GString
*string
, const gchar
*val
, gssize len
);
479 GString
*g_string_truncate (GString
*string
, gsize len
);
480 GString
*g_string_set_size (GString
*string
, gsize len
);
482 #define g_string_sprintfa g_string_append_printf
484 typedef void (*GFunc
) (gpointer data
, gpointer user_data
);
485 typedef gint (*GCompareFunc
) (gconstpointer a
, gconstpointer b
);
486 typedef gint (*GCompareDataFunc
) (gconstpointer a
, gconstpointer b
, gpointer user_data
);
487 typedef void (*GHFunc
) (gpointer key
, gpointer value
, gpointer user_data
);
488 typedef gboolean (*GHRFunc
) (gpointer key
, gpointer value
, gpointer user_data
);
489 typedef void (*GDestroyNotify
) (gpointer data
);
490 typedef guint (*GHashFunc
) (gconstpointer key
);
491 typedef gboolean (*GEqualFunc
) (gconstpointer a
, gconstpointer b
);
492 typedef void (*GFreeFunc
) (gpointer data
);
497 typedef struct _GSList GSList
;
503 GSList
*g_slist_alloc (void);
504 GSList
*g_slist_append (GSList
*list
,
506 GSList
*g_slist_prepend (GSList
*list
,
508 void g_slist_free (GSList
*list
);
509 void g_slist_free_1 (GSList
*list
);
510 GSList
*g_slist_copy (GSList
*list
);
511 GSList
*g_slist_concat (GSList
*list1
,
513 void g_slist_foreach (GSList
*list
,
516 GSList
*g_slist_last (GSList
*list
);
517 GSList
*g_slist_find (GSList
*list
,
519 GSList
*g_slist_find_custom (GSList
*list
,
522 GSList
*g_slist_remove (GSList
*list
,
524 GSList
*g_slist_remove_all (GSList
*list
,
526 GSList
*g_slist_reverse (GSList
*list
);
527 guint
g_slist_length (GSList
*list
);
528 GSList
*g_slist_remove_link (GSList
*list
,
530 GSList
*g_slist_delete_link (GSList
*list
,
532 GSList
*g_slist_insert_sorted (GSList
*list
,
535 GSList
*g_slist_insert_before (GSList
*list
,
538 GSList
*g_slist_sort (GSList
*list
,
540 gint
g_slist_index (GSList
*list
,
542 GSList
*g_slist_nth (GSList
*list
,
544 gpointer
g_slist_nth_data (GSList
*list
,
547 #define g_slist_next(slist) ((slist) ? (((GSList *) (slist))->next) : NULL)
550 typedef struct _GList GList
;
557 #define g_list_next(list) ((list) ? (((GList *) (list))->next) : NULL)
558 #define g_list_previous(list) ((list) ? (((GList *) (list))->prev) : NULL)
560 GList
*g_list_alloc (void);
561 GList
*g_list_append (GList
*list
,
563 GList
*g_list_prepend (GList
*list
,
565 void g_list_free (GList
*list
);
566 void g_list_free_1 (GList
*list
);
567 GList
*g_list_copy (GList
*list
);
568 guint
g_list_length (GList
*list
);
569 gint
g_list_index (GList
*list
,
571 GList
*g_list_nth (GList
*list
,
573 gpointer
g_list_nth_data (GList
*list
,
575 GList
*g_list_last (GList
*list
);
576 GList
*g_list_concat (GList
*list1
,
578 void g_list_foreach (GList
*list
,
581 GList
*g_list_first (GList
*list
);
582 GList
*g_list_find (GList
*list
,
584 GList
*g_list_find_custom (GList
*list
,
587 GList
*g_list_remove (GList
*list
,
589 GList
*g_list_remove_all (GList
*list
,
591 GList
*g_list_reverse (GList
*list
);
592 GList
*g_list_remove_link (GList
*list
,
594 GList
*g_list_delete_link (GList
*list
,
596 GList
*g_list_insert_sorted (GList
*list
,
599 GList
*g_list_insert_before (GList
*list
,
602 GList
*g_list_sort (GList
*sort
,
608 typedef struct _GHashTable GHashTable
;
609 typedef struct _GHashTableIter GHashTableIter
;
611 /* Private, but needed for stack allocation */
612 struct _GHashTableIter
617 G_EXTERN_C
// Used by MonoPosixHelper or MonoSupportW, at least.
618 GHashTable
*g_hash_table_new (GHashFunc hash_func
, GEqualFunc key_equal_func
);
619 GHashTable
*g_hash_table_new_full (GHashFunc hash_func
, GEqualFunc key_equal_func
,
620 GDestroyNotify key_destroy_func
, GDestroyNotify value_destroy_func
);
621 G_EXTERN_C
// Used by MonoPosixHelper or MonoSupportW, at least.
622 void g_hash_table_insert_replace (GHashTable
*hash
, gpointer key
, gpointer value
, gboolean replace
);
623 guint
g_hash_table_size (GHashTable
*hash
);
624 GList
*g_hash_table_get_keys (GHashTable
*hash
);
625 GList
*g_hash_table_get_values (GHashTable
*hash
);
626 G_EXTERN_C
// Used by MonoPosixHelper or MonoSupportW, at least.
627 gpointer
g_hash_table_lookup (GHashTable
*hash
, gconstpointer key
);
628 gboolean
g_hash_table_lookup_extended (GHashTable
*hash
, gconstpointer key
, gpointer
*orig_key
, gpointer
*value
);
629 G_EXTERN_C
// Used by MonoPosixHelper or MonoSupportW, at least.
630 void g_hash_table_foreach (GHashTable
*hash
, GHFunc func
, gpointer user_data
);
631 gpointer
g_hash_table_find (GHashTable
*hash
, GHRFunc predicate
, gpointer user_data
);
632 G_EXTERN_C
// Used by MonoPosixHelper or MonoSupportW, at least.
633 gboolean
g_hash_table_remove (GHashTable
*hash
, gconstpointer key
);
634 gboolean
g_hash_table_steal (GHashTable
*hash
, gconstpointer key
);
635 void g_hash_table_remove_all (GHashTable
*hash
);
636 guint
g_hash_table_foreach_remove (GHashTable
*hash
, GHRFunc func
, gpointer user_data
);
637 guint
g_hash_table_foreach_steal (GHashTable
*hash
, GHRFunc func
, gpointer user_data
);
638 G_EXTERN_C
// Used by MonoPosixHelper or MonoSupportW, at least.
639 void g_hash_table_destroy (GHashTable
*hash
);
640 void g_hash_table_print_stats (GHashTable
*table
);
642 void g_hash_table_iter_init (GHashTableIter
*iter
, GHashTable
*hash_table
);
643 gboolean
g_hash_table_iter_next (GHashTableIter
*iter
, gpointer
*key
, gpointer
*value
);
645 guint
g_spaced_primes_closest (guint x
);
647 #define g_hash_table_insert(h,k,v) g_hash_table_insert_replace ((h),(k),(v),FALSE)
648 #define g_hash_table_replace(h,k,v) g_hash_table_insert_replace ((h),(k),(v),TRUE)
650 G_EXTERN_C
// Used by MonoPosixHelper or MonoSupportW, at least.
651 gboolean
g_direct_equal (gconstpointer v1
, gconstpointer v2
);
652 G_EXTERN_C
// Used by MonoPosixHelper or MonoSupportW, at least.
653 guint
g_direct_hash (gconstpointer v1
);
654 gboolean
g_int_equal (gconstpointer v1
, gconstpointer v2
);
655 guint
g_int_hash (gconstpointer v1
);
656 gboolean
g_str_equal (gconstpointer v1
, gconstpointer v2
);
657 guint
g_str_hash (gconstpointer v1
);
663 typedef struct _GByteArray GByteArray
;
669 GByteArray
*g_byte_array_new (void);
670 GByteArray
* g_byte_array_append (GByteArray
*array
, const guint8
*data
, guint len
);
671 guint8
* g_byte_array_free (GByteArray
*array
, gboolean free_segment
);
672 void g_byte_array_set_size (GByteArray
*array
, gint length
);
678 typedef struct _GArray GArray
;
684 GArray
*g_array_new (gboolean zero_terminated
, gboolean clear_
, guint element_size
);
685 GArray
*g_array_sized_new (gboolean zero_terminated
, gboolean clear_
, guint element_size
, guint reserved_size
);
686 gchar
* g_array_free (GArray
*array
, gboolean free_segment
);
687 GArray
*g_array_append_vals (GArray
*array
, gconstpointer data
, guint len
);
688 GArray
* g_array_insert_vals (GArray
*array
, guint index_
, gconstpointer data
, guint len
);
689 GArray
* g_array_remove_index (GArray
*array
, guint index_
);
690 GArray
* g_array_remove_index_fast (GArray
*array
, guint index_
);
691 void g_array_set_size (GArray
*array
, gint length
);
693 #define g_array_append_val(a,v) (g_array_append_vals((a),&(v),1))
694 #define g_array_insert_val(a,i,v) (g_array_insert_vals((a),(i),&(v),1))
695 #define g_array_index(a,t,i) *(t*)(((a)->data) + sizeof(t) * (i))
696 //FIXME previous missing parens
702 void g_qsort_with_data (gpointer base
, size_t nmemb
, size_t size
, GCompareDataFunc compare
, gpointer user_data
);
708 typedef struct _GPtrArray GPtrArray
;
714 GPtrArray
*g_ptr_array_new (void);
715 GPtrArray
*g_ptr_array_sized_new (guint reserved_size
);
716 void g_ptr_array_add (GPtrArray
*array
, gpointer data
);
717 gboolean
g_ptr_array_remove (GPtrArray
*array
, gpointer data
);
718 gpointer
g_ptr_array_remove_index (GPtrArray
*array
, guint index
);
719 gboolean
g_ptr_array_remove_fast (GPtrArray
*array
, gpointer data
);
720 gpointer
g_ptr_array_remove_index_fast (GPtrArray
*array
, guint index
);
721 void g_ptr_array_sort (GPtrArray
*array
, GCompareFunc compare_func
);
722 void g_ptr_array_sort_with_data (GPtrArray
*array
, GCompareDataFunc compare_func
, gpointer user_data
);
723 void g_ptr_array_set_size (GPtrArray
*array
, gint length
);
724 gpointer
*g_ptr_array_free (GPtrArray
*array
, gboolean free_seg
);
725 void g_ptr_array_foreach (GPtrArray
*array
, GFunc func
, gpointer user_data
);
726 guint
g_ptr_array_capacity (GPtrArray
*array
);
727 #define g_ptr_array_index(array,index) (array)->pdata[(index)]
728 //FIXME previous missing parens
739 gpointer
g_queue_pop_head (GQueue
*queue
);
740 void g_queue_push_head (GQueue
*queue
,
742 void g_queue_push_tail (GQueue
*queue
,
744 gboolean
g_queue_is_empty (GQueue
*queue
);
745 GQueue
*g_queue_new (void);
746 void g_queue_free (GQueue
*queue
);
747 void g_queue_foreach (GQueue
*queue
, GFunc func
, gpointer user_data
);
753 #define G_LOG_DOMAIN ((gchar*) 0)
757 G_LOG_FLAG_RECURSION
= 1 << 0,
758 G_LOG_FLAG_FATAL
= 1 << 1,
760 G_LOG_LEVEL_ERROR
= 1 << 2,
761 G_LOG_LEVEL_CRITICAL
= 1 << 3,
762 G_LOG_LEVEL_WARNING
= 1 << 4,
763 G_LOG_LEVEL_MESSAGE
= 1 << 5,
764 G_LOG_LEVEL_INFO
= 1 << 6,
765 G_LOG_LEVEL_DEBUG
= 1 << 7,
767 G_LOG_LEVEL_MASK
= ~(G_LOG_FLAG_RECURSION
| G_LOG_FLAG_FATAL
)
770 G_ENUM_FUNCTIONS (GLogLevelFlags
)
772 void g_printv (const gchar
*format
, va_list args
);
773 void g_print (const gchar
*format
, ...);
774 void g_printerr (const gchar
*format
, ...);
775 GLogLevelFlags
g_log_set_always_fatal (GLogLevelFlags fatal_mask
);
776 GLogLevelFlags
g_log_set_fatal_mask (const gchar
*log_domain
, GLogLevelFlags fatal_mask
);
777 void g_logv (const gchar
*log_domain
, GLogLevelFlags log_level
, const gchar
*format
, va_list args
);
778 G_EXTERN_C
// Used by MonoPosixHelper or MonoSupportW, at least.
779 void g_log (const gchar
*log_domain
, GLogLevelFlags log_level
, const gchar
*format
, ...);
780 G_EXTERN_C
// Used by MonoPosixHelper or MonoSupportW, at least.
781 void g_assertion_message (const gchar
*format
, ...) G_GNUC_NORETURN
;
782 void mono_assertion_message_disabled (const char *file
, int line
) G_GNUC_NORETURN
;
783 void mono_assertion_message (const char *file
, int line
, const char *condition
) G_GNUC_NORETURN
;
784 void mono_assertion_message_unreachable (const char *file
, int line
) G_GNUC_NORETURN
;
785 const char * g_get_assertion_message (void);
787 #ifdef HAVE_C99_SUPPORT
788 /* The for (;;) tells gc thats g_error () doesn't return, avoiding warnings */
789 #define g_error(format, ...) do { g_log (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, format, __VA_ARGS__); for (;;); } while (0)
790 #define g_critical(format, ...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, format, __VA_ARGS__)
791 #define g_warning(format, ...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, format, __VA_ARGS__)
792 #define g_message(format, ...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, format, __VA_ARGS__)
793 #define g_debug(format, ...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format, __VA_ARGS__)
794 #else /* HAVE_C99_SUPPORT */
795 #define g_error(...) do { g_log (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, __VA_ARGS__); for (;;); } while (0)
796 #define g_critical(...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, __VA_ARGS__)
797 #define g_warning(...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, __VA_ARGS__)
798 #define g_message(...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, __VA_ARGS__)
799 #define g_debug(...) g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, __VA_ARGS__)
800 #endif /* ndef HAVE_C99_SUPPORT */
802 typedef void (*GLogFunc
) (const gchar
*log_domain
, GLogLevelFlags log_level
, const gchar
*message
, gpointer user_data
);
803 typedef void (*GPrintFunc
) (const gchar
*string
);
804 typedef void (*GAbortFunc
) (void);
806 void g_assertion_disable_global (GAbortFunc func
);
807 void g_assert_abort (void);
808 void g_log_default_handler (const gchar
*log_domain
, GLogLevelFlags log_level
, const gchar
*message
, gpointer unused_data
);
809 GLogFunc
g_log_set_default_handler (GLogFunc log_func
, gpointer user_data
);
810 GPrintFunc
g_set_print_handler (GPrintFunc func
);
811 GPrintFunc
g_set_printerr_handler (GPrintFunc func
);
816 gpointer
g_convert_error_quark(void);
820 * Unicode Manipulation: most of this is not used by Mono by default, it is
821 * only used if the old collation code is activated, so this is only the
822 * bare minimum to build.
828 G_UNICODE_UNASSIGNED
,
829 G_UNICODE_PRIVATE_USE
,
831 G_UNICODE_LOWERCASE_LETTER
,
832 G_UNICODE_MODIFIER_LETTER
,
833 G_UNICODE_OTHER_LETTER
,
834 G_UNICODE_TITLECASE_LETTER
,
835 G_UNICODE_UPPERCASE_LETTER
,
836 G_UNICODE_COMBINING_MARK
,
837 G_UNICODE_ENCLOSING_MARK
,
838 G_UNICODE_NON_SPACING_MARK
,
839 G_UNICODE_DECIMAL_NUMBER
,
840 G_UNICODE_LETTER_NUMBER
,
841 G_UNICODE_OTHER_NUMBER
,
842 G_UNICODE_CONNECT_PUNCTUATION
,
843 G_UNICODE_DASH_PUNCTUATION
,
844 G_UNICODE_CLOSE_PUNCTUATION
,
845 G_UNICODE_FINAL_PUNCTUATION
,
846 G_UNICODE_INITIAL_PUNCTUATION
,
847 G_UNICODE_OTHER_PUNCTUATION
,
848 G_UNICODE_OPEN_PUNCTUATION
,
849 G_UNICODE_CURRENCY_SYMBOL
,
850 G_UNICODE_MODIFIER_SYMBOL
,
851 G_UNICODE_MATH_SYMBOL
,
852 G_UNICODE_OTHER_SYMBOL
,
853 G_UNICODE_LINE_SEPARATOR
,
854 G_UNICODE_PARAGRAPH_SEPARATOR
,
855 G_UNICODE_SPACE_SEPARATOR
859 G_UNICODE_BREAK_MANDATORY
,
860 G_UNICODE_BREAK_CARRIAGE_RETURN
,
861 G_UNICODE_BREAK_LINE_FEED
,
862 G_UNICODE_BREAK_COMBINING_MARK
,
863 G_UNICODE_BREAK_SURROGATE
,
864 G_UNICODE_BREAK_ZERO_WIDTH_SPACE
,
865 G_UNICODE_BREAK_INSEPARABLE
,
866 G_UNICODE_BREAK_NON_BREAKING_GLUE
,
867 G_UNICODE_BREAK_CONTINGENT
,
868 G_UNICODE_BREAK_SPACE
,
869 G_UNICODE_BREAK_AFTER
,
870 G_UNICODE_BREAK_BEFORE
,
871 G_UNICODE_BREAK_BEFORE_AND_AFTER
,
872 G_UNICODE_BREAK_HYPHEN
,
873 G_UNICODE_BREAK_NON_STARTER
,
874 G_UNICODE_BREAK_OPEN_PUNCTUATION
,
875 G_UNICODE_BREAK_CLOSE_PUNCTUATION
,
876 G_UNICODE_BREAK_QUOTATION
,
877 G_UNICODE_BREAK_EXCLAMATION
,
878 G_UNICODE_BREAK_IDEOGRAPHIC
,
879 G_UNICODE_BREAK_NUMERIC
,
880 G_UNICODE_BREAK_INFIX_SEPARATOR
,
881 G_UNICODE_BREAK_SYMBOL
,
882 G_UNICODE_BREAK_ALPHABETIC
,
883 G_UNICODE_BREAK_PREFIX
,
884 G_UNICODE_BREAK_POSTFIX
,
885 G_UNICODE_BREAK_COMPLEX_CONTEXT
,
886 G_UNICODE_BREAK_AMBIGUOUS
,
887 G_UNICODE_BREAK_UNKNOWN
,
888 G_UNICODE_BREAK_NEXT_LINE
,
889 G_UNICODE_BREAK_WORD_JOINER
,
890 G_UNICODE_BREAK_HANGUL_L_JAMO
,
891 G_UNICODE_BREAK_HANGUL_V_JAMO
,
892 G_UNICODE_BREAK_HANGUL_T_JAMO
,
893 G_UNICODE_BREAK_HANGUL_LV_SYLLABLE
,
894 G_UNICODE_BREAK_HANGUL_LVT_SYLLABLE
897 gunichar
g_unichar_toupper (gunichar c
);
898 gunichar
g_unichar_tolower (gunichar c
);
899 gunichar
g_unichar_totitle (gunichar c
);
900 GUnicodeType
g_unichar_type (gunichar c
);
901 gboolean
g_unichar_isspace (gunichar c
);
902 gboolean
g_unichar_isxdigit (gunichar c
);
903 gint
g_unichar_xdigit_value (gunichar c
);
904 GUnicodeBreakType
g_unichar_break_type (gunichar c
);
907 #define MAX(a,b) (((a)>(b)) ? (a) : (b))
911 #define MIN(a,b) (((a)<(b)) ? (a) : (b))
915 #define CLAMP(a,low,high) (((a) < (low)) ? (low) : (((a) > (high)) ? (high) : (a)))
918 #if defined(__GNUC__) && (__GNUC__ > 2)
919 #define G_LIKELY(expr) (__builtin_expect ((expr) != 0, 1))
920 #define G_UNLIKELY(expr) (__builtin_expect ((expr) != 0, 0))
922 #define G_LIKELY(x) (x)
923 #define G_UNLIKELY(x) (x)
926 #if defined(_MSC_VER)
927 #define eg_unreachable() __assume(0)
928 #elif defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && (__GNUC_MINOR__ >= 5)))
929 #define eg_unreachable() __builtin_unreachable()
931 #define eg_unreachable()
934 /* g_assert is a boolean expression; the precise value is not preserved, just true or false. */
935 #ifdef DISABLE_ASSERT_MESSAGES
936 // This is smaller than the equivalent mono_assertion_message (..."disabled");
937 #define g_assert(x) (G_LIKELY((x)) ? 1 : (mono_assertion_message_disabled (__FILE__, __LINE__), 0))
939 #define g_assert(x) (G_LIKELY((x)) ? 1 : (mono_assertion_message (__FILE__, __LINE__, #x), 0))
943 #define g_static_assert(x) static_assert (x, "")
945 #define g_static_assert(x) g_assert (x)
948 #define g_assert_not_reached() G_STMT_START { mono_assertion_message_unreachable (__FILE__, __LINE__); eg_unreachable(); } G_STMT_END
950 /* f is format -- like printf and scanf
951 * Where you might have said:
953 * g_error("%s invalid bar:%d", __func__, bar)
956 * g_assertf(expr, "bar:%d", bar);
958 * The usual assertion text of file/line/expr/newline are builtin, and __func__.
960 * g_assertf is a boolean expression -- the precise value is not preserved, just true or false.
962 * Other than expr, the parameters are not evaluated unless expr is false.
964 * format must be a string literal, in order to be concatenated.
965 * If this is too restrictive, g_error remains.
967 #if defined(_MSC_VER) && (_MSC_VER < 1910)
968 #define g_assertf(x, format, ...) (G_LIKELY((x)) ? 1 : (g_assertion_message ("* Assertion at %s:%d, condition `%s' not met, function:%s, " format "\n", __FILE__, __LINE__, #x, __func__, __VA_ARGS__), 0))
970 #define g_assertf(x, format, ...) (G_LIKELY((x)) ? 1 : (g_assertion_message ("* Assertion at %s:%d, condition `%s' not met, function:%s, " format "\n", __FILE__, __LINE__, #x, __func__, ##__VA_ARGS__), 0))
977 #define G_CONVERT_ERROR g_convert_error_quark()
980 G_CONVERT_ERROR_NO_CONVERSION
,
981 G_CONVERT_ERROR_ILLEGAL_SEQUENCE
,
982 G_CONVERT_ERROR_FAILED
,
983 G_CONVERT_ERROR_PARTIAL_INPUT
,
984 G_CONVERT_ERROR_BAD_URI
,
985 G_CONVERT_ERROR_NOT_ABSOLUTE_PATH
988 gchar
*g_utf8_strup (const gchar
*str
, gssize len
);
989 gchar
*g_utf8_strdown (const gchar
*str
, gssize len
);
990 gint
g_unichar_to_utf8 (gunichar c
, gchar
*outbuf
);
991 gunichar
*g_utf8_to_ucs4_fast (const gchar
*str
, glong len
, glong
*items_written
);
992 gunichar
*g_utf8_to_ucs4 (const gchar
*str
, glong len
, glong
*items_read
, glong
*items_written
, GError
**err
);
993 G_EXTERN_C
// Used by libtest, at least.
994 gunichar2
*g_utf8_to_utf16 (const gchar
*str
, glong len
, glong
*items_read
, glong
*items_written
, GError
**err
);
995 gunichar2
*eg_utf8_to_utf16_with_nuls (const gchar
*str
, glong len
, glong
*items_read
, glong
*items_written
, GError
**err
);
996 gunichar2
*eg_wtf8_to_utf16 (const gchar
*str
, glong len
, glong
*items_read
, glong
*items_written
, GError
**err
);
997 G_EXTERN_C
// Used by libtest, at least.
998 gchar
*g_utf16_to_utf8 (const gunichar2
*str
, glong len
, glong
*items_read
, glong
*items_written
, GError
**err
);
999 gunichar
*g_utf16_to_ucs4 (const gunichar2
*str
, glong len
, glong
*items_read
, glong
*items_written
, GError
**err
);
1000 gchar
*g_ucs4_to_utf8 (const gunichar
*str
, glong len
, glong
*items_read
, glong
*items_written
, GError
**err
);
1001 gunichar2
*g_ucs4_to_utf16 (const gunichar
*str
, glong len
, glong
*items_read
, glong
*items_written
, GError
**err
);
1002 size_t g_utf16_len (const gunichar2
*);
1004 #define u8to16(str) g_utf8_to_utf16(str, (glong)strlen(str), NULL, NULL, NULL)
1007 #define u16to8(str) g_utf16_to_utf8((gunichar2 *) (str), (glong)wcslen((wchar_t *) (str)), NULL, NULL, NULL)
1009 #define u16to8(str) g_utf16_to_utf8(str, (glong)strlen(str), NULL, NULL, NULL)
1015 gchar
*g_build_path (const gchar
*separator
, const gchar
*first_element
, ...);
1016 #define g_build_filename(x, ...) g_build_path(G_DIR_SEPARATOR_S, x, __VA_ARGS__)
1017 gchar
*g_path_get_dirname (const gchar
*filename
);
1018 gchar
*g_path_get_basename (const char *filename
);
1019 gchar
*g_find_program_in_path (const gchar
*program
);
1020 gchar
*g_get_current_dir (void);
1021 gboolean
g_path_is_absolute (const char *filename
);
1023 const gchar
*g_get_home_dir (void);
1024 const gchar
*g_get_tmp_dir (void);
1025 const gchar
*g_get_user_name (void);
1026 gchar
*g_get_prgname (void);
1027 void g_set_prgname (const gchar
*prgname
);
1029 gboolean
g_ensure_directory_exists (const gchar
*filename
);
1035 gboolean
g_shell_parse_argv (const gchar
*command_line
, gint
*argcp
, gchar
***argvp
, GError
**gerror
);
1036 gchar
*g_shell_unquote (const gchar
*quoted_string
, GError
**gerror
);
1037 gchar
*g_shell_quote (const gchar
*unquoted_string
);
1043 G_SPAWN_LEAVE_DESCRIPTORS_OPEN
= 1,
1044 G_SPAWN_DO_NOT_REAP_CHILD
= 1 << 1,
1045 G_SPAWN_SEARCH_PATH
= 1 << 2,
1046 G_SPAWN_STDOUT_TO_DEV_NULL
= 1 << 3,
1047 G_SPAWN_STDERR_TO_DEV_NULL
= 1 << 4,
1048 G_SPAWN_CHILD_INHERITS_STDIN
= 1 << 5,
1049 G_SPAWN_FILE_AND_ARGV_ZERO
= 1 << 6
1052 typedef void (*GSpawnChildSetupFunc
) (gpointer user_data
);
1054 gboolean
g_spawn_command_line_sync (const gchar
*command_line
, gchar
**standard_output
, gchar
**standard_error
, gint
*exit_status
, GError
**gerror
);
1055 gboolean
g_spawn_async_with_pipes (const gchar
*working_directory
, gchar
**argv
, gchar
**envp
, GSpawnFlags flags
, GSpawnChildSetupFunc child_setup
,
1056 gpointer user_data
, GPid
*child_pid
, gint
*standard_input
, gint
*standard_output
, gint
*standard_error
, GError
**gerror
);
1058 int eg_getdtablesize (void);
1063 typedef struct _GTimer GTimer
;
1065 GTimer
*g_timer_new (void);
1066 void g_timer_destroy (GTimer
*timer
);
1067 gdouble
g_timer_elapsed (GTimer
*timer
, gulong
*microseconds
);
1068 void g_timer_stop (GTimer
*timer
);
1069 void g_timer_start (GTimer
*timer
);
1079 void g_get_current_time (GTimeVal
*result
);
1080 void g_usleep (gulong microseconds
);
1086 gpointer
g_file_error_quark (void);
1088 #define G_FILE_ERROR g_file_error_quark ()
1094 G_FILE_ERROR_NAMETOOLONG
,
1096 G_FILE_ERROR_NOTDIR
,
1100 G_FILE_ERROR_TXTBSY
,
1119 G_FILE_TEST_IS_REGULAR
= 1 << 0,
1120 G_FILE_TEST_IS_SYMLINK
= 1 << 1,
1121 G_FILE_TEST_IS_DIR
= 1 << 2,
1122 G_FILE_TEST_IS_EXECUTABLE
= 1 << 3,
1123 G_FILE_TEST_EXISTS
= 1 << 4
1126 G_ENUM_FUNCTIONS (GFileTest
)
1128 gboolean
g_file_set_contents (const gchar
*filename
, const gchar
*contents
, gssize length
, GError
**gerror
);
1129 gboolean
g_file_get_contents (const gchar
*filename
, gchar
**contents
, gsize
*length
, GError
**gerror
);
1130 GFileError
g_file_error_from_errno (gint err_no
);
1131 gint
g_file_open_tmp (const gchar
*tmpl
, gchar
**name_used
, GError
**gerror
);
1132 gboolean
g_file_test (const gchar
*filename
, GFileTest test
);
1135 #define g_open _open
1139 #define g_rename rename
1142 #define g_access _access
1144 #define g_access access
1147 #define g_mktemp _mktemp
1149 #define g_mktemp mktemp
1152 #define g_unlink _unlink
1154 #define g_unlink unlink
1157 #define g_write _write
1159 #define g_write write
1162 #define g_read _read
1167 #define g_fopen fopen
1168 #define g_lstat lstat
1169 #define g_rmdir rmdir
1170 #define g_mkstemp mkstemp
1171 #define g_ascii_isdigit isdigit
1172 #define g_ascii_strtod strtod
1173 #define g_ascii_isalnum isalnum
1175 gchar
*g_mkdtemp (gchar
*tmpl
);
1178 * Low-level write-based printing functions
1182 g_async_safe_fgets (char *str
, int num
, int handle
, gboolean
*newline
)
1184 memset (str
, 0, num
);
1185 // Make sure we don't overwrite the last index so that we are
1186 // guaranteed to be NULL-terminated
1187 int without_padding
= num
- 1;
1189 while (i
< without_padding
&& g_read (handle
, &str
[i
], sizeof(char))) {
1190 if (str
[i
] == '\n') {
1195 if (!isprint (str
[i
]))
1198 if (str
[i
] == '\0')
1208 g_async_safe_vfprintf (int handle
, gchar
const *format
, va_list args
)
1210 char print_buff
[1024];
1211 print_buff
[0] = '\0';
1212 g_vsnprintf (print_buff
, sizeof(print_buff
), format
, args
);
1213 int ret
= g_write (handle
, print_buff
, (guint32
) strlen (print_buff
));
1219 g_async_safe_fprintf (int handle
, gchar
const *format
, ...)
1222 va_start (args
, format
);
1223 int ret
= g_async_safe_vfprintf (handle
, format
, args
);
1229 g_async_safe_vprintf (gchar
const *format
, va_list args
)
1231 return g_async_safe_vfprintf (1, format
, args
);
1235 g_async_safe_printf (gchar
const *format
, ...)
1238 va_start (args
, format
);
1239 int ret
= g_async_safe_vfprintf (1, format
, args
);
1249 typedef struct _GPatternSpec GPatternSpec
;
1250 GPatternSpec
* g_pattern_spec_new (const gchar
*pattern
);
1251 void g_pattern_spec_free (GPatternSpec
*pspec
);
1252 gboolean
g_pattern_match_string (GPatternSpec
*pspec
, const gchar
*string
);
1257 typedef struct _GDir GDir
;
1258 GDir
*g_dir_open (const gchar
*path
, guint flags
, GError
**gerror
);
1259 const gchar
*g_dir_read_name (GDir
*dir
);
1260 void g_dir_rewind (GDir
*dir
);
1261 void g_dir_close (GDir
*dir
);
1263 int g_mkdir_with_parents (const gchar
*pathname
, int mode
);
1264 #define g_mkdir mkdir
1269 typedef struct _GMarkupParseContext GMarkupParseContext
;
1273 G_MARKUP_DO_NOT_USE_THIS_UNSUPPORTED_FLAG
= 1 << 0,
1274 G_MARKUP_TREAT_CDATA_AS_TEXT
= 1 << 1
1275 } GMarkupParseFlags
;
1278 void (*start_element
) (GMarkupParseContext
*context
,
1279 const gchar
*element_name
,
1280 const gchar
**attribute_names
,
1281 const gchar
**attribute_values
,
1285 void (*end_element
) (GMarkupParseContext
*context
,
1286 const gchar
*element_name
,
1290 void (*text
) (GMarkupParseContext
*context
,
1296 void (*passthrough
) (GMarkupParseContext
*context
,
1297 const gchar
*passthrough_text
,
1301 void (*error
) (GMarkupParseContext
*context
,
1303 gpointer user_data
);
1306 GMarkupParseContext
*g_markup_parse_context_new (const GMarkupParser
*parser
,
1307 GMarkupParseFlags flags
,
1309 GDestroyNotify user_data_dnotify
);
1310 void g_markup_parse_context_free (GMarkupParseContext
*context
);
1311 gboolean
g_markup_parse_context_parse (GMarkupParseContext
*context
,
1312 const gchar
*text
, gssize text_len
,
1314 gboolean
g_markup_parse_context_end_parse (GMarkupParseContext
*context
,
1318 * Character set conversion
1320 typedef struct _GIConv
*GIConv
;
1322 gsize
g_iconv (GIConv cd
, gchar
**inbytes
, gsize
*inbytesleft
, gchar
**outbytes
, gsize
*outbytesleft
);
1323 GIConv
g_iconv_open (const gchar
*to_charset
, const gchar
*from_charset
);
1324 int g_iconv_close (GIConv cd
);
1326 gboolean
g_get_charset (G_CONST_RETURN
char **charset
);
1327 gchar
*g_locale_to_utf8 (const gchar
*opsysstring
, gssize len
,
1328 gsize
*bytes_read
, gsize
*bytes_written
,
1330 gchar
*g_locale_from_utf8 (const gchar
*utf8string
, gssize len
, gsize
*bytes_read
,
1331 gsize
*bytes_written
, GError
**gerror
);
1332 gchar
*g_filename_from_utf8 (const gchar
*utf8string
, gssize len
, gsize
*bytes_read
,
1333 gsize
*bytes_written
, GError
**gerror
);
1334 gchar
*g_convert (const gchar
*str
, gssize len
,
1335 const gchar
*to_codeset
, const gchar
*from_codeset
,
1336 gsize
*bytes_read
, gsize
*bytes_written
, GError
**gerror
);
1339 * Unicode manipulation
1341 extern const guchar g_utf8_jump_table
[256];
1343 gboolean
g_utf8_validate (const gchar
*str
, gssize max_len
, const gchar
**end
);
1344 gunichar
g_utf8_get_char_validated (const gchar
*str
, gssize max_len
);
1345 #define g_utf8_next_char(p) ((p) + g_utf8_jump_table[(guchar)(*p)])
1346 gunichar
g_utf8_get_char (const gchar
*src
);
1347 glong
g_utf8_strlen (const gchar
*str
, gssize max
);
1348 gchar
*g_utf8_offset_to_pointer (const gchar
*str
, glong offset
);
1349 glong
g_utf8_pointer_to_offset (const gchar
*str
, const gchar
*pos
);
1354 #define G_PRIORITY_DEFAULT 0
1355 #define G_PRIORITY_DEFAULT_IDLE 200
1357 #define GUINT16_SWAP_LE_BE_CONSTANT(x) ((((guint16) x) >> 8) | ((((guint16) x) << 8)))
1359 #define GUINT16_SWAP_LE_BE(x) ((guint16) (((guint16) x) >> 8) | ((((guint16)(x)) & 0xff) << 8))
1360 #define GUINT32_SWAP_LE_BE(x) ((guint32) \
1361 ( (((guint32) (x)) << 24)| \
1362 ((((guint32) (x)) & 0xff0000) >> 8) | \
1363 ((((guint32) (x)) & 0xff00) << 8) | \
1364 (((guint32) (x)) >> 24)) )
1366 #define GUINT64_SWAP_LE_BE(x) ((guint64) (((guint64)(GUINT32_SWAP_LE_BE(((guint64)x) & 0xffffffff))) << 32) | \
1367 GUINT32_SWAP_LE_BE(((guint64)x) >> 32))
1371 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
1372 # define GUINT64_FROM_BE(x) GUINT64_SWAP_LE_BE(x)
1373 # define GUINT32_FROM_BE(x) GUINT32_SWAP_LE_BE(x)
1374 # define GUINT16_FROM_BE(x) GUINT16_SWAP_LE_BE(x)
1375 # define GUINT_FROM_BE(x) GUINT32_SWAP_LE_BE(x)
1376 # define GUINT64_FROM_LE(x) (x)
1377 # define GUINT32_FROM_LE(x) (x)
1378 # define GUINT16_FROM_LE(x) (x)
1379 # define GUINT_FROM_LE(x) (x)
1380 # define GUINT64_TO_BE(x) GUINT64_SWAP_LE_BE(x)
1381 # define GUINT32_TO_BE(x) GUINT32_SWAP_LE_BE(x)
1382 # define GUINT16_TO_BE(x) GUINT16_SWAP_LE_BE(x)
1383 # define GUINT_TO_BE(x) GUINT32_SWAP_LE_BE(x)
1384 # define GUINT64_TO_LE(x) (x)
1385 # define GUINT32_TO_LE(x) (x)
1386 # define GUINT16_TO_LE(x) (x)
1387 # define GUINT_TO_LE(x) (x)
1389 # define GUINT64_FROM_BE(x) (x)
1390 # define GUINT32_FROM_BE(x) (x)
1391 # define GUINT16_FROM_BE(x) (x)
1392 # define GUINT_FROM_BE(x) (x)
1393 # define GUINT64_FROM_LE(x) GUINT64_SWAP_LE_BE(x)
1394 # define GUINT32_FROM_LE(x) GUINT32_SWAP_LE_BE(x)
1395 # define GUINT16_FROM_LE(x) GUINT16_SWAP_LE_BE(x)
1396 # define GUINT_FROM_LE(x) GUINT32_SWAP_LE_BE(x)
1397 # define GUINT64_TO_BE(x) (x)
1398 # define GUINT32_TO_BE(x) (x)
1399 # define GUINT16_TO_BE(x) (x)
1400 # define GUINT_TO_BE(x) (x)
1401 # define GUINT64_TO_LE(x) GUINT64_SWAP_LE_BE(x)
1402 # define GUINT32_TO_LE(x) GUINT32_SWAP_LE_BE(x)
1403 # define GUINT16_TO_LE(x) GUINT16_SWAP_LE_BE(x)
1404 # define GUINT_TO_LE(x) GUINT32_SWAP_LE_BE(x)
1407 #define GINT64_FROM_BE(x) (GUINT64_TO_BE (x))
1408 #define GINT32_FROM_BE(x) (GUINT32_TO_BE (x))
1409 #define GINT16_FROM_BE(x) (GUINT16_TO_BE (x))
1410 #define GINT64_FROM_LE(x) (GUINT64_TO_LE (x))
1411 #define GINT32_FROM_LE(x) (GUINT32_TO_LE (x))
1412 #define GINT16_FROM_LE(x) (GUINT16_TO_LE (x))
1414 #define _EGLIB_MAJOR 2
1415 #define _EGLIB_MIDDLE 4
1416 #define _EGLIB_MINOR 0
1418 #define GLIB_CHECK_VERSION(a,b,c) ((a < _EGLIB_MAJOR) || (a == _EGLIB_MAJOR && (b < _EGLIB_MIDDLE || (b == _EGLIB_MIDDLE && c <= _EGLIB_MINOR))))
1420 #define G_HAVE_API_SUPPORT(x) (x)
1421 #define G_UNSUPPORTED_API "%s:%d: '%s' not supported.", __FILE__, __LINE__
1422 #define g_unsupported_api(name) G_STMT_START { g_warning (G_UNSUPPORTED_API, name); } G_STMT_END
1425 // g_free the result
1426 // No MAX_PATH limit.
1428 mono_get_module_filename (gpointer mod
, gunichar2
**pstr
, guint32
*plength
);
1430 // g_free the result
1431 // No MAX_PATH limit.
1433 mono_get_module_filename_ex (gpointer process
, gpointer mod
, gunichar2
**pstr
, guint32
*plength
);
1435 // g_free the result
1436 // No MAX_PATH limit.
1438 mono_get_module_basename (gpointer process
, gpointer mod
, gunichar2
**pstr
, guint32
*plength
);
1440 // g_free the result
1441 // No MAX_PATH limit.
1443 mono_get_current_directory (gunichar2
**pstr
, guint32
*plength
);
1446 G_END_DECLS
// FIXME: There is more extern C than there should be.
1450 mono_qsort (void* base
, size_t num
, size_t size
, int (*compare
)(const void*, const void*))
1454 if (num
< 2 || !size
|| !base
)
1456 qsort (base
, num
, size
, compare
);
1459 #define MONO_DECL_CALLBACK(prefix, ret, name, sig) ret (*name) sig;
1460 #define MONO_INIT_CALLBACK(prefix, ret, name, sig) prefix ## _ ## name,
1462 // For each allocator; i.e. returning gpointer that needs to be cast.
1463 // Macros do not recurse, so naming function and macro the same is ok.
1464 // However these are also already macros.
1470 #undef g_try_realloc
1472 #define g_malloc(x) (g_cast (monoeg_malloc (x)))
1473 #define g_realloc(obj, size) (g_cast (monoeg_realloc ((obj), (size))))
1474 #define g_malloc0(x) (g_cast (monoeg_malloc0 (x)))
1475 #define g_calloc(x, y) (g_cast (monoeg_g_calloc ((x), (y))))
1476 #define g_try_malloc(x) (g_cast (monoeg_try_malloc (x)))
1477 #define g_try_realloc(obj, size) (g_cast (monoeg_try_realloc ((obj), (size))))
1478 #define g_memdup(mem, size) (g_cast (monoeg_g_memdup ((mem), (size))))