+Wed Dec 16 03:16:58 1998 Tim Janik <timj@gtk.org>
+
+ * configure.in: version bump to 1.1.8, binary age 0, interface age 0.
+
+ * glib.h: changed g_lock() to G_LOCK(), g_unlock() to G_UNLOCK() and
+ g_trylock() to G_TRYLOCK(), since these are macros that expand to
+ nothing with --disable-threads.
+ changed G_LOCK_DEFINE() to G_LOCK_DECLARE() and introduced
+ G_LOCK_DECLARE_STATIC() to achive the results of static G_LOCK_DECLARE().
+ changed semantics of g_thread_supported to g_thread_supported() so it
+ can be used as a function like g_module_supported(). the actuall
+ definition is still a macro that expands into a variable for
+ performance reasons though.
+ various indentation and coding style cleanups.
+
+ * configure.in: added --enable-threads that defaults to yes.
+
+ * gmutex.c: changed tests g_thread_supported to g_thread_supported (),
+ changed variable settings of g_thread_supported
+ to g_threads_got_initialized.
+
+ garray.c:
+ gcache.c:
+ gdataset.c:
+ gdate.c:
+ ghash.c:
+ glist.c:
+ gmain.c:
+ gnode.c:
+ gslist.c:
+ gstring.c:
+ gtree.c:
+ gutils.c:
+ changed s/g_lock/G_LOCK/, s/g_unlock/G_UNLOCK/,
+ s/static G_LOCK_DEFINE/G_LOCK_DECLARE_STATIC/.
+
Tue Dec 15 23:16:05 CST 1998 Shawn T. Amundson <amundson@gtk.org>
* Released GLib 1.1.8
+Wed Dec 16 03:16:58 1998 Tim Janik <timj@gtk.org>
+
+ * configure.in: version bump to 1.1.8, binary age 0, interface age 0.
+
+ * glib.h: changed g_lock() to G_LOCK(), g_unlock() to G_UNLOCK() and
+ g_trylock() to G_TRYLOCK(), since these are macros that expand to
+ nothing with --disable-threads.
+ changed G_LOCK_DEFINE() to G_LOCK_DECLARE() and introduced
+ G_LOCK_DECLARE_STATIC() to achive the results of static G_LOCK_DECLARE().
+ changed semantics of g_thread_supported to g_thread_supported() so it
+ can be used as a function like g_module_supported(). the actuall
+ definition is still a macro that expands into a variable for
+ performance reasons though.
+ various indentation and coding style cleanups.
+
+ * configure.in: added --enable-threads that defaults to yes.
+
+ * gmutex.c: changed tests g_thread_supported to g_thread_supported (),
+ changed variable settings of g_thread_supported
+ to g_threads_got_initialized.
+
+ garray.c:
+ gcache.c:
+ gdataset.c:
+ gdate.c:
+ ghash.c:
+ glist.c:
+ gmain.c:
+ gnode.c:
+ gslist.c:
+ gstring.c:
+ gtree.c:
+ gutils.c:
+ changed s/g_lock/G_LOCK/, s/g_unlock/G_UNLOCK/,
+ s/static G_LOCK_DEFINE/G_LOCK_DECLARE_STATIC/.
+
Tue Dec 15 23:16:05 CST 1998 Shawn T. Amundson <amundson@gtk.org>
* Released GLib 1.1.8
+Wed Dec 16 03:16:58 1998 Tim Janik <timj@gtk.org>
+
+ * configure.in: version bump to 1.1.8, binary age 0, interface age 0.
+
+ * glib.h: changed g_lock() to G_LOCK(), g_unlock() to G_UNLOCK() and
+ g_trylock() to G_TRYLOCK(), since these are macros that expand to
+ nothing with --disable-threads.
+ changed G_LOCK_DEFINE() to G_LOCK_DECLARE() and introduced
+ G_LOCK_DECLARE_STATIC() to achive the results of static G_LOCK_DECLARE().
+ changed semantics of g_thread_supported to g_thread_supported() so it
+ can be used as a function like g_module_supported(). the actuall
+ definition is still a macro that expands into a variable for
+ performance reasons though.
+ various indentation and coding style cleanups.
+
+ * configure.in: added --enable-threads that defaults to yes.
+
+ * gmutex.c: changed tests g_thread_supported to g_thread_supported (),
+ changed variable settings of g_thread_supported
+ to g_threads_got_initialized.
+
+ garray.c:
+ gcache.c:
+ gdataset.c:
+ gdate.c:
+ ghash.c:
+ glist.c:
+ gmain.c:
+ gnode.c:
+ gslist.c:
+ gstring.c:
+ gtree.c:
+ gutils.c:
+ changed s/g_lock/G_LOCK/, s/g_unlock/G_UNLOCK/,
+ s/static G_LOCK_DEFINE/G_LOCK_DECLARE_STATIC/.
+
Tue Dec 15 23:16:05 CST 1998 Shawn T. Amundson <amundson@gtk.org>
* Released GLib 1.1.8
+Wed Dec 16 03:16:58 1998 Tim Janik <timj@gtk.org>
+
+ * configure.in: version bump to 1.1.8, binary age 0, interface age 0.
+
+ * glib.h: changed g_lock() to G_LOCK(), g_unlock() to G_UNLOCK() and
+ g_trylock() to G_TRYLOCK(), since these are macros that expand to
+ nothing with --disable-threads.
+ changed G_LOCK_DEFINE() to G_LOCK_DECLARE() and introduced
+ G_LOCK_DECLARE_STATIC() to achive the results of static G_LOCK_DECLARE().
+ changed semantics of g_thread_supported to g_thread_supported() so it
+ can be used as a function like g_module_supported(). the actuall
+ definition is still a macro that expands into a variable for
+ performance reasons though.
+ various indentation and coding style cleanups.
+
+ * configure.in: added --enable-threads that defaults to yes.
+
+ * gmutex.c: changed tests g_thread_supported to g_thread_supported (),
+ changed variable settings of g_thread_supported
+ to g_threads_got_initialized.
+
+ garray.c:
+ gcache.c:
+ gdataset.c:
+ gdate.c:
+ ghash.c:
+ glist.c:
+ gmain.c:
+ gnode.c:
+ gslist.c:
+ gstring.c:
+ gtree.c:
+ gutils.c:
+ changed s/g_lock/G_LOCK/, s/g_unlock/G_UNLOCK/,
+ s/static G_LOCK_DEFINE/G_LOCK_DECLARE_STATIC/.
+
Tue Dec 15 23:16:05 CST 1998 Shawn T. Amundson <amundson@gtk.org>
* Released GLib 1.1.8
+Wed Dec 16 03:16:58 1998 Tim Janik <timj@gtk.org>
+
+ * configure.in: version bump to 1.1.8, binary age 0, interface age 0.
+
+ * glib.h: changed g_lock() to G_LOCK(), g_unlock() to G_UNLOCK() and
+ g_trylock() to G_TRYLOCK(), since these are macros that expand to
+ nothing with --disable-threads.
+ changed G_LOCK_DEFINE() to G_LOCK_DECLARE() and introduced
+ G_LOCK_DECLARE_STATIC() to achive the results of static G_LOCK_DECLARE().
+ changed semantics of g_thread_supported to g_thread_supported() so it
+ can be used as a function like g_module_supported(). the actuall
+ definition is still a macro that expands into a variable for
+ performance reasons though.
+ various indentation and coding style cleanups.
+
+ * configure.in: added --enable-threads that defaults to yes.
+
+ * gmutex.c: changed tests g_thread_supported to g_thread_supported (),
+ changed variable settings of g_thread_supported
+ to g_threads_got_initialized.
+
+ garray.c:
+ gcache.c:
+ gdataset.c:
+ gdate.c:
+ ghash.c:
+ glist.c:
+ gmain.c:
+ gnode.c:
+ gslist.c:
+ gstring.c:
+ gtree.c:
+ gutils.c:
+ changed s/g_lock/G_LOCK/, s/g_unlock/G_UNLOCK/,
+ s/static G_LOCK_DEFINE/G_LOCK_DECLARE_STATIC/.
+
Tue Dec 15 23:16:05 CST 1998 Shawn T. Amundson <amundson@gtk.org>
* Released GLib 1.1.8
+Wed Dec 16 03:16:58 1998 Tim Janik <timj@gtk.org>
+
+ * configure.in: version bump to 1.1.8, binary age 0, interface age 0.
+
+ * glib.h: changed g_lock() to G_LOCK(), g_unlock() to G_UNLOCK() and
+ g_trylock() to G_TRYLOCK(), since these are macros that expand to
+ nothing with --disable-threads.
+ changed G_LOCK_DEFINE() to G_LOCK_DECLARE() and introduced
+ G_LOCK_DECLARE_STATIC() to achive the results of static G_LOCK_DECLARE().
+ changed semantics of g_thread_supported to g_thread_supported() so it
+ can be used as a function like g_module_supported(). the actuall
+ definition is still a macro that expands into a variable for
+ performance reasons though.
+ various indentation and coding style cleanups.
+
+ * configure.in: added --enable-threads that defaults to yes.
+
+ * gmutex.c: changed tests g_thread_supported to g_thread_supported (),
+ changed variable settings of g_thread_supported
+ to g_threads_got_initialized.
+
+ garray.c:
+ gcache.c:
+ gdataset.c:
+ gdate.c:
+ ghash.c:
+ glist.c:
+ gmain.c:
+ gnode.c:
+ gslist.c:
+ gstring.c:
+ gtree.c:
+ gutils.c:
+ changed s/g_lock/G_LOCK/, s/g_unlock/G_UNLOCK/,
+ s/static G_LOCK_DEFINE/G_LOCK_DECLARE_STATIC/.
+
Tue Dec 15 23:16:05 CST 1998 Shawn T. Amundson <amundson@gtk.org>
* Released GLib 1.1.8
+Wed Dec 16 03:16:58 1998 Tim Janik <timj@gtk.org>
+
+ * configure.in: version bump to 1.1.8, binary age 0, interface age 0.
+
+ * glib.h: changed g_lock() to G_LOCK(), g_unlock() to G_UNLOCK() and
+ g_trylock() to G_TRYLOCK(), since these are macros that expand to
+ nothing with --disable-threads.
+ changed G_LOCK_DEFINE() to G_LOCK_DECLARE() and introduced
+ G_LOCK_DECLARE_STATIC() to achive the results of static G_LOCK_DECLARE().
+ changed semantics of g_thread_supported to g_thread_supported() so it
+ can be used as a function like g_module_supported(). the actuall
+ definition is still a macro that expands into a variable for
+ performance reasons though.
+ various indentation and coding style cleanups.
+
+ * configure.in: added --enable-threads that defaults to yes.
+
+ * gmutex.c: changed tests g_thread_supported to g_thread_supported (),
+ changed variable settings of g_thread_supported
+ to g_threads_got_initialized.
+
+ garray.c:
+ gcache.c:
+ gdataset.c:
+ gdate.c:
+ ghash.c:
+ glist.c:
+ gmain.c:
+ gnode.c:
+ gslist.c:
+ gstring.c:
+ gtree.c:
+ gutils.c:
+ changed s/g_lock/G_LOCK/, s/g_unlock/G_UNLOCK/,
+ s/static G_LOCK_DEFINE/G_LOCK_DECLARE_STATIC/.
+
Tue Dec 15 23:16:05 CST 1998 Shawn T. Amundson <amundson@gtk.org>
* Released GLib 1.1.8
+Wed Dec 16 03:16:58 1998 Tim Janik <timj@gtk.org>
+
+ * configure.in: version bump to 1.1.8, binary age 0, interface age 0.
+
+ * glib.h: changed g_lock() to G_LOCK(), g_unlock() to G_UNLOCK() and
+ g_trylock() to G_TRYLOCK(), since these are macros that expand to
+ nothing with --disable-threads.
+ changed G_LOCK_DEFINE() to G_LOCK_DECLARE() and introduced
+ G_LOCK_DECLARE_STATIC() to achive the results of static G_LOCK_DECLARE().
+ changed semantics of g_thread_supported to g_thread_supported() so it
+ can be used as a function like g_module_supported(). the actuall
+ definition is still a macro that expands into a variable for
+ performance reasons though.
+ various indentation and coding style cleanups.
+
+ * configure.in: added --enable-threads that defaults to yes.
+
+ * gmutex.c: changed tests g_thread_supported to g_thread_supported (),
+ changed variable settings of g_thread_supported
+ to g_threads_got_initialized.
+
+ garray.c:
+ gcache.c:
+ gdataset.c:
+ gdate.c:
+ ghash.c:
+ glist.c:
+ gmain.c:
+ gnode.c:
+ gslist.c:
+ gstring.c:
+ gtree.c:
+ gutils.c:
+ changed s/g_lock/G_LOCK/, s/g_unlock/G_UNLOCK/,
+ s/static G_LOCK_DEFINE/G_LOCK_DECLARE_STATIC/.
+
Tue Dec 15 23:16:05 CST 1998 Shawn T. Amundson <amundson@gtk.org>
* Released GLib 1.1.8
#undef ENABLE_MEM_PROFILE
#undef G_COMPILED_WITH_DEBUGGING
+#undef G_THREADS_ENABLED
#undef HAVE_BROKEN_WCTYPE
#undef HAVE_DOPRNT
#undef HAVE_FLOAT_H
AC_CANONICAL_HOST
AC_ARG_ENABLE(debug, [ --enable-debug=[no/minimum/yes] turn on debugging [default=minimum]],,enable_debug=minimum)
-AC_ARG_ENABLE(mem_check, [ --enable-mem-check=[no/yes] turn on malloc/free sanity checking [default=no]],,enable_mem_check=no)
-AC_ARG_ENABLE(mem_profile, [ --enable-mem-profile=[no/yes] turn on malloc profiling atexit [default=no]],,enable_mem_profile=no)
-
+AC_ARG_ENABLE(mem_check, [ --enable-mem-check turn on malloc/free sanity checking [default=no]],,enable_mem_check=no)
+AC_ARG_ENABLE(mem_profile, [ --enable-mem-profile turn on malloc profiling atexit [default=no]],,enable_mem_profile=no)
AC_ARG_ENABLE(ansi, [ --enable-ansi turn on strict ansi [default=no]],
, enable_ansi=no)
+AC_ARG_ENABLE(threads, [ --enable-threads turn on basic thread support [default=yes]
+ ([=no] will override --with-threads)],,enable_threads=yes)
+
+if test "x$enable_threads" != "xyes"; then
+ enable_threads=no
+fi
AC_MSG_CHECKING(whether to enable memory checking)
if test "x$enable_mem_check" = "xyes"; then
dnl *** g_thread checks ***
dnl ***********************
-AC_ARG_WITH(threads, [ --with-threads=[none/posix/solaris/nspr] specify a thread implementation to use.],
+AC_ARG_WITH(threads, [ --with-threads=[none/posix/solaris/nspr] specify a thread implementation to use],
if test "x$with_threads" = x; then
want_threads=yes
else
want_threads=$with_threads
fi,
want_threads=yes)
+if test "x$enable_threads" = "xno"; then
+ want_threads=no
+fi
if test "x$want_threads" = "xnone"; then
want_threads=no
fi
cat >>$outfile <<outfile_EOF
+$g_enable_threads_def G_THREADS_ENABLED
+
/* definitions for the default mutex implementation */
outfile_EOF
#define G_HAVE_BROKEN_WCTYPE 1"
fi
+case x$enable_threads in
+xyes) g_enable_threads_def="#define";;
+*) g_enable_threads_def="#undef ";;
+esac
+
case $have_threads in
posix)
g_mutex_has_default=yes
gint len);
static GMemChunk *array_mem_chunk = NULL;
-static G_LOCK_DEFINE(array_mem_chunk);
+G_LOCK_DECLARE_STATIC (array_mem_chunk);
GArray*
g_array_new (gboolean zero_terminated,
{
GRealArray *array;
- g_lock (array_mem_chunk);
+ G_LOCK (array_mem_chunk);
if (!array_mem_chunk)
array_mem_chunk = g_mem_chunk_new ("array mem chunk",
sizeof (GRealArray),
1024, G_ALLOC_AND_FREE);
array = g_chunk_new (GRealArray, array_mem_chunk);
- g_unlock (array_mem_chunk);
+ G_UNLOCK (array_mem_chunk);
array->data = NULL;
array->len = 0;
if (free_segment)
g_free (array->data);
- g_lock (array_mem_chunk);
+ G_LOCK (array_mem_chunk);
g_mem_chunk_free (array_mem_chunk, array);
- g_unlock (array_mem_chunk);
+ G_UNLOCK (array_mem_chunk);
}
GArray*
gint len);
static GMemChunk *ptr_array_mem_chunk = NULL;
-static G_LOCK_DEFINE(ptr_array_mem_chunk);
+G_LOCK_DECLARE_STATIC (ptr_array_mem_chunk);
GPtrArray*
{
GRealPtrArray *array;
- g_lock (ptr_array_mem_chunk);
+ G_LOCK (ptr_array_mem_chunk);
if (!ptr_array_mem_chunk)
ptr_array_mem_chunk = g_mem_chunk_new ("array mem chunk",
sizeof (GRealPtrArray),
1024, G_ALLOC_AND_FREE);
array = g_chunk_new (GRealPtrArray, ptr_array_mem_chunk);
- g_unlock (ptr_array_mem_chunk);
+ G_UNLOCK (ptr_array_mem_chunk);
array->pdata = NULL;
array->len = 0;
if (free_segment)
g_free (array->pdata);
- g_lock (ptr_array_mem_chunk);
+ G_LOCK (ptr_array_mem_chunk);
g_mem_chunk_free (ptr_array_mem_chunk, array);
- g_unlock (ptr_array_mem_chunk);
+ G_UNLOCK (ptr_array_mem_chunk);
}
static void
static GMemChunk *node_mem_chunk = NULL;
-static G_LOCK_DEFINE(node_mem_chunk);
+G_LOCK_DECLARE_STATIC (node_mem_chunk);
GCache*
g_cache_new (GCacheNewFunc value_new_func,
{
GCacheNode *node;
- g_lock (node_mem_chunk);
+ G_LOCK (node_mem_chunk);
if (!node_mem_chunk)
node_mem_chunk = g_mem_chunk_new ("cache node mem chunk", sizeof (GCacheNode),
1024, G_ALLOC_AND_FREE);
node = g_chunk_new (GCacheNode, node_mem_chunk);
- g_unlock (node_mem_chunk);
+ G_UNLOCK (node_mem_chunk);
node->value = value;
node->ref_count = 1;
static void
g_cache_node_destroy (GCacheNode *node)
{
- g_lock (node_mem_chunk);
+ G_LOCK (node_mem_chunk);
g_mem_chunk_free (node_mem_chunk, node);
- g_unlock (node_mem_chunk);
+ G_UNLOCK (node_mem_chunk);
}
/* --- variables --- */
-static G_LOCK_DEFINE(g_dataset_global);
+G_LOCK_DECLARE_STATIC (g_dataset_global);
static GHashTable *g_dataset_location_ht = NULL;
static GDataset *g_dataset_cached = NULL; /* should this be
threadspecific? */
static GData *g_data_cache = NULL;
static guint g_data_cache_length = 0;
-static G_LOCK_DEFINE(g_quark_global);
+G_LOCK_DECLARE_STATIC (g_quark_global);
static GHashTable *g_quark_ht = NULL;
static gchar **g_quarks = NULL;
static GQuark g_quark_seq_id = 0;
{
g_return_if_fail (datalist != NULL);
- g_lock (g_dataset_global);
+ G_LOCK (g_dataset_global);
if (!g_dataset_location_ht)
g_data_initialize ();
while (*datalist)
g_datalist_clear_i (datalist);
- g_unlock (g_dataset_global);
+ G_UNLOCK (g_dataset_global);
}
/* HOLDS: g_dataset_global_lock */
{
g_return_if_fail (dataset_location != NULL);
- g_lock (g_dataset_global);
+ G_LOCK (g_dataset_global);
if (g_dataset_location_ht)
{
register GDataset *dataset;
if (dataset)
g_dataset_destroy_internal (dataset);
}
- g_unlock (g_dataset_global);
+ G_UNLOCK (g_dataset_global);
}
/* HOLDS: g_dataset_global_lock */
return;
}
- g_lock (g_dataset_global);
+ G_LOCK (g_dataset_global);
if (!g_dataset_location_ht)
g_data_initialize ();
}
g_data_set_internal (&dataset->datalist, key_id, data, destroy_func, dataset);
- g_unlock (g_dataset_global);
+ G_UNLOCK (g_dataset_global);
}
void
return;
}
- g_lock (g_dataset_global);
+ G_LOCK (g_dataset_global);
if (!g_dataset_location_ht)
g_data_initialize ();
g_data_set_internal (datalist, key_id, data, destroy_func, NULL);
- g_unlock (g_dataset_global);
+ G_UNLOCK (g_dataset_global);
}
void
{
g_return_if_fail (dataset_location != NULL);
- g_lock (g_dataset_global);
+ G_LOCK (g_dataset_global);
if (key_id && g_dataset_location_ht)
{
GDataset *dataset;
if (dataset)
g_data_set_internal (&dataset->datalist, key_id, NULL, (GDestroyNotify) 42, dataset);
}
- g_unlock (g_dataset_global);
+ G_UNLOCK (g_dataset_global);
}
void
{
g_return_if_fail (datalist != NULL);
- g_lock (g_dataset_global);
+ G_LOCK (g_dataset_global);
if (key_id && g_dataset_location_ht)
g_data_set_internal (datalist, key_id, NULL, (GDestroyNotify) 42, NULL);
- g_unlock (g_dataset_global);
+ G_UNLOCK (g_dataset_global);
}
gpointer
{
g_return_val_if_fail (dataset_location != NULL, NULL);
- g_lock (g_dataset_global);
+ G_LOCK (g_dataset_global);
if (key_id && g_dataset_location_ht)
{
register GDataset *dataset;
for (list = dataset->datalist; list; list = list->next)
if (list->id == key_id)
{
- g_unlock (g_dataset_global);
+ G_UNLOCK (g_dataset_global);
return list->data;
}
}
}
- g_unlock (g_dataset_global);
+ G_UNLOCK (g_dataset_global);
return NULL;
}
g_return_if_fail (dataset_location != NULL);
g_return_if_fail (func != NULL);
- g_lock (g_dataset_global);
+ G_LOCK (g_dataset_global);
if (g_dataset_location_ht)
{
dataset = g_dataset_lookup (dataset_location);
- g_unlock (g_dataset_global);
+ G_UNLOCK (g_dataset_global);
if (dataset)
{
register GData *list;
}
else
{
- g_unlock (g_dataset_global);
+ G_UNLOCK (g_dataset_global);
}
}
GQuark quark = 0;
g_return_val_if_fail (string != NULL, 0);
- g_lock (g_quark_global);
+ G_LOCK (g_quark_global);
if (g_quark_ht)
quark = GPOINTER_TO_UINT (g_hash_table_lookup (g_quark_ht, string));
- g_unlock (g_quark_global);
+ G_UNLOCK (g_quark_global);
return quark;
}
g_return_val_if_fail (string != NULL, 0);
- g_lock (g_quark_global);
+ G_LOCK (g_quark_global);
if (g_quark_ht)
quark = (gulong) g_hash_table_lookup (g_quark_ht, string);
else
if (!quark)
quark = g_quark_new (g_strdup (string));
- g_unlock (g_quark_global);
+ G_UNLOCK (g_quark_global);
return quark;
}
g_return_val_if_fail (string != NULL, 0);
- g_lock (g_quark_global);
+ G_LOCK (g_quark_global);
if (g_quark_ht)
quark = (gulong) g_hash_table_lookup (g_quark_ht, string);
else
if (!quark)
quark = g_quark_new ((gchar*) string);
- g_unlock (g_quark_global);
+ G_UNLOCK (g_quark_global);
return quark;
}
g_quark_to_string (GQuark quark)
{
gchar* result = NULL;
- g_lock (g_quark_global);
+ G_LOCK (g_quark_global);
if (quark > 0 && quark <= g_quark_seq_id)
result = g_quarks[quark - 1];
- g_unlock (g_quark_global);
+ G_UNLOCK (g_quark_global);
return result;
}
memset (d, 0x0, ndates*sizeof (GDate));
}
-static G_LOCK_DEFINE(g_date_global);
+G_LOCK_DECLARE_STATIC (g_date_global);
/* These are for the parser, output to the user should use *
* g_date_strftime () - this creates more never-freed memory to annoy
/* set invalid */
g_date_clear (d, 1);
- g_lock (g_date_global);
+ G_LOCK (g_date_global);
g_date_prepare_to_parse (str, &pt);
if (pt.num_ints == 4)
{
- g_unlock (g_date_global);
+ G_UNLOCK (g_date_global);
return; /* presumably a typo; bail out. */
}
else
g_message ("Rejected DMY %u %u %u", day, m, y);
#endif
- g_unlock (g_date_global);
+ G_UNLOCK (g_date_global);
}
void
static void g_hash_nodes_destroy (GHashNode *hash_node);
-static G_LOCK_DEFINE(g_hash_global);
+G_LOCK_DECLARE_STATIC (g_hash_global);
static GMemChunk *node_mem_chunk = NULL;
static GHashNode *node_free_list = NULL;
{
GHashNode *hash_node;
- g_lock (g_hash_global);
+ G_LOCK (g_hash_global);
if (node_free_list)
{
hash_node = node_free_list;
hash_node = g_chunk_new (GHashNode, node_mem_chunk);
}
- g_unlock (g_hash_global);
+ G_UNLOCK (g_hash_global);
hash_node->key = key;
hash_node->value = value;
static void
g_hash_node_destroy (GHashNode *hash_node)
{
- g_lock (g_hash_global);
+ G_LOCK (g_hash_global);
hash_node->next = node_free_list;
node_free_list = hash_node;
- g_unlock (g_hash_global);
+ G_UNLOCK (g_hash_global);
}
static void
while (node->next)
node = node->next;
- g_lock (g_hash_global);
+ G_LOCK (g_hash_global);
node->next = node_free_list;
node_free_list = hash_node;
- g_unlock (g_hash_global);
+ G_UNLOCK (g_hash_global);
}
} G_STMT_END
-/* Completion */
+/* GCompletion
+ */
struct _GCompletion
{
void g_completion_free (GCompletion* cmp);
-
-
-/* Date calculations (not time for now, to be resolved). These are a
+/* GDate
+ *
+ * Date calculations (not time for now, to be resolved). These are a
* mutant combination of Steffen Beyer's DateCalc routines
* (http://www.perl.com/CPAN/authors/id/STBEY/) and Jon Trowbridge's
* date routines (written for in-house software). Written by Havoc
* Pennington <hp@pobox.com>
*/
-/* this enum is used to specify order of appearance in parsed date
- * strings
- */
+typedef guint16 GDateYear;
+typedef guint8 GDateDay; /* day of the month */
+typedef struct _GDate GDate;
+/* make struct tm known without having to include time.h */
+struct tm;
-typedef enum {
+/* enum used to specify order of appearance in parsed date strings */
+typedef enum
+{
G_DATE_DAY = 0,
G_DATE_MONTH = 1,
G_DATE_YEAR = 2
} GDateDMY;
-/* These other types specify the actual values. */
-
-typedef enum {
+/* actual week and month values */
+typedef enum
+{
G_DATE_BAD_WEEKDAY = 0,
G_DATE_MONDAY = 1,
G_DATE_TUESDAY = 2,
G_DATE_SATURDAY = 6,
G_DATE_SUNDAY = 7
} GDateWeekday;
-
-typedef enum {
+typedef enum
+{
G_DATE_BAD_MONTH = 0,
G_DATE_JANUARY = 1,
G_DATE_FEBRUARY = 2,
G_DATE_DECEMBER = 12
} GDateMonth;
-typedef guint16 GDateYear;
-typedef guint8 GDateDay; /* day of the month */
-
#define G_DATE_BAD_JULIAN 0U
#define G_DATE_BAD_DAY 0U
#define G_DATE_BAD_YEAR 0U
-typedef struct _GDate GDate;
-
/* Note: directly manipulating structs is generally a bad idea, but
* in this case it's an *incredibly* bad idea, because all or part
* of this struct can be invalid at any given time. Use the functions,
* or you will get hosed, I promise.
*/
-
-struct _GDate {
+struct _GDate
+{
guint julian_days : 32; /* julian days representation - we use a
* bitfield hoping that 64 bit platforms
* will pack this whole struct in one big
guint year : 16;
};
-/* _new with no args returns an invalid date, you then have to _set() stuff
+/* g_date_new() returns an invalid date, you then have to _set() stuff
* to get a usable object. You can also allocate a GDate statically,
* then call g_date_clear() to initialize.
*/
-
GDate* g_date_new (void);
-GDate* g_date_new_dmy (GDateDay d,
- GDateMonth m,
- GDateYear y);
+GDate* g_date_new_dmy (GDateDay day,
+ GDateMonth month,
+ GDateYear year);
GDate* g_date_new_julian (guint32 julian_day);
-void g_date_free (GDate *d);
+void g_date_free (GDate *date);
/* check g_date_valid() after doing an operation that might fail, like
* _parse. Almost all g_date operations are undefined on invalid
* dates (the exceptions are the mutators, since you need those to
* return to validity).
*/
+gboolean g_date_valid (GDate *date);
+gboolean g_date_valid_day (GDateDay day);
+gboolean g_date_valid_month (GDateMonth month);
+gboolean g_date_valid_year (GDateYear year);
+gboolean g_date_valid_weekday (GDateWeekday weekday);
+gboolean g_date_valid_julian (guint32 julian_date);
+gboolean g_date_valid_dmy (GDateDay day,
+ GDateMonth month,
+ GDateYear year);
-gboolean g_date_valid (GDate *d);
-gboolean g_date_valid_day (GDateDay d);
-gboolean g_date_valid_month (GDateMonth m);
-gboolean g_date_valid_year (GDateYear y);
-gboolean g_date_valid_weekday (GDateWeekday w);
-gboolean g_date_valid_julian (guint32 j);
-gboolean g_date_valid_dmy (GDateDay d,
- GDateMonth m,
- GDateYear y);
-
-GDateWeekday g_date_weekday (GDate *d);
-GDateMonth g_date_month (GDate *d);
-GDateYear g_date_year (GDate *d);
-GDateDay g_date_day (GDate *d);
-guint32 g_date_julian (GDate *d);
-
-guint g_date_day_of_year (GDate *d);
+GDateWeekday g_date_weekday (GDate *date);
+GDateMonth g_date_month (GDate *date);
+GDateYear g_date_year (GDate *date);
+GDateDay g_date_day (GDate *date);
+guint32 g_date_julian (GDate *date);
+guint g_date_day_of_year (GDate *date);
/* First monday/sunday is the start of week 1; if we haven't reached
- * that day, return 0. These are not ISO weeks of the year; that
- * routine should be added.
+ * that day, return 0. These are not ISO weeks of the year; that
+ * routine needs to be added.
+ * these functions return the number of weeks, starting on the
+ * corrsponding day
*/
-
-guint g_date_monday_week_of_year (GDate *d); /* # weeks, starting on Monday */
-guint g_date_sunday_week_of_year (GDate *d); /* # weeks, starting on Sunday */
+guint g_date_monday_week_of_year (GDate *date);
+guint g_date_sunday_week_of_year (GDate *date);
/* If you create a static date struct you need to clear it to get it
* in a sane state before use. You can clear a whole array at
* once with the ndates argument.
*/
-
-void g_date_clear (GDate *d,
- guint ndates);
+void g_date_clear (GDate *date,
+ guint n_dates);
/* The parse routine is meant for dates typed in by a user, so it
* permits many formats but tries to catch common typos. If your data
* needs to be strictly validated, it is not an appropriate function.
*/
-
-void g_date_set_parse (GDate *d,
+void g_date_set_parse (GDate *date,
const gchar *str);
-
-void g_date_set_time (GDate *d,
+void g_date_set_time (GDate *date,
GTime time);
-
-void g_date_set_month (GDate *d,
- GDateMonth m);
-void g_date_set_day (GDate *d,
+void g_date_set_month (GDate *date,
+ GDateMonth month);
+void g_date_set_day (GDate *date,
GDateDay day);
-void g_date_set_year (GDate *d,
- GDateYear y);
-void g_date_set_dmy (GDate *d,
+void g_date_set_year (GDate *date,
+ GDateYear year);
+void g_date_set_dmy (GDate *date,
GDateDay day,
- GDateMonth m,
+ GDateMonth month,
GDateYear y);
-
-void g_date_set_julian (GDate *d,
- guint32 j);
-
-gboolean g_date_is_first_of_month (GDate *d);
-gboolean g_date_is_last_of_month (GDate *d);
-
+void g_date_set_julian (GDate *date,
+ guint32 julian_date);
+gboolean g_date_is_first_of_month (GDate *date);
+gboolean g_date_is_last_of_month (GDate *date);
/* To go forward by some number of weeks just go forward weeks*7 days */
-void g_date_add_days (GDate *d,
- guint ndays);
-void g_date_subtract_days (GDate *d,
- guint ndays);
+void g_date_add_days (GDate *date,
+ guint n_days);
+void g_date_subtract_days (GDate *date,
+ guint n_days);
/* If you add/sub months while day > 28, the day might change */
-void g_date_add_months (GDate *d,
- guint nmonths);
-void g_date_subtract_months (GDate *d,
- guint nmonths);
+void g_date_add_months (GDate *date,
+ guint n_months);
+void g_date_subtract_months (GDate *date,
+ guint n_months);
/* If it's feb 29, changing years can move you to the 28th */
-void g_date_add_years (GDate *d,
- guint nyears);
-void g_date_subtract_years (GDate *d,
- guint nyears);
-
+void g_date_add_years (GDate *date,
+ guint n_years);
+void g_date_subtract_years (GDate *date,
+ guint n_years);
gboolean g_date_is_leap_year (GDateYear year);
guint8 g_date_days_in_month (GDateMonth month,
GDateYear year);
/* qsort-friendly (with a cast...) */
gint g_date_compare (GDate *lhs,
GDate *rhs);
-
-/* make struct tm known without having to include time.h */
-struct tm;
-
-void g_date_to_struct_tm (GDate *d,
+void g_date_to_struct_tm (GDate *date,
struct tm *tm);
/* Just like strftime() except you can only use date-related formats.
gsize g_date_strftime (gchar *s,
gsize slen,
const gchar *format,
- GDate *d);
-
-
+ GDate *date);
-/* GRelation: Indexed Relations. Imagine a really simple table in a
+/* GRelation
+ *
+ * Indexed Relations. Imagine a really simple table in a
* database. Relations are not ordered. This data type is meant for
* maintaining a N-way mapping.
*
guint g_spaced_primes_closest (guint num);
-/* IO Channels
+/* GIOChannel
*/
typedef struct _GIOFuncs GIOFuncs;
-
-typedef enum {
+typedef enum
+{
G_IO_ERROR_NONE,
G_IO_ERROR_AGAIN,
G_IO_ERROR_INVAL,
G_IO_ERROR_UNKNOWN
} GIOError;
-
-typedef enum {
+typedef enum
+{
G_SEEK_CUR,
G_SEEK_SET,
G_SEEK_END
} GSeekType;
-
-typedef enum {
+typedef enum
+{
G_IO_IN
#ifdef POLLIN
= POLLIN
#endif
- ,G_IO_OUT
+ , G_IO_OUT
#ifdef POLLOUT
= POLLOUT
#endif
- ,G_IO_PRI
+ , G_IO_PRI
#ifdef POLLPRI
= POLLPRI
#endif
- ,G_IO_ERR
+ , G_IO_ERR
#ifdef POLLERR
= POLLERR
#endif
- ,G_IO_HUP
+ , G_IO_HUP
#ifdef POLLHUP
= POLLHUP
#endif
- ,G_IO_NVAL
+ , G_IO_NVAL
#ifdef POLLNVAL
= POLLNVAL
#endif
typedef gboolean (*GIOFunc) (GIOChannel *source,
GIOCondition condition,
gpointer data);
-
-struct _GIOFuncs {
- GIOError (*io_read) (GIOChannel *channel,
- gchar *buf,
- guint count,
- guint *bytes_read);
- GIOError (*io_write) (GIOChannel *channel,
- gchar *buf,
- guint count,
- guint *bytes_written);
- GIOError (*io_seek) (GIOChannel *channel,
- gint offset,
- GSeekType type);
- void (*io_close) (GIOChannel *channel);
- guint (*io_add_watch) (GIOChannel *channel,
- gint priority,
- GIOCondition condition,
- GIOFunc func,
- gpointer user_data,
- GDestroyNotify notify);
- void (*io_free) (GIOChannel *channel);
+struct _GIOFuncs
+{
+ GIOError (*io_read) (GIOChannel *channel,
+ gchar *buf,
+ guint count,
+ guint *bytes_read);
+ GIOError (*io_write) (GIOChannel *channel,
+ gchar *buf,
+ guint count,
+ guint *bytes_written);
+ GIOError (*io_seek) (GIOChannel *channel,
+ gint offset,
+ GSeekType type);
+ void (*io_close) (GIOChannel *channel);
+ guint (*io_add_watch) (GIOChannel *channel,
+ gint priority,
+ GIOCondition condition,
+ GIOFunc func,
+ gpointer user_data,
+ GDestroyNotify notify);
+ void (*io_free) (GIOChannel *channel);
};
void g_io_channel_init (GIOChannel *channel);
GIOFunc func,
gpointer user_data);
-/* Main loop */
-
-typedef struct _GTimeVal GTimeVal;
-typedef struct _GSourceFuncs GSourceFuncs;
-typedef struct _GMainLoop GMainLoop; /* Opaque */
+/* Main loop
+ */
+typedef struct _GTimeVal GTimeVal;
+typedef struct _GSourceFuncs GSourceFuncs;
+typedef struct _GMainLoop GMainLoop; /* Opaque */
-struct _GTimeVal {
+struct _GTimeVal
+{
glong tv_sec;
glong tv_usec;
};
-
-struct _GSourceFuncs {
+struct _GSourceFuncs
+{
gboolean (*prepare) (gpointer source_data,
GTimeVal *current_time,
gint *timeout);
GDestroyNotify destroy;
};
-typedef gboolean (*GSourceFunc) (gpointer data);
+typedef gboolean (*GSourceFunc) (gpointer data);
/* Hooks for adding to the main loop */
-
guint g_source_add (gint priority,
gboolean can_recurse,
GSourceFuncs *funcs,
void g_source_remove_by_user_data (gpointer user_data);
void g_source_remove_by_source_data (gpointer source_data);
-
-void g_get_current_time (GTimeVal *result);
+void g_get_current_time (GTimeVal *result);
/* Running the main loop */
-
-GMainLoop *g_main_new (void);
-void g_main_run (GMainLoop *loop);
-void g_main_quit (GMainLoop *loop);
-void g_main_destroy (GMainLoop *loop);
+GMainLoop* g_main_new (void);
+void g_main_run (GMainLoop *loop);
+void g_main_quit (GMainLoop *loop);
+void g_main_destroy (GMainLoop *loop);
/* Run a single iteration of the mainloop. If block is FALSE,
* will never block
*/
-gboolean g_main_iteration (gboolean block);
+gboolean g_main_iteration (gboolean may_block);
-/* See if any events are pending
- */
-gboolean g_main_pending ();
+/* See if any events are pending */
+gboolean g_main_pending (void);
/* Idles and timeouts */
-
-guint g_timeout_add_full (gint priority,
- guint interval,
- GSourceFunc function,
- gpointer data,
- GDestroyNotify notify);
-guint g_timeout_add (guint interval,
- GSourceFunc function,
- gpointer data);
-
-guint g_idle_add (GSourceFunc function,
- gpointer data);
-guint g_idle_add_full (gint priority,
- GSourceFunc function,
- gpointer data,
- GDestroyNotify destroy);
-
-/* Unix-specific IO and main loop calls */
+guint g_timeout_add_full (gint priority,
+ guint interval,
+ GSourceFunc function,
+ gpointer data,
+ GDestroyNotify notify);
+guint g_timeout_add (guint interval,
+ GSourceFunc function,
+ gpointer data);
+guint g_idle_add (GSourceFunc function,
+ gpointer data);
+guint g_idle_add_full (gint priority,
+ GSourceFunc function,
+ gpointer data,
+ GDestroyNotify destroy);
+
+/* GPollFD
+ *
+ * Unix-specific IO and main loop calls
+ */
typedef struct _GPollFD GPollFD;
-
-struct _GPollFD {
- gint fd;
- gushort events;
- gushort revents;
+typedef gint (*GPollFunc) (GPollFD *ufds,
+ guint nfsd,
+ gint timeout);
+struct _GPollFD
+{
+ gint fd;
+ gushort events;
+ gushort revents;
};
-typedef gint (*GPollFunc) (GPollFD *ufds, guint nfsd, gint timeout);
-
void g_main_poll_add (gint priority,
GPollFD *fd);
void g_main_poll_remove (GPollFD *fd);
-
void g_main_set_poll_func (GPollFunc func);
-
-GIOChannel *g_io_channel_unix_new (int fd);
+GIOChannel* g_io_channel_unix_new (int fd);
gint g_io_channel_unix_get_fd (GIOChannel *channel);
-#if 0 /* old IO Channels */
+/* old IO Channels */
+#if 0
/* IO Channels.
* These are used for plug-in communication in the GIMP, for instance.
* On Unix, it's simply an encapsulated file descriptor (a pipe).
*/
#endif
};
-
GIOChannel *g_iochannel_new (gint fd);
void g_iochannel_free (GIOChannel *channel);
void g_iochannel_close_and_free (GIOChannel *channel);
#ifndef NATIVE_WIN32
# define g_iochannel_wakeup_peer(channel) G_STMT_START { } G_STMT_END
#endif
+#endif /* old IO Channels */
-#endif /* old IO Channels */
/* Windows emulation stubs for common unix functions
*/
#ifdef NATIVE_WIN32
-
-#define MAXPATHLEN 1024
-
-#ifdef _MSC_VER
+# define MAXPATHLEN 1024
+# ifdef _MSC_VER
typedef int pid_t;
/* These POSIXish functions are available in the Microsoft C library
* For some functions, we provide emulators in glib, which are prefixed
* with gwin_.
*/
-#define getcwd _getcwd
-#define getpid _getpid
-#define access _access
-#define open _open
-#define read _read
-#define write _write
-#define lseek _lseek
-#define close _close
-#define pipe(phandles) _pipe (phandles, 4096, _O_BINARY)
-#define popen _popen
-#define pclose _pclose
-#define fdopen _fdopen
-#define ftruncate(fd, size) gwin_ftruncate (fd, size)
-#define opendir gwin_opendir
-#define readdir gwin_readdir
-#define rewinddir gwin_rewinddir
-#define closedir gwin_closedir
-
-#define NAME_MAX 255
-
+# define getcwd _getcwd
+# define getpid _getpid
+# define access _access
+# define open _open
+# define read _read
+# define write _write
+# define lseek _lseek
+# define close _close
+# define pipe(phandles) _pipe (phandles, 4096, _O_BINARY)
+# define popen _popen
+# define pclose _pclose
+# define fdopen _fdopen
+# define ftruncate(fd, size) gwin_ftruncate (fd, size)
+# define opendir gwin_opendir
+# define readdir gwin_readdir
+# define rewinddir gwin_rewinddir
+# define closedir gwin_closedir
+# define NAME_MAX 255
struct DIR
{
gchar *dir_name;
-
gboolean just_opened;
guint find_file_handle;
gpointer find_file_data;
{
gchar d_name[NAME_MAX + 1];
};
-
/* emulation functions */
extern int gwin_ftruncate (gint f,
guint size);
struct dirent* gwin_readdir (DIR *dir);
void gwin_rewinddir (DIR *dir);
gint gwin_closedir (DIR *dir);
+# endif /* _MSC_VER */
+#endif /* NATIVE_WIN32 */
-#endif /* _MSC_VER */
-
-#endif /* NATIVE_WIN32 */
-
-/* functions for thread support for glib. */
-
-typedef struct _GMutex GMutex;
-typedef struct _GCond GCond;
-typedef struct _GPrivate GPrivate;
-typedef struct _GStaticPrivate GStaticPrivate;
+/* GLib Thread support
+ */
+typedef struct _GMutex GMutex;
+typedef struct _GCond GCond;
+typedef struct _GPrivate GPrivate;
+typedef struct _GStaticPrivate GStaticPrivate;
typedef struct _GThreadFunctions GThreadFunctions;
struct _GThreadFunctions
{
GMutex* (*mutex_new) (void);
- void (*mutex_lock) (GMutex* mutex);
- gboolean (*mutex_trylock) (GMutex* mutex);
- void (*mutex_unlock) (GMutex* mutex);
- void (*mutex_free) (GMutex* mutex);
+ void (*mutex_lock) (GMutex *mutex);
+ gboolean (*mutex_trylock) (GMutex *mutex);
+ void (*mutex_unlock) (GMutex *mutex);
+ void (*mutex_free) (GMutex *mutex);
GCond* (*cond_new) (void);
- void (*cond_signal) (GCond* cond);
- void (*cond_broadcast) (GCond* cond);
- void (*cond_wait) (GCond* cond, GMutex* mutex);
- gboolean (*cond_timed_wait) (GCond* cond, GMutex* mutex,
- GTimeVal *end_time);
- void (*cond_free) (GCond* cond);
- GPrivate* (*private_new) (GDestroyNotify destructor);
- gpointer (*private_get) (GPrivate* private_key);
- void (*private_set) (GPrivate* private_key, gpointer value);
+ void (*cond_signal) (GCond *cond);
+ void (*cond_broadcast) (GCond *cond);
+ void (*cond_wait) (GCond *cond,
+ GMutex *mutex);
+ gboolean (*cond_timed_wait) (GCond *cond,
+ GMutex *mutex,
+ GTimeVal *end_time);
+ void (*cond_free) (GCond *cond);
+ GPrivate* (*private_new) (GDestroyNotify destructor);
+ gpointer (*private_get) (GPrivate *private_key);
+ void (*private_set) (GPrivate *private_key,
+ gpointer data);
};
-GUTILS_C_VAR GThreadFunctions g_thread_functions_for_glib_use;
-GUTILS_C_VAR gboolean g_thread_use_default_impl;
-GUTILS_C_VAR gboolean g_thread_supported;
+GUTILS_C_VAR GThreadFunctions g_thread_functions_for_glib_use;
+GUTILS_C_VAR gboolean g_thread_use_default_impl;
+GUTILS_C_VAR gboolean g_threads_got_initialized;
/* initializes the mutex/cond/private implementation for glib, might
* only be called once, and must not be called directly or indirectly
- * from another glib-function, e.g. as a callback. */
-void g_thread_init(GThreadFunctions* init);
-
-/* Internal functions for fallback static mutex implementation
- * Please don't use it directly
+ * from another glib-function, e.g. as a callback.
*/
-GMutex* g_static_mutex_get_mutex_impl(GMutex** mutex);
+void g_thread_init (GThreadFunctions *vtable);
-#define G_USE_THREAD_FUNC_UNCOND(name,arg) \
- (*g_thread_functions_for_glib_use.name)arg
-#define G_USE_THREAD_FUNC(name,fail,arg) \
- (g_thread_supported ? G_USE_THREAD_FUNC_UNCOND(name,arg) : (fail))
+/* internal function for fallback static mutex implementation */
+GMutex* g_static_mutex_get_mutex_impl (GMutex **mutex);
+/* shorthands for conditional and unconditional function calls */
+#define G_THREAD_UF(name, arglist) \
+ (*g_thread_functions_for_glib_use . name) arglist
+#define G_THREAD_CF(name, fail, arg) \
+ (g_thread_supported () ? G_THREAD_UF (name, arg) : (fail))
/* keep in mind, all those mutexes and static mutexes are not
- * recursive in general, don't rely on that */
-#define g_mutex_new() G_USE_THREAD_FUNC_UNCOND(mutex_new,())
-#define g_mutex_lock(mutex) G_USE_THREAD_FUNC(mutex_lock,(void)0,(mutex))
-#define g_mutex_trylock(mutex) G_USE_THREAD_FUNC(mutex_trylock,TRUE,(mutex))
-#define g_mutex_unlock(mutex) G_USE_THREAD_FUNC(mutex_unlock,(void)0,(mutex))
-#define g_mutex_free(mutex) G_USE_THREAD_FUNC(mutex_free,(void)0,(mutex))
-#define g_cond_new() G_USE_THREAD_FUNC_UNCOND(cond_new,())
-#define g_cond_signal(cond) G_USE_THREAD_FUNC(cond_signal,(void)0,(cond))
-#define g_cond_broadcast(cond) G_USE_THREAD_FUNC(cond_broadcast,(void)0,(cond))
-#define g_cond_wait(cond,mutex) G_USE_THREAD_FUNC(cond_wait,(void)0,(cond,mutex))
-#define g_cond_timed_wait(cond,mutex,abs_time) \
- G_USE_THREAD_FUNC(cond_timed_wait,TRUE,(cond,mutex,abs_time))
-#define g_cond_free(cond) G_USE_THREAD_FUNC(cond_free,(void)0,(cond))
-
-#define g_private_new(destructor) \
- G_USE_THREAD_FUNC_UNCOND(private_new,(destructor))
-#define g_private_get(private_key) \
- G_USE_THREAD_FUNC(private_get,((gpointer)private_key),(private_key))
-#define g_private_set(private_key,value) \
- G_USE_THREAD_FUNC(private_set,(void)(private_key=(GPrivate *)(value)), \
- (private_key,value))
-
-/* GStaticMutex'es can be statically initialized with the value
+ * recursive in general, don't rely on that
+ */
+#define g_thread_supported() (g_threads_got_initialized)
+#define g_mutex_new() G_THREAD_UF (mutex_new, ())
+#define g_mutex_lock(mutex) G_THREAD_CF (mutex_lock, (void)0, (mutex))
+#define g_mutex_trylock(mutex) G_THREAD_CF (mutex_trylock, TRUE, (mutex))
+#define g_mutex_unlock(mutex) G_THREAD_CF (mutex_unlock, (void)0, (mutex))
+#define g_mutex_free(mutex) G_THREAD_CF (mutex_free, (void)0, (mutex))
+#define g_cond_new() G_THREAD_UF (cond_new, ())
+#define g_cond_signal(cond) G_THREAD_CF (cond_signal, (void)0, (cond))
+#define g_cond_broadcast(cond) G_THREAD_CF (cond_broadcast, (void)0, (cond))
+#define g_cond_wait(cond, mutex) G_THREAD_CF (cond_wait, (void)0, (cond, \
+ mutex))
+#define g_cond_free(cond) G_THREAD_CF (cond_free, (void)0, (cond))
+#define g_cond_timed_wait(cond, mutex, abs_time) G_THREAD_CF (cond_timed_wait, \
+ TRUE, \
+ (cond, mutex, \
+ abs_time))
+#define g_private_new(destructor) G_THREAD_UF (private_new, (destructor))
+#define g_private_get(private_key) G_THREAD_CF (private_get, \
+ ((gpointer)private_key), \
+ (private_key))
+#define g_private_set(private_key, value) G_THREAD_CF (private_set, \
+ (void) (private_key = \
+ (GPrivate*) (value)), \
+ (private_key, value))
+/* GStaticMutexes can be statically initialized with the value
* G_STATIC_MUTEX_INIT, and then they can directly be used, that is
* much easier, than having to explicitly allocate the mutex before
- * use */
+ * use
+ */
#define g_static_mutex_lock(mutex) \
- g_mutex_lock( g_static_mutex_get_mutex(mutex) )
+ g_mutex_lock (g_static_mutex_get_mutex (mutex))
#define g_static_mutex_trylock(mutex) \
- g_mutex_trylock( g_static_mutex_get_mutex(mutex) )
+ g_mutex_trylock (g_static_mutex_get_mutex (mutex))
#define g_static_mutex_unlock(mutex) \
- g_mutex_unlock( g_static_mutex_get_mutex(mutex) )
-
+ g_mutex_unlock (g_static_mutex_get_mutex (mutex))
struct _GStaticPrivate
{
guint index;
};
-
#define G_STATIC_PRIVATE_INIT { 0 }
-
-gpointer g_static_private_get (GStaticPrivate* private_key);
-void g_static_private_set (GStaticPrivate *private_key,
- gpointer data,
- GDestroyNotify notify);
-
-/* these are some convenience macros, for using StaticMutex'es, you
- * define them by G_LOCK_DEFINE(name), where name could for example be the
- * name of the protected varibale, and you (un)lock them with
- * g_(un)lock(name) */
-#define g_lock_name(name) (name ## _lock)
-#define G_LOCK_DEFINE(name) GStaticMutex g_lock_name(name)=G_STATIC_MUTEX_INIT
-
-#ifdef G_DEBUG_LOCKS
-#define g_lock(name) G_STMT_START{ \
- g_log (G_LOG_DOMAIN, \
- G_LOG_LEVEL_MESSAGE, \
- "file %s: line %d (%s): locking: %s ", \
- __FILE__, \
- __LINE__, \
- __PRETTY_FUNCTION__, \
- #name); \
- g_static_mutex_lock(g_lock_name(name)); \
+gpointer g_static_private_get (GStaticPrivate *private_key);
+void g_static_private_set (GStaticPrivate *private_key,
+ gpointer data,
+ GDestroyNotify notify);
+
+/* these are some convenience macros that expand to nothing if GLib was
+ * configured with --deisable-threads. for using StaticMutexes, you
+ * declare them with G_LOCK_DECLARE_STATIC (name) or G_LOCK_DECLARE (name)
+ * if you need to export the mutex. name is a unique identifier for the
+ * protected varibale or code portion. locking, testing and unlocking of
+ * such mutexes can be done with G_LOCK(), G_UNLOCK() and G_TRYLOCK()
+ * respectively.
+ */
+extern gboolean glib_dummy_decl;
+#define G_LOCK_NAME(name) (g__ ## name ## _lock)
+#ifdef G_THREADS_ENABLED
+# define G_LOCK_DECLARE_STATIC(name) static G_LOCK_DECLARE (name)
+# define G_LOCK_DECLARE(name) \
+ GStaticMutex G_LOCK_NAME (name) = G_STATIC_MUTEX_INIT
+
+# ifdef G_DEBUG_LOCKS
+# define G_LOCK(name) G_STMT_START{ \
+ g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \
+ "file %s: line %d (%s): locking: %s ", \
+ __FILE__, __LINE__, G_GNUC_PRETTY_FUNCTION, \
+ #name); \
+ g_static_mutex_lock (G_LOCK_NAME (name)); \
}G_STMT_END
-#define g_unlock(name) G_STMT_START{ \
- g_log (G_LOG_DOMAIN, \
- G_LOG_LEVEL_MESSAGE, \
- "file %s: line %d (%s): unlocking: %s ", \
- __FILE__, \
- __LINE__, \
- __PRETTY_FUNCTION__, \
- #name); \
- g_static_mutex_unlock(g_lock_name(name)); \
+# define G_UNLOCK(name) G_STMT_START{ \
+ g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \
+ "file %s: line %d (%s): unlocking: %s ", \
+ __FILE__, __LINE__, G_GNUC_PRETTY_FUNCTION, \
+ #name); \
+ g_static_mutex_unlock (G_LOCK_NAME (name)); \
}G_STMT_END
-#define g_trylock(name) G_STMT_START{ \
- g_log (G_LOG_DOMAIN, \
- G_LOG_LEVEL_MESSAGE, \
- "file %s: line %d (%s): try locking: %s ", \
- __FILE__, \
- __LINE__, \
- __PRETTY_FUNCTION__, \
- #name); \
- }G_STMT_END, g_static_mutex_trylock(g_lock_name(name))
-#else /* !G_DEBUG_LOCKS */
-#define g_lock(name) g_static_mutex_lock(g_lock_name(name))
-#define g_unlock(name) g_static_mutex_unlock(g_lock_name(name))
-#define g_trylock(name) g_static_mutex_trylock(g_lock_name(name))
-#endif
+# define G_TRYLOCK(name) G_STMT_START{ \
+ g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \
+ "file %s: line %d (%s): try locking: %s ", \
+ __FILE__, __LINE__, G_GNUC_PRETTY_FUNCTION, \
+ #name); \
+ }G_STMT_END, g_static_mutex_trylock (G_LOCK_NAME (name))
+# else /* !G_DEBUG_LOCKS */
+# define G_LOCK(name) g_static_mutex_lock (G_LOCK_NAME (name))
+# define G_UNLOCK(name) g_static_mutex_unlock (G_LOCK_NAME (name))
+# define G_TRYLOCK(name) g_static_mutex_trylock (G_LOCK_NAME (name))
+# endif /* !G_DEBUG_LOCKS */
+#else /* !G_THREADS_ENABLED */
+# define G_LOCK_DECLARE_STATIC(name) extern gboolean glib_dummy_decl
+# define G_LOCK_DECLARE(name) extern gboolean glib_dummy_decl
+# define G_LOCK(name)
+# define G_UNLOCK(name)
+# define G_TRYLOCK(name) (FALSE)
+#endif /* !G_THREADS_ENABLED */
#ifdef __cplusplus
}
gint len);
static GMemChunk *array_mem_chunk = NULL;
-static G_LOCK_DEFINE(array_mem_chunk);
+G_LOCK_DECLARE_STATIC (array_mem_chunk);
GArray*
g_array_new (gboolean zero_terminated,
{
GRealArray *array;
- g_lock (array_mem_chunk);
+ G_LOCK (array_mem_chunk);
if (!array_mem_chunk)
array_mem_chunk = g_mem_chunk_new ("array mem chunk",
sizeof (GRealArray),
1024, G_ALLOC_AND_FREE);
array = g_chunk_new (GRealArray, array_mem_chunk);
- g_unlock (array_mem_chunk);
+ G_UNLOCK (array_mem_chunk);
array->data = NULL;
array->len = 0;
if (free_segment)
g_free (array->data);
- g_lock (array_mem_chunk);
+ G_LOCK (array_mem_chunk);
g_mem_chunk_free (array_mem_chunk, array);
- g_unlock (array_mem_chunk);
+ G_UNLOCK (array_mem_chunk);
}
GArray*
gint len);
static GMemChunk *ptr_array_mem_chunk = NULL;
-static G_LOCK_DEFINE(ptr_array_mem_chunk);
+G_LOCK_DECLARE_STATIC (ptr_array_mem_chunk);
GPtrArray*
{
GRealPtrArray *array;
- g_lock (ptr_array_mem_chunk);
+ G_LOCK (ptr_array_mem_chunk);
if (!ptr_array_mem_chunk)
ptr_array_mem_chunk = g_mem_chunk_new ("array mem chunk",
sizeof (GRealPtrArray),
1024, G_ALLOC_AND_FREE);
array = g_chunk_new (GRealPtrArray, ptr_array_mem_chunk);
- g_unlock (ptr_array_mem_chunk);
+ G_UNLOCK (ptr_array_mem_chunk);
array->pdata = NULL;
array->len = 0;
if (free_segment)
g_free (array->pdata);
- g_lock (ptr_array_mem_chunk);
+ G_LOCK (ptr_array_mem_chunk);
g_mem_chunk_free (ptr_array_mem_chunk, array);
- g_unlock (ptr_array_mem_chunk);
+ G_UNLOCK (ptr_array_mem_chunk);
}
static void
static GMemChunk *node_mem_chunk = NULL;
-static G_LOCK_DEFINE(node_mem_chunk);
+G_LOCK_DECLARE_STATIC (node_mem_chunk);
GCache*
g_cache_new (GCacheNewFunc value_new_func,
{
GCacheNode *node;
- g_lock (node_mem_chunk);
+ G_LOCK (node_mem_chunk);
if (!node_mem_chunk)
node_mem_chunk = g_mem_chunk_new ("cache node mem chunk", sizeof (GCacheNode),
1024, G_ALLOC_AND_FREE);
node = g_chunk_new (GCacheNode, node_mem_chunk);
- g_unlock (node_mem_chunk);
+ G_UNLOCK (node_mem_chunk);
node->value = value;
node->ref_count = 1;
static void
g_cache_node_destroy (GCacheNode *node)
{
- g_lock (node_mem_chunk);
+ G_LOCK (node_mem_chunk);
g_mem_chunk_free (node_mem_chunk, node);
- g_unlock (node_mem_chunk);
+ G_UNLOCK (node_mem_chunk);
}
/* --- variables --- */
-static G_LOCK_DEFINE(g_dataset_global);
+G_LOCK_DECLARE_STATIC (g_dataset_global);
static GHashTable *g_dataset_location_ht = NULL;
static GDataset *g_dataset_cached = NULL; /* should this be
threadspecific? */
static GData *g_data_cache = NULL;
static guint g_data_cache_length = 0;
-static G_LOCK_DEFINE(g_quark_global);
+G_LOCK_DECLARE_STATIC (g_quark_global);
static GHashTable *g_quark_ht = NULL;
static gchar **g_quarks = NULL;
static GQuark g_quark_seq_id = 0;
{
g_return_if_fail (datalist != NULL);
- g_lock (g_dataset_global);
+ G_LOCK (g_dataset_global);
if (!g_dataset_location_ht)
g_data_initialize ();
while (*datalist)
g_datalist_clear_i (datalist);
- g_unlock (g_dataset_global);
+ G_UNLOCK (g_dataset_global);
}
/* HOLDS: g_dataset_global_lock */
{
g_return_if_fail (dataset_location != NULL);
- g_lock (g_dataset_global);
+ G_LOCK (g_dataset_global);
if (g_dataset_location_ht)
{
register GDataset *dataset;
if (dataset)
g_dataset_destroy_internal (dataset);
}
- g_unlock (g_dataset_global);
+ G_UNLOCK (g_dataset_global);
}
/* HOLDS: g_dataset_global_lock */
return;
}
- g_lock (g_dataset_global);
+ G_LOCK (g_dataset_global);
if (!g_dataset_location_ht)
g_data_initialize ();
}
g_data_set_internal (&dataset->datalist, key_id, data, destroy_func, dataset);
- g_unlock (g_dataset_global);
+ G_UNLOCK (g_dataset_global);
}
void
return;
}
- g_lock (g_dataset_global);
+ G_LOCK (g_dataset_global);
if (!g_dataset_location_ht)
g_data_initialize ();
g_data_set_internal (datalist, key_id, data, destroy_func, NULL);
- g_unlock (g_dataset_global);
+ G_UNLOCK (g_dataset_global);
}
void
{
g_return_if_fail (dataset_location != NULL);
- g_lock (g_dataset_global);
+ G_LOCK (g_dataset_global);
if (key_id && g_dataset_location_ht)
{
GDataset *dataset;
if (dataset)
g_data_set_internal (&dataset->datalist, key_id, NULL, (GDestroyNotify) 42, dataset);
}
- g_unlock (g_dataset_global);
+ G_UNLOCK (g_dataset_global);
}
void
{
g_return_if_fail (datalist != NULL);
- g_lock (g_dataset_global);
+ G_LOCK (g_dataset_global);
if (key_id && g_dataset_location_ht)
g_data_set_internal (datalist, key_id, NULL, (GDestroyNotify) 42, NULL);
- g_unlock (g_dataset_global);
+ G_UNLOCK (g_dataset_global);
}
gpointer
{
g_return_val_if_fail (dataset_location != NULL, NULL);
- g_lock (g_dataset_global);
+ G_LOCK (g_dataset_global);
if (key_id && g_dataset_location_ht)
{
register GDataset *dataset;
for (list = dataset->datalist; list; list = list->next)
if (list->id == key_id)
{
- g_unlock (g_dataset_global);
+ G_UNLOCK (g_dataset_global);
return list->data;
}
}
}
- g_unlock (g_dataset_global);
+ G_UNLOCK (g_dataset_global);
return NULL;
}
g_return_if_fail (dataset_location != NULL);
g_return_if_fail (func != NULL);
- g_lock (g_dataset_global);
+ G_LOCK (g_dataset_global);
if (g_dataset_location_ht)
{
dataset = g_dataset_lookup (dataset_location);
- g_unlock (g_dataset_global);
+ G_UNLOCK (g_dataset_global);
if (dataset)
{
register GData *list;
}
else
{
- g_unlock (g_dataset_global);
+ G_UNLOCK (g_dataset_global);
}
}
GQuark quark = 0;
g_return_val_if_fail (string != NULL, 0);
- g_lock (g_quark_global);
+ G_LOCK (g_quark_global);
if (g_quark_ht)
quark = GPOINTER_TO_UINT (g_hash_table_lookup (g_quark_ht, string));
- g_unlock (g_quark_global);
+ G_UNLOCK (g_quark_global);
return quark;
}
g_return_val_if_fail (string != NULL, 0);
- g_lock (g_quark_global);
+ G_LOCK (g_quark_global);
if (g_quark_ht)
quark = (gulong) g_hash_table_lookup (g_quark_ht, string);
else
if (!quark)
quark = g_quark_new (g_strdup (string));
- g_unlock (g_quark_global);
+ G_UNLOCK (g_quark_global);
return quark;
}
g_return_val_if_fail (string != NULL, 0);
- g_lock (g_quark_global);
+ G_LOCK (g_quark_global);
if (g_quark_ht)
quark = (gulong) g_hash_table_lookup (g_quark_ht, string);
else
if (!quark)
quark = g_quark_new ((gchar*) string);
- g_unlock (g_quark_global);
+ G_UNLOCK (g_quark_global);
return quark;
}
g_quark_to_string (GQuark quark)
{
gchar* result = NULL;
- g_lock (g_quark_global);
+ G_LOCK (g_quark_global);
if (quark > 0 && quark <= g_quark_seq_id)
result = g_quarks[quark - 1];
- g_unlock (g_quark_global);
+ G_UNLOCK (g_quark_global);
return result;
}
memset (d, 0x0, ndates*sizeof (GDate));
}
-static G_LOCK_DEFINE(g_date_global);
+G_LOCK_DECLARE_STATIC (g_date_global);
/* These are for the parser, output to the user should use *
* g_date_strftime () - this creates more never-freed memory to annoy
/* set invalid */
g_date_clear (d, 1);
- g_lock (g_date_global);
+ G_LOCK (g_date_global);
g_date_prepare_to_parse (str, &pt);
if (pt.num_ints == 4)
{
- g_unlock (g_date_global);
+ G_UNLOCK (g_date_global);
return; /* presumably a typo; bail out. */
}
else
g_message ("Rejected DMY %u %u %u", day, m, y);
#endif
- g_unlock (g_date_global);
+ G_UNLOCK (g_date_global);
}
void
static void g_hash_nodes_destroy (GHashNode *hash_node);
-static G_LOCK_DEFINE(g_hash_global);
+G_LOCK_DECLARE_STATIC (g_hash_global);
static GMemChunk *node_mem_chunk = NULL;
static GHashNode *node_free_list = NULL;
{
GHashNode *hash_node;
- g_lock (g_hash_global);
+ G_LOCK (g_hash_global);
if (node_free_list)
{
hash_node = node_free_list;
hash_node = g_chunk_new (GHashNode, node_mem_chunk);
}
- g_unlock (g_hash_global);
+ G_UNLOCK (g_hash_global);
hash_node->key = key;
hash_node->value = value;
static void
g_hash_node_destroy (GHashNode *hash_node)
{
- g_lock (g_hash_global);
+ G_LOCK (g_hash_global);
hash_node->next = node_free_list;
node_free_list = hash_node;
- g_unlock (g_hash_global);
+ G_UNLOCK (g_hash_global);
}
static void
while (node->next)
node = node->next;
- g_lock (g_hash_global);
+ G_LOCK (g_hash_global);
node->next = node_free_list;
node_free_list = hash_node;
- g_unlock (g_hash_global);
+ G_UNLOCK (g_hash_global);
}
} G_STMT_END
-/* Completion */
+/* GCompletion
+ */
struct _GCompletion
{
void g_completion_free (GCompletion* cmp);
-
-
-/* Date calculations (not time for now, to be resolved). These are a
+/* GDate
+ *
+ * Date calculations (not time for now, to be resolved). These are a
* mutant combination of Steffen Beyer's DateCalc routines
* (http://www.perl.com/CPAN/authors/id/STBEY/) and Jon Trowbridge's
* date routines (written for in-house software). Written by Havoc
* Pennington <hp@pobox.com>
*/
-/* this enum is used to specify order of appearance in parsed date
- * strings
- */
+typedef guint16 GDateYear;
+typedef guint8 GDateDay; /* day of the month */
+typedef struct _GDate GDate;
+/* make struct tm known without having to include time.h */
+struct tm;
-typedef enum {
+/* enum used to specify order of appearance in parsed date strings */
+typedef enum
+{
G_DATE_DAY = 0,
G_DATE_MONTH = 1,
G_DATE_YEAR = 2
} GDateDMY;
-/* These other types specify the actual values. */
-
-typedef enum {
+/* actual week and month values */
+typedef enum
+{
G_DATE_BAD_WEEKDAY = 0,
G_DATE_MONDAY = 1,
G_DATE_TUESDAY = 2,
G_DATE_SATURDAY = 6,
G_DATE_SUNDAY = 7
} GDateWeekday;
-
-typedef enum {
+typedef enum
+{
G_DATE_BAD_MONTH = 0,
G_DATE_JANUARY = 1,
G_DATE_FEBRUARY = 2,
G_DATE_DECEMBER = 12
} GDateMonth;
-typedef guint16 GDateYear;
-typedef guint8 GDateDay; /* day of the month */
-
#define G_DATE_BAD_JULIAN 0U
#define G_DATE_BAD_DAY 0U
#define G_DATE_BAD_YEAR 0U
-typedef struct _GDate GDate;
-
/* Note: directly manipulating structs is generally a bad idea, but
* in this case it's an *incredibly* bad idea, because all or part
* of this struct can be invalid at any given time. Use the functions,
* or you will get hosed, I promise.
*/
-
-struct _GDate {
+struct _GDate
+{
guint julian_days : 32; /* julian days representation - we use a
* bitfield hoping that 64 bit platforms
* will pack this whole struct in one big
guint year : 16;
};
-/* _new with no args returns an invalid date, you then have to _set() stuff
+/* g_date_new() returns an invalid date, you then have to _set() stuff
* to get a usable object. You can also allocate a GDate statically,
* then call g_date_clear() to initialize.
*/
-
GDate* g_date_new (void);
-GDate* g_date_new_dmy (GDateDay d,
- GDateMonth m,
- GDateYear y);
+GDate* g_date_new_dmy (GDateDay day,
+ GDateMonth month,
+ GDateYear year);
GDate* g_date_new_julian (guint32 julian_day);
-void g_date_free (GDate *d);
+void g_date_free (GDate *date);
/* check g_date_valid() after doing an operation that might fail, like
* _parse. Almost all g_date operations are undefined on invalid
* dates (the exceptions are the mutators, since you need those to
* return to validity).
*/
+gboolean g_date_valid (GDate *date);
+gboolean g_date_valid_day (GDateDay day);
+gboolean g_date_valid_month (GDateMonth month);
+gboolean g_date_valid_year (GDateYear year);
+gboolean g_date_valid_weekday (GDateWeekday weekday);
+gboolean g_date_valid_julian (guint32 julian_date);
+gboolean g_date_valid_dmy (GDateDay day,
+ GDateMonth month,
+ GDateYear year);
-gboolean g_date_valid (GDate *d);
-gboolean g_date_valid_day (GDateDay d);
-gboolean g_date_valid_month (GDateMonth m);
-gboolean g_date_valid_year (GDateYear y);
-gboolean g_date_valid_weekday (GDateWeekday w);
-gboolean g_date_valid_julian (guint32 j);
-gboolean g_date_valid_dmy (GDateDay d,
- GDateMonth m,
- GDateYear y);
-
-GDateWeekday g_date_weekday (GDate *d);
-GDateMonth g_date_month (GDate *d);
-GDateYear g_date_year (GDate *d);
-GDateDay g_date_day (GDate *d);
-guint32 g_date_julian (GDate *d);
-
-guint g_date_day_of_year (GDate *d);
+GDateWeekday g_date_weekday (GDate *date);
+GDateMonth g_date_month (GDate *date);
+GDateYear g_date_year (GDate *date);
+GDateDay g_date_day (GDate *date);
+guint32 g_date_julian (GDate *date);
+guint g_date_day_of_year (GDate *date);
/* First monday/sunday is the start of week 1; if we haven't reached
- * that day, return 0. These are not ISO weeks of the year; that
- * routine should be added.
+ * that day, return 0. These are not ISO weeks of the year; that
+ * routine needs to be added.
+ * these functions return the number of weeks, starting on the
+ * corrsponding day
*/
-
-guint g_date_monday_week_of_year (GDate *d); /* # weeks, starting on Monday */
-guint g_date_sunday_week_of_year (GDate *d); /* # weeks, starting on Sunday */
+guint g_date_monday_week_of_year (GDate *date);
+guint g_date_sunday_week_of_year (GDate *date);
/* If you create a static date struct you need to clear it to get it
* in a sane state before use. You can clear a whole array at
* once with the ndates argument.
*/
-
-void g_date_clear (GDate *d,
- guint ndates);
+void g_date_clear (GDate *date,
+ guint n_dates);
/* The parse routine is meant for dates typed in by a user, so it
* permits many formats but tries to catch common typos. If your data
* needs to be strictly validated, it is not an appropriate function.
*/
-
-void g_date_set_parse (GDate *d,
+void g_date_set_parse (GDate *date,
const gchar *str);
-
-void g_date_set_time (GDate *d,
+void g_date_set_time (GDate *date,
GTime time);
-
-void g_date_set_month (GDate *d,
- GDateMonth m);
-void g_date_set_day (GDate *d,
+void g_date_set_month (GDate *date,
+ GDateMonth month);
+void g_date_set_day (GDate *date,
GDateDay day);
-void g_date_set_year (GDate *d,
- GDateYear y);
-void g_date_set_dmy (GDate *d,
+void g_date_set_year (GDate *date,
+ GDateYear year);
+void g_date_set_dmy (GDate *date,
GDateDay day,
- GDateMonth m,
+ GDateMonth month,
GDateYear y);
-
-void g_date_set_julian (GDate *d,
- guint32 j);
-
-gboolean g_date_is_first_of_month (GDate *d);
-gboolean g_date_is_last_of_month (GDate *d);
-
+void g_date_set_julian (GDate *date,
+ guint32 julian_date);
+gboolean g_date_is_first_of_month (GDate *date);
+gboolean g_date_is_last_of_month (GDate *date);
/* To go forward by some number of weeks just go forward weeks*7 days */
-void g_date_add_days (GDate *d,
- guint ndays);
-void g_date_subtract_days (GDate *d,
- guint ndays);
+void g_date_add_days (GDate *date,
+ guint n_days);
+void g_date_subtract_days (GDate *date,
+ guint n_days);
/* If you add/sub months while day > 28, the day might change */
-void g_date_add_months (GDate *d,
- guint nmonths);
-void g_date_subtract_months (GDate *d,
- guint nmonths);
+void g_date_add_months (GDate *date,
+ guint n_months);
+void g_date_subtract_months (GDate *date,
+ guint n_months);
/* If it's feb 29, changing years can move you to the 28th */
-void g_date_add_years (GDate *d,
- guint nyears);
-void g_date_subtract_years (GDate *d,
- guint nyears);
-
+void g_date_add_years (GDate *date,
+ guint n_years);
+void g_date_subtract_years (GDate *date,
+ guint n_years);
gboolean g_date_is_leap_year (GDateYear year);
guint8 g_date_days_in_month (GDateMonth month,
GDateYear year);
/* qsort-friendly (with a cast...) */
gint g_date_compare (GDate *lhs,
GDate *rhs);
-
-/* make struct tm known without having to include time.h */
-struct tm;
-
-void g_date_to_struct_tm (GDate *d,
+void g_date_to_struct_tm (GDate *date,
struct tm *tm);
/* Just like strftime() except you can only use date-related formats.
gsize g_date_strftime (gchar *s,
gsize slen,
const gchar *format,
- GDate *d);
-
-
+ GDate *date);
-/* GRelation: Indexed Relations. Imagine a really simple table in a
+/* GRelation
+ *
+ * Indexed Relations. Imagine a really simple table in a
* database. Relations are not ordered. This data type is meant for
* maintaining a N-way mapping.
*
guint g_spaced_primes_closest (guint num);
-/* IO Channels
+/* GIOChannel
*/
typedef struct _GIOFuncs GIOFuncs;
-
-typedef enum {
+typedef enum
+{
G_IO_ERROR_NONE,
G_IO_ERROR_AGAIN,
G_IO_ERROR_INVAL,
G_IO_ERROR_UNKNOWN
} GIOError;
-
-typedef enum {
+typedef enum
+{
G_SEEK_CUR,
G_SEEK_SET,
G_SEEK_END
} GSeekType;
-
-typedef enum {
+typedef enum
+{
G_IO_IN
#ifdef POLLIN
= POLLIN
#endif
- ,G_IO_OUT
+ , G_IO_OUT
#ifdef POLLOUT
= POLLOUT
#endif
- ,G_IO_PRI
+ , G_IO_PRI
#ifdef POLLPRI
= POLLPRI
#endif
- ,G_IO_ERR
+ , G_IO_ERR
#ifdef POLLERR
= POLLERR
#endif
- ,G_IO_HUP
+ , G_IO_HUP
#ifdef POLLHUP
= POLLHUP
#endif
- ,G_IO_NVAL
+ , G_IO_NVAL
#ifdef POLLNVAL
= POLLNVAL
#endif
typedef gboolean (*GIOFunc) (GIOChannel *source,
GIOCondition condition,
gpointer data);
-
-struct _GIOFuncs {
- GIOError (*io_read) (GIOChannel *channel,
- gchar *buf,
- guint count,
- guint *bytes_read);
- GIOError (*io_write) (GIOChannel *channel,
- gchar *buf,
- guint count,
- guint *bytes_written);
- GIOError (*io_seek) (GIOChannel *channel,
- gint offset,
- GSeekType type);
- void (*io_close) (GIOChannel *channel);
- guint (*io_add_watch) (GIOChannel *channel,
- gint priority,
- GIOCondition condition,
- GIOFunc func,
- gpointer user_data,
- GDestroyNotify notify);
- void (*io_free) (GIOChannel *channel);
+struct _GIOFuncs
+{
+ GIOError (*io_read) (GIOChannel *channel,
+ gchar *buf,
+ guint count,
+ guint *bytes_read);
+ GIOError (*io_write) (GIOChannel *channel,
+ gchar *buf,
+ guint count,
+ guint *bytes_written);
+ GIOError (*io_seek) (GIOChannel *channel,
+ gint offset,
+ GSeekType type);
+ void (*io_close) (GIOChannel *channel);
+ guint (*io_add_watch) (GIOChannel *channel,
+ gint priority,
+ GIOCondition condition,
+ GIOFunc func,
+ gpointer user_data,
+ GDestroyNotify notify);
+ void (*io_free) (GIOChannel *channel);
};
void g_io_channel_init (GIOChannel *channel);
GIOFunc func,
gpointer user_data);
-/* Main loop */
-
-typedef struct _GTimeVal GTimeVal;
-typedef struct _GSourceFuncs GSourceFuncs;
-typedef struct _GMainLoop GMainLoop; /* Opaque */
+/* Main loop
+ */
+typedef struct _GTimeVal GTimeVal;
+typedef struct _GSourceFuncs GSourceFuncs;
+typedef struct _GMainLoop GMainLoop; /* Opaque */
-struct _GTimeVal {
+struct _GTimeVal
+{
glong tv_sec;
glong tv_usec;
};
-
-struct _GSourceFuncs {
+struct _GSourceFuncs
+{
gboolean (*prepare) (gpointer source_data,
GTimeVal *current_time,
gint *timeout);
GDestroyNotify destroy;
};
-typedef gboolean (*GSourceFunc) (gpointer data);
+typedef gboolean (*GSourceFunc) (gpointer data);
/* Hooks for adding to the main loop */
-
guint g_source_add (gint priority,
gboolean can_recurse,
GSourceFuncs *funcs,
void g_source_remove_by_user_data (gpointer user_data);
void g_source_remove_by_source_data (gpointer source_data);
-
-void g_get_current_time (GTimeVal *result);
+void g_get_current_time (GTimeVal *result);
/* Running the main loop */
-
-GMainLoop *g_main_new (void);
-void g_main_run (GMainLoop *loop);
-void g_main_quit (GMainLoop *loop);
-void g_main_destroy (GMainLoop *loop);
+GMainLoop* g_main_new (void);
+void g_main_run (GMainLoop *loop);
+void g_main_quit (GMainLoop *loop);
+void g_main_destroy (GMainLoop *loop);
/* Run a single iteration of the mainloop. If block is FALSE,
* will never block
*/
-gboolean g_main_iteration (gboolean block);
+gboolean g_main_iteration (gboolean may_block);
-/* See if any events are pending
- */
-gboolean g_main_pending ();
+/* See if any events are pending */
+gboolean g_main_pending (void);
/* Idles and timeouts */
-
-guint g_timeout_add_full (gint priority,
- guint interval,
- GSourceFunc function,
- gpointer data,
- GDestroyNotify notify);
-guint g_timeout_add (guint interval,
- GSourceFunc function,
- gpointer data);
-
-guint g_idle_add (GSourceFunc function,
- gpointer data);
-guint g_idle_add_full (gint priority,
- GSourceFunc function,
- gpointer data,
- GDestroyNotify destroy);
-
-/* Unix-specific IO and main loop calls */
+guint g_timeout_add_full (gint priority,
+ guint interval,
+ GSourceFunc function,
+ gpointer data,
+ GDestroyNotify notify);
+guint g_timeout_add (guint interval,
+ GSourceFunc function,
+ gpointer data);
+guint g_idle_add (GSourceFunc function,
+ gpointer data);
+guint g_idle_add_full (gint priority,
+ GSourceFunc function,
+ gpointer data,
+ GDestroyNotify destroy);
+
+/* GPollFD
+ *
+ * Unix-specific IO and main loop calls
+ */
typedef struct _GPollFD GPollFD;
-
-struct _GPollFD {
- gint fd;
- gushort events;
- gushort revents;
+typedef gint (*GPollFunc) (GPollFD *ufds,
+ guint nfsd,
+ gint timeout);
+struct _GPollFD
+{
+ gint fd;
+ gushort events;
+ gushort revents;
};
-typedef gint (*GPollFunc) (GPollFD *ufds, guint nfsd, gint timeout);
-
void g_main_poll_add (gint priority,
GPollFD *fd);
void g_main_poll_remove (GPollFD *fd);
-
void g_main_set_poll_func (GPollFunc func);
-
-GIOChannel *g_io_channel_unix_new (int fd);
+GIOChannel* g_io_channel_unix_new (int fd);
gint g_io_channel_unix_get_fd (GIOChannel *channel);
-#if 0 /* old IO Channels */
+/* old IO Channels */
+#if 0
/* IO Channels.
* These are used for plug-in communication in the GIMP, for instance.
* On Unix, it's simply an encapsulated file descriptor (a pipe).
*/
#endif
};
-
GIOChannel *g_iochannel_new (gint fd);
void g_iochannel_free (GIOChannel *channel);
void g_iochannel_close_and_free (GIOChannel *channel);
#ifndef NATIVE_WIN32
# define g_iochannel_wakeup_peer(channel) G_STMT_START { } G_STMT_END
#endif
+#endif /* old IO Channels */
-#endif /* old IO Channels */
/* Windows emulation stubs for common unix functions
*/
#ifdef NATIVE_WIN32
-
-#define MAXPATHLEN 1024
-
-#ifdef _MSC_VER
+# define MAXPATHLEN 1024
+# ifdef _MSC_VER
typedef int pid_t;
/* These POSIXish functions are available in the Microsoft C library
* For some functions, we provide emulators in glib, which are prefixed
* with gwin_.
*/
-#define getcwd _getcwd
-#define getpid _getpid
-#define access _access
-#define open _open
-#define read _read
-#define write _write
-#define lseek _lseek
-#define close _close
-#define pipe(phandles) _pipe (phandles, 4096, _O_BINARY)
-#define popen _popen
-#define pclose _pclose
-#define fdopen _fdopen
-#define ftruncate(fd, size) gwin_ftruncate (fd, size)
-#define opendir gwin_opendir
-#define readdir gwin_readdir
-#define rewinddir gwin_rewinddir
-#define closedir gwin_closedir
-
-#define NAME_MAX 255
-
+# define getcwd _getcwd
+# define getpid _getpid
+# define access _access
+# define open _open
+# define read _read
+# define write _write
+# define lseek _lseek
+# define close _close
+# define pipe(phandles) _pipe (phandles, 4096, _O_BINARY)
+# define popen _popen
+# define pclose _pclose
+# define fdopen _fdopen
+# define ftruncate(fd, size) gwin_ftruncate (fd, size)
+# define opendir gwin_opendir
+# define readdir gwin_readdir
+# define rewinddir gwin_rewinddir
+# define closedir gwin_closedir
+# define NAME_MAX 255
struct DIR
{
gchar *dir_name;
-
gboolean just_opened;
guint find_file_handle;
gpointer find_file_data;
{
gchar d_name[NAME_MAX + 1];
};
-
/* emulation functions */
extern int gwin_ftruncate (gint f,
guint size);
struct dirent* gwin_readdir (DIR *dir);
void gwin_rewinddir (DIR *dir);
gint gwin_closedir (DIR *dir);
+# endif /* _MSC_VER */
+#endif /* NATIVE_WIN32 */
-#endif /* _MSC_VER */
-
-#endif /* NATIVE_WIN32 */
-
-/* functions for thread support for glib. */
-
-typedef struct _GMutex GMutex;
-typedef struct _GCond GCond;
-typedef struct _GPrivate GPrivate;
-typedef struct _GStaticPrivate GStaticPrivate;
+/* GLib Thread support
+ */
+typedef struct _GMutex GMutex;
+typedef struct _GCond GCond;
+typedef struct _GPrivate GPrivate;
+typedef struct _GStaticPrivate GStaticPrivate;
typedef struct _GThreadFunctions GThreadFunctions;
struct _GThreadFunctions
{
GMutex* (*mutex_new) (void);
- void (*mutex_lock) (GMutex* mutex);
- gboolean (*mutex_trylock) (GMutex* mutex);
- void (*mutex_unlock) (GMutex* mutex);
- void (*mutex_free) (GMutex* mutex);
+ void (*mutex_lock) (GMutex *mutex);
+ gboolean (*mutex_trylock) (GMutex *mutex);
+ void (*mutex_unlock) (GMutex *mutex);
+ void (*mutex_free) (GMutex *mutex);
GCond* (*cond_new) (void);
- void (*cond_signal) (GCond* cond);
- void (*cond_broadcast) (GCond* cond);
- void (*cond_wait) (GCond* cond, GMutex* mutex);
- gboolean (*cond_timed_wait) (GCond* cond, GMutex* mutex,
- GTimeVal *end_time);
- void (*cond_free) (GCond* cond);
- GPrivate* (*private_new) (GDestroyNotify destructor);
- gpointer (*private_get) (GPrivate* private_key);
- void (*private_set) (GPrivate* private_key, gpointer value);
+ void (*cond_signal) (GCond *cond);
+ void (*cond_broadcast) (GCond *cond);
+ void (*cond_wait) (GCond *cond,
+ GMutex *mutex);
+ gboolean (*cond_timed_wait) (GCond *cond,
+ GMutex *mutex,
+ GTimeVal *end_time);
+ void (*cond_free) (GCond *cond);
+ GPrivate* (*private_new) (GDestroyNotify destructor);
+ gpointer (*private_get) (GPrivate *private_key);
+ void (*private_set) (GPrivate *private_key,
+ gpointer data);
};
-GUTILS_C_VAR GThreadFunctions g_thread_functions_for_glib_use;
-GUTILS_C_VAR gboolean g_thread_use_default_impl;
-GUTILS_C_VAR gboolean g_thread_supported;
+GUTILS_C_VAR GThreadFunctions g_thread_functions_for_glib_use;
+GUTILS_C_VAR gboolean g_thread_use_default_impl;
+GUTILS_C_VAR gboolean g_threads_got_initialized;
/* initializes the mutex/cond/private implementation for glib, might
* only be called once, and must not be called directly or indirectly
- * from another glib-function, e.g. as a callback. */
-void g_thread_init(GThreadFunctions* init);
-
-/* Internal functions for fallback static mutex implementation
- * Please don't use it directly
+ * from another glib-function, e.g. as a callback.
*/
-GMutex* g_static_mutex_get_mutex_impl(GMutex** mutex);
+void g_thread_init (GThreadFunctions *vtable);
-#define G_USE_THREAD_FUNC_UNCOND(name,arg) \
- (*g_thread_functions_for_glib_use.name)arg
-#define G_USE_THREAD_FUNC(name,fail,arg) \
- (g_thread_supported ? G_USE_THREAD_FUNC_UNCOND(name,arg) : (fail))
+/* internal function for fallback static mutex implementation */
+GMutex* g_static_mutex_get_mutex_impl (GMutex **mutex);
+/* shorthands for conditional and unconditional function calls */
+#define G_THREAD_UF(name, arglist) \
+ (*g_thread_functions_for_glib_use . name) arglist
+#define G_THREAD_CF(name, fail, arg) \
+ (g_thread_supported () ? G_THREAD_UF (name, arg) : (fail))
/* keep in mind, all those mutexes and static mutexes are not
- * recursive in general, don't rely on that */
-#define g_mutex_new() G_USE_THREAD_FUNC_UNCOND(mutex_new,())
-#define g_mutex_lock(mutex) G_USE_THREAD_FUNC(mutex_lock,(void)0,(mutex))
-#define g_mutex_trylock(mutex) G_USE_THREAD_FUNC(mutex_trylock,TRUE,(mutex))
-#define g_mutex_unlock(mutex) G_USE_THREAD_FUNC(mutex_unlock,(void)0,(mutex))
-#define g_mutex_free(mutex) G_USE_THREAD_FUNC(mutex_free,(void)0,(mutex))
-#define g_cond_new() G_USE_THREAD_FUNC_UNCOND(cond_new,())
-#define g_cond_signal(cond) G_USE_THREAD_FUNC(cond_signal,(void)0,(cond))
-#define g_cond_broadcast(cond) G_USE_THREAD_FUNC(cond_broadcast,(void)0,(cond))
-#define g_cond_wait(cond,mutex) G_USE_THREAD_FUNC(cond_wait,(void)0,(cond,mutex))
-#define g_cond_timed_wait(cond,mutex,abs_time) \
- G_USE_THREAD_FUNC(cond_timed_wait,TRUE,(cond,mutex,abs_time))
-#define g_cond_free(cond) G_USE_THREAD_FUNC(cond_free,(void)0,(cond))
-
-#define g_private_new(destructor) \
- G_USE_THREAD_FUNC_UNCOND(private_new,(destructor))
-#define g_private_get(private_key) \
- G_USE_THREAD_FUNC(private_get,((gpointer)private_key),(private_key))
-#define g_private_set(private_key,value) \
- G_USE_THREAD_FUNC(private_set,(void)(private_key=(GPrivate *)(value)), \
- (private_key,value))
-
-/* GStaticMutex'es can be statically initialized with the value
+ * recursive in general, don't rely on that
+ */
+#define g_thread_supported() (g_threads_got_initialized)
+#define g_mutex_new() G_THREAD_UF (mutex_new, ())
+#define g_mutex_lock(mutex) G_THREAD_CF (mutex_lock, (void)0, (mutex))
+#define g_mutex_trylock(mutex) G_THREAD_CF (mutex_trylock, TRUE, (mutex))
+#define g_mutex_unlock(mutex) G_THREAD_CF (mutex_unlock, (void)0, (mutex))
+#define g_mutex_free(mutex) G_THREAD_CF (mutex_free, (void)0, (mutex))
+#define g_cond_new() G_THREAD_UF (cond_new, ())
+#define g_cond_signal(cond) G_THREAD_CF (cond_signal, (void)0, (cond))
+#define g_cond_broadcast(cond) G_THREAD_CF (cond_broadcast, (void)0, (cond))
+#define g_cond_wait(cond, mutex) G_THREAD_CF (cond_wait, (void)0, (cond, \
+ mutex))
+#define g_cond_free(cond) G_THREAD_CF (cond_free, (void)0, (cond))
+#define g_cond_timed_wait(cond, mutex, abs_time) G_THREAD_CF (cond_timed_wait, \
+ TRUE, \
+ (cond, mutex, \
+ abs_time))
+#define g_private_new(destructor) G_THREAD_UF (private_new, (destructor))
+#define g_private_get(private_key) G_THREAD_CF (private_get, \
+ ((gpointer)private_key), \
+ (private_key))
+#define g_private_set(private_key, value) G_THREAD_CF (private_set, \
+ (void) (private_key = \
+ (GPrivate*) (value)), \
+ (private_key, value))
+/* GStaticMutexes can be statically initialized with the value
* G_STATIC_MUTEX_INIT, and then they can directly be used, that is
* much easier, than having to explicitly allocate the mutex before
- * use */
+ * use
+ */
#define g_static_mutex_lock(mutex) \
- g_mutex_lock( g_static_mutex_get_mutex(mutex) )
+ g_mutex_lock (g_static_mutex_get_mutex (mutex))
#define g_static_mutex_trylock(mutex) \
- g_mutex_trylock( g_static_mutex_get_mutex(mutex) )
+ g_mutex_trylock (g_static_mutex_get_mutex (mutex))
#define g_static_mutex_unlock(mutex) \
- g_mutex_unlock( g_static_mutex_get_mutex(mutex) )
-
+ g_mutex_unlock (g_static_mutex_get_mutex (mutex))
struct _GStaticPrivate
{
guint index;
};
-
#define G_STATIC_PRIVATE_INIT { 0 }
-
-gpointer g_static_private_get (GStaticPrivate* private_key);
-void g_static_private_set (GStaticPrivate *private_key,
- gpointer data,
- GDestroyNotify notify);
-
-/* these are some convenience macros, for using StaticMutex'es, you
- * define them by G_LOCK_DEFINE(name), where name could for example be the
- * name of the protected varibale, and you (un)lock them with
- * g_(un)lock(name) */
-#define g_lock_name(name) (name ## _lock)
-#define G_LOCK_DEFINE(name) GStaticMutex g_lock_name(name)=G_STATIC_MUTEX_INIT
-
-#ifdef G_DEBUG_LOCKS
-#define g_lock(name) G_STMT_START{ \
- g_log (G_LOG_DOMAIN, \
- G_LOG_LEVEL_MESSAGE, \
- "file %s: line %d (%s): locking: %s ", \
- __FILE__, \
- __LINE__, \
- __PRETTY_FUNCTION__, \
- #name); \
- g_static_mutex_lock(g_lock_name(name)); \
+gpointer g_static_private_get (GStaticPrivate *private_key);
+void g_static_private_set (GStaticPrivate *private_key,
+ gpointer data,
+ GDestroyNotify notify);
+
+/* these are some convenience macros that expand to nothing if GLib was
+ * configured with --deisable-threads. for using StaticMutexes, you
+ * declare them with G_LOCK_DECLARE_STATIC (name) or G_LOCK_DECLARE (name)
+ * if you need to export the mutex. name is a unique identifier for the
+ * protected varibale or code portion. locking, testing and unlocking of
+ * such mutexes can be done with G_LOCK(), G_UNLOCK() and G_TRYLOCK()
+ * respectively.
+ */
+extern gboolean glib_dummy_decl;
+#define G_LOCK_NAME(name) (g__ ## name ## _lock)
+#ifdef G_THREADS_ENABLED
+# define G_LOCK_DECLARE_STATIC(name) static G_LOCK_DECLARE (name)
+# define G_LOCK_DECLARE(name) \
+ GStaticMutex G_LOCK_NAME (name) = G_STATIC_MUTEX_INIT
+
+# ifdef G_DEBUG_LOCKS
+# define G_LOCK(name) G_STMT_START{ \
+ g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \
+ "file %s: line %d (%s): locking: %s ", \
+ __FILE__, __LINE__, G_GNUC_PRETTY_FUNCTION, \
+ #name); \
+ g_static_mutex_lock (G_LOCK_NAME (name)); \
}G_STMT_END
-#define g_unlock(name) G_STMT_START{ \
- g_log (G_LOG_DOMAIN, \
- G_LOG_LEVEL_MESSAGE, \
- "file %s: line %d (%s): unlocking: %s ", \
- __FILE__, \
- __LINE__, \
- __PRETTY_FUNCTION__, \
- #name); \
- g_static_mutex_unlock(g_lock_name(name)); \
+# define G_UNLOCK(name) G_STMT_START{ \
+ g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \
+ "file %s: line %d (%s): unlocking: %s ", \
+ __FILE__, __LINE__, G_GNUC_PRETTY_FUNCTION, \
+ #name); \
+ g_static_mutex_unlock (G_LOCK_NAME (name)); \
}G_STMT_END
-#define g_trylock(name) G_STMT_START{ \
- g_log (G_LOG_DOMAIN, \
- G_LOG_LEVEL_MESSAGE, \
- "file %s: line %d (%s): try locking: %s ", \
- __FILE__, \
- __LINE__, \
- __PRETTY_FUNCTION__, \
- #name); \
- }G_STMT_END, g_static_mutex_trylock(g_lock_name(name))
-#else /* !G_DEBUG_LOCKS */
-#define g_lock(name) g_static_mutex_lock(g_lock_name(name))
-#define g_unlock(name) g_static_mutex_unlock(g_lock_name(name))
-#define g_trylock(name) g_static_mutex_trylock(g_lock_name(name))
-#endif
+# define G_TRYLOCK(name) G_STMT_START{ \
+ g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \
+ "file %s: line %d (%s): try locking: %s ", \
+ __FILE__, __LINE__, G_GNUC_PRETTY_FUNCTION, \
+ #name); \
+ }G_STMT_END, g_static_mutex_trylock (G_LOCK_NAME (name))
+# else /* !G_DEBUG_LOCKS */
+# define G_LOCK(name) g_static_mutex_lock (G_LOCK_NAME (name))
+# define G_UNLOCK(name) g_static_mutex_unlock (G_LOCK_NAME (name))
+# define G_TRYLOCK(name) g_static_mutex_trylock (G_LOCK_NAME (name))
+# endif /* !G_DEBUG_LOCKS */
+#else /* !G_THREADS_ENABLED */
+# define G_LOCK_DECLARE_STATIC(name) extern gboolean glib_dummy_decl
+# define G_LOCK_DECLARE(name) extern gboolean glib_dummy_decl
+# define G_LOCK(name)
+# define G_UNLOCK(name)
+# define G_TRYLOCK(name) (FALSE)
+#endif /* !G_THREADS_ENABLED */
#ifdef __cplusplus
}
};
static GAllocator *current_allocator = NULL;
-static G_LOCK_DEFINE(current_allocator);
+G_LOCK_DECLARE_STATIC (current_allocator);
/* HOLDS: current_allocator_lock */
static void
void
g_list_push_allocator(GAllocator *allocator)
{
- g_lock (current_allocator);
+ G_LOCK (current_allocator);
g_list_validate_allocator ( allocator );
allocator->last = current_allocator;
current_allocator = allocator;
- g_unlock (current_allocator);
+ G_UNLOCK (current_allocator);
}
void
g_list_pop_allocator (void)
{
- g_lock (current_allocator);
+ G_LOCK (current_allocator);
if (current_allocator)
{
GAllocator *allocator;
allocator->last = NULL;
allocator->is_unused = TRUE;
}
- g_unlock (current_allocator);
+ G_UNLOCK (current_allocator);
}
GList*
{
GList *list;
- g_lock (current_allocator);
+ G_LOCK (current_allocator);
if (!current_allocator)
{
GAllocator *allocator = g_allocator_new ("GLib default GList allocator",
current_allocator->free_lists = list->next;
}
}
- g_unlock (current_allocator);
+ G_UNLOCK (current_allocator);
list->next = NULL;
list->prev = NULL;
if (list)
{
list->data = list->next;
- g_lock (current_allocator);
+ G_LOCK (current_allocator);
list->next = current_allocator->free_lists;
current_allocator->free_lists = list;
- g_unlock (current_allocator);
+ G_UNLOCK (current_allocator);
}
}
if (list)
{
list->data = NULL;
- g_lock (current_allocator);
+ G_LOCK (current_allocator);
list->next = current_allocator->free_lists;
current_allocator->free_lists = list;
- g_unlock (current_allocator);
+ G_UNLOCK (current_allocator);
}
}
/* The following lock is used for both the list of sources
* and the list of poll records
*/
-static G_LOCK_DEFINE (main_loop);
+G_LOCK_DECLARE_STATIC (main_loop);
static GSourceFuncs timeout_funcs = {
g_timeout_prepare,
guint return_val;
GSource *source;
- g_lock (main_loop);
+ G_LOCK (main_loop);
if (!source_list.is_setup)
g_hook_list_init (&source_list, sizeof(GSource));
write (wake_up_pipe[1], "A", 1);
}
- g_unlock (main_loop);
+ G_UNLOCK (main_loop);
return return_val;
}
{
GHook *hook;
- g_lock (main_loop);
+ G_LOCK (main_loop);
hook = g_hook_get (&source_list, tag);
if (hook)
g_hook_destroy_link (&source_list, hook);
}
- g_unlock (main_loop);
+ G_UNLOCK (main_loop);
}
void
{
GHook *hook;
- g_lock (main_loop);
+ G_LOCK (main_loop);
hook = g_hook_find_data (&source_list, TRUE, user_data);
if (hook)
g_hook_destroy_link (&source_list, hook);
}
- g_unlock (main_loop);
+ G_UNLOCK (main_loop);
}
static gboolean
{
GHook *hook;
- g_lock (main_loop);
+ G_LOCK (main_loop);
hook = g_hook_find (&source_list, TRUE,
g_source_find_source_data, source_data);
g_hook_destroy_link (&source_list, hook);
}
- g_unlock (main_loop);
+ G_UNLOCK (main_loop);
}
void g_get_current_time (GTimeVal *result)
source->hook.flags |= G_HOOK_FLAG_IN_CALL;
- g_unlock (main_loop);
+ G_UNLOCK (main_loop);
need_destroy = ! dispatch(source_data,
current_time,
hook_data);
- g_lock (main_loop);
+ G_LOCK (main_loop);
source->hook.flags &= ~G_HOOK_FLAG_IN_CALL;
g_get_current_time (¤t_time);
- g_lock (main_loop);
+ G_LOCK (main_loop);
/* If recursing, finish up current dispatch, before starting over */
if (pending_dispatches)
if (dispatch)
g_main_dispatch (¤t_time);
- g_unlock (main_loop);
+ G_UNLOCK (main_loop);
return TRUE;
}
if (!dispatch)
{
g_hook_unref (&source_list, hook);
- g_unlock (main_loop);
+ G_UNLOCK (main_loop);
return TRUE;
}
else
else
{
g_hook_unref (&source_list, hook);
- g_unlock (main_loop);
+ G_UNLOCK (main_loop);
return TRUE;
}
}
retval = TRUE;
}
- g_unlock (main_loop);
+ G_UNLOCK (main_loop);
return retval;
}
poll_waiting = TRUE;
- g_unlock (main_loop);
+ G_UNLOCK (main_loop);
npoll = i;
(*poll_func) (fd_array, npoll, timeout);
- g_lock (main_loop);
+ G_LOCK (main_loop);
if (!poll_waiting)
{
g_main_poll_add (gint priority,
GPollFD *fd)
{
- g_lock (main_loop);
+ G_LOCK (main_loop);
g_main_poll_add_unlocked (priority, fd);
- g_unlock (main_loop);
+ G_UNLOCK (main_loop);
}
static void
n_poll_records++;
- g_unlock (main_loop);
+ G_UNLOCK (main_loop);
}
void
{
GPollRec *pollrec, *lastrec;
- g_lock (main_loop);
+ G_LOCK (main_loop);
lastrec = NULL;
pollrec = poll_records;
pollrec = pollrec->next;
}
- g_unlock (main_loop);
+ G_UNLOCK (main_loop);
}
void
GNode *free_nodes; /* implementation specific */
};
-static G_LOCK_DEFINE(current_allocator);
+G_LOCK_DECLARE_STATIC (current_allocator);
static GAllocator *current_allocator = NULL;
/* HOLDS: current_allocator_lock */
void
g_node_push_allocator (GAllocator *allocator)
{
- g_lock (current_allocator);
+ G_LOCK (current_allocator);
g_node_validate_allocator ( allocator );
allocator->last = current_allocator;
current_allocator = allocator;
- g_unlock (current_allocator);
+ G_UNLOCK (current_allocator);
}
void
g_node_pop_allocator (void)
{
- g_lock (current_allocator);
+ G_LOCK (current_allocator);
if (current_allocator)
{
GAllocator *allocator;
allocator->last = NULL;
allocator->is_unused = TRUE;
}
- g_unlock (current_allocator);
+ G_UNLOCK (current_allocator);
}
{
GNode *node;
- g_lock (current_allocator);
+ G_LOCK (current_allocator);
if (!current_allocator)
{
GAllocator *allocator = g_allocator_new ("GLib default GNode allocator",
node = current_allocator->free_nodes;
current_allocator->free_nodes = node->next;
}
- g_unlock (current_allocator);
+ G_UNLOCK (current_allocator);
node->data = data;
node->next = NULL;
break;
}
- g_lock (current_allocator);
+ G_LOCK (current_allocator);
parent->next = current_allocator->free_nodes;
current_allocator->free_nodes = node;
- g_unlock (current_allocator);
+ G_UNLOCK (current_allocator);
}
void
GSList *free_lists; /* implementation specific */
};
-static G_LOCK_DEFINE(current_allocator);
+G_LOCK_DECLARE_STATIC (current_allocator);
static GAllocator *current_allocator = NULL;
/* HOLDS: current_allocator_lock */
void
g_slist_push_allocator (GAllocator *allocator)
{
- g_lock (current_allocator);
+ G_LOCK (current_allocator);
g_slist_validate_allocator (allocator);
allocator->last = current_allocator;
current_allocator = allocator;
- g_unlock (current_allocator);
+ G_UNLOCK (current_allocator);
}
void
g_slist_pop_allocator (void)
{
- g_lock (current_allocator);
+ G_LOCK (current_allocator);
if (current_allocator)
{
GAllocator *allocator;
allocator->last = NULL;
allocator->is_unused = TRUE;
}
- g_unlock (current_allocator);
+ G_UNLOCK (current_allocator);
}
GSList*
{
GSList *list;
- g_lock (current_allocator);
+ G_LOCK (current_allocator);
if (!current_allocator)
{
GAllocator *allocator = g_allocator_new ("GLib default GSList allocator",
current_allocator->free_lists = list->next;
}
}
- g_unlock (current_allocator);
+ G_UNLOCK (current_allocator);
list->next = NULL;
if (list)
{
list->data = list->next;
- g_lock (current_allocator);
+ G_LOCK (current_allocator);
list->next = current_allocator->free_lists;
current_allocator->free_lists = list;
- g_unlock (current_allocator);
+ G_UNLOCK (current_allocator);
}
}
if (list)
{
list->data = NULL;
- g_lock (current_allocator);
+ G_LOCK (current_allocator);
list->next = current_allocator->free_lists;
current_allocator->free_lists = list;
- g_unlock (current_allocator);
+ G_UNLOCK (current_allocator);
}
}
gint alloc;
};
-static G_LOCK_DEFINE(string_mem_chunk);
+G_LOCK_DECLARE_STATIC (string_mem_chunk);
static GMemChunk *string_mem_chunk = NULL;
/* Hash Functions.
{
GRealString *string;
- g_lock (string_mem_chunk);
+ G_LOCK (string_mem_chunk);
if (!string_mem_chunk)
string_mem_chunk = g_mem_chunk_new ("string mem chunk",
sizeof (GRealString),
1024, G_ALLOC_AND_FREE);
string = g_chunk_new (GRealString, string_mem_chunk);
- g_unlock (string_mem_chunk);
+ G_UNLOCK (string_mem_chunk);
string->alloc = 0;
string->len = 0;
if (free_segment)
g_free (string->str);
- g_lock (string_mem_chunk);
+ G_LOCK (string_mem_chunk);
g_mem_chunk_free (string_mem_chunk, string);
- g_unlock (string_mem_chunk);
+ G_UNLOCK (string_mem_chunk);
}
GString*
static void g_tree_node_check (GTreeNode *node);
-static G_LOCK_DEFINE(g_tree_global);
+G_LOCK_DECLARE_STATIC (g_tree_global);
static GMemChunk *node_mem_chunk = NULL;
static GTreeNode *node_free_list = NULL;
{
GTreeNode *node;
- g_lock (g_tree_global);
+ G_LOCK (g_tree_global);
if (node_free_list)
{
node = node_free_list;
node = g_chunk_new (GTreeNode, node_mem_chunk);
}
- g_unlock (g_tree_global);
+ G_UNLOCK (g_tree_global);
node->balance = 0;
node->left = NULL;
{
g_tree_node_destroy (node->right);
g_tree_node_destroy (node->left);
- g_lock (g_tree_global);
+ G_LOCK (g_tree_global);
node->right = node_free_list;
node_free_list = node;
- g_unlock (g_tree_global);
+ G_UNLOCK (g_tree_global);
}
}
node = g_tree_node_restore_right_balance (new_root, old_balance);
}
- g_lock (g_tree_global);
+ G_LOCK (g_tree_global);
garbage->right = node_free_list;
node_free_list = garbage;
- g_unlock (g_tree_global);
+ G_UNLOCK (g_tree_global);
}
else if (cmp < 0)
{
#endif
}
-static G_LOCK_DEFINE(g_utils_global);
+G_LOCK_DECLARE_STATIC (g_utils_global);
static gchar *g_tmp_dir = NULL;
static gchar *g_user_name = NULL;
gchar*
g_get_user_name (void)
{
- g_lock (g_utils_global);
+ G_LOCK (g_utils_global);
if (!g_tmp_dir)
g_get_any_init ();
- g_unlock (g_utils_global);
+ G_UNLOCK (g_utils_global);
return g_user_name;
}
gchar*
g_get_real_name (void)
{
- g_lock (g_utils_global);
+ G_LOCK (g_utils_global);
if (!g_tmp_dir)
g_get_any_init ();
- g_unlock (g_utils_global);
+ G_UNLOCK (g_utils_global);
return g_real_name;
}
gchar*
g_get_home_dir (void)
{
- g_lock (g_utils_global);
+ G_LOCK (g_utils_global);
if (!g_tmp_dir)
g_get_any_init ();
- g_unlock (g_utils_global);
+ G_UNLOCK (g_utils_global);
return g_home_dir;
}
gchar*
g_get_tmp_dir (void)
{
- g_lock (g_utils_global);
+ G_LOCK (g_utils_global);
if (!g_tmp_dir)
g_get_any_init ();
- g_unlock (g_utils_global);
+ G_UNLOCK (g_utils_global);
return g_tmp_dir;
}
{
gchar* retval;
- g_lock (g_utils_global);
+ G_LOCK (g_utils_global);
retval = g_prgname;
- g_unlock (g_utils_global);
+ G_UNLOCK (g_utils_global);
return retval;
}
{
gchar *c;
- g_lock (g_utils_global);
+ G_LOCK (g_utils_global);
c = g_prgname;
g_prgname = g_strdup (prgname);
g_free (c);
- g_unlock (g_utils_global);
+ G_UNLOCK (g_utils_global);
}
guint
};
static GAllocator *current_allocator = NULL;
-static G_LOCK_DEFINE(current_allocator);
+G_LOCK_DECLARE_STATIC (current_allocator);
/* HOLDS: current_allocator_lock */
static void
void
g_list_push_allocator(GAllocator *allocator)
{
- g_lock (current_allocator);
+ G_LOCK (current_allocator);
g_list_validate_allocator ( allocator );
allocator->last = current_allocator;
current_allocator = allocator;
- g_unlock (current_allocator);
+ G_UNLOCK (current_allocator);
}
void
g_list_pop_allocator (void)
{
- g_lock (current_allocator);
+ G_LOCK (current_allocator);
if (current_allocator)
{
GAllocator *allocator;
allocator->last = NULL;
allocator->is_unused = TRUE;
}
- g_unlock (current_allocator);
+ G_UNLOCK (current_allocator);
}
GList*
{
GList *list;
- g_lock (current_allocator);
+ G_LOCK (current_allocator);
if (!current_allocator)
{
GAllocator *allocator = g_allocator_new ("GLib default GList allocator",
current_allocator->free_lists = list->next;
}
}
- g_unlock (current_allocator);
+ G_UNLOCK (current_allocator);
list->next = NULL;
list->prev = NULL;
if (list)
{
list->data = list->next;
- g_lock (current_allocator);
+ G_LOCK (current_allocator);
list->next = current_allocator->free_lists;
current_allocator->free_lists = list;
- g_unlock (current_allocator);
+ G_UNLOCK (current_allocator);
}
}
if (list)
{
list->data = NULL;
- g_lock (current_allocator);
+ G_LOCK (current_allocator);
list->next = current_allocator->free_lists;
current_allocator->free_lists = list;
- g_unlock (current_allocator);
+ G_UNLOCK (current_allocator);
}
}
/* The following lock is used for both the list of sources
* and the list of poll records
*/
-static G_LOCK_DEFINE (main_loop);
+G_LOCK_DECLARE_STATIC (main_loop);
static GSourceFuncs timeout_funcs = {
g_timeout_prepare,
guint return_val;
GSource *source;
- g_lock (main_loop);
+ G_LOCK (main_loop);
if (!source_list.is_setup)
g_hook_list_init (&source_list, sizeof(GSource));
write (wake_up_pipe[1], "A", 1);
}
- g_unlock (main_loop);
+ G_UNLOCK (main_loop);
return return_val;
}
{
GHook *hook;
- g_lock (main_loop);
+ G_LOCK (main_loop);
hook = g_hook_get (&source_list, tag);
if (hook)
g_hook_destroy_link (&source_list, hook);
}
- g_unlock (main_loop);
+ G_UNLOCK (main_loop);
}
void
{
GHook *hook;
- g_lock (main_loop);
+ G_LOCK (main_loop);
hook = g_hook_find_data (&source_list, TRUE, user_data);
if (hook)
g_hook_destroy_link (&source_list, hook);
}
- g_unlock (main_loop);
+ G_UNLOCK (main_loop);
}
static gboolean
{
GHook *hook;
- g_lock (main_loop);
+ G_LOCK (main_loop);
hook = g_hook_find (&source_list, TRUE,
g_source_find_source_data, source_data);
g_hook_destroy_link (&source_list, hook);
}
- g_unlock (main_loop);
+ G_UNLOCK (main_loop);
}
void g_get_current_time (GTimeVal *result)
source->hook.flags |= G_HOOK_FLAG_IN_CALL;
- g_unlock (main_loop);
+ G_UNLOCK (main_loop);
need_destroy = ! dispatch(source_data,
current_time,
hook_data);
- g_lock (main_loop);
+ G_LOCK (main_loop);
source->hook.flags &= ~G_HOOK_FLAG_IN_CALL;
g_get_current_time (¤t_time);
- g_lock (main_loop);
+ G_LOCK (main_loop);
/* If recursing, finish up current dispatch, before starting over */
if (pending_dispatches)
if (dispatch)
g_main_dispatch (¤t_time);
- g_unlock (main_loop);
+ G_UNLOCK (main_loop);
return TRUE;
}
if (!dispatch)
{
g_hook_unref (&source_list, hook);
- g_unlock (main_loop);
+ G_UNLOCK (main_loop);
return TRUE;
}
else
else
{
g_hook_unref (&source_list, hook);
- g_unlock (main_loop);
+ G_UNLOCK (main_loop);
return TRUE;
}
}
retval = TRUE;
}
- g_unlock (main_loop);
+ G_UNLOCK (main_loop);
return retval;
}
poll_waiting = TRUE;
- g_unlock (main_loop);
+ G_UNLOCK (main_loop);
npoll = i;
(*poll_func) (fd_array, npoll, timeout);
- g_lock (main_loop);
+ G_LOCK (main_loop);
if (!poll_waiting)
{
g_main_poll_add (gint priority,
GPollFD *fd)
{
- g_lock (main_loop);
+ G_LOCK (main_loop);
g_main_poll_add_unlocked (priority, fd);
- g_unlock (main_loop);
+ G_UNLOCK (main_loop);
}
static void
n_poll_records++;
- g_unlock (main_loop);
+ G_UNLOCK (main_loop);
}
void
{
GPollRec *pollrec, *lastrec;
- g_lock (main_loop);
+ G_LOCK (main_loop);
lastrec = NULL;
pollrec = poll_records;
pollrec = pollrec->next;
}
- g_unlock (main_loop);
+ G_UNLOCK (main_loop);
}
void
/* --- variables --- */
-static G_LOCK_DEFINE (g_module_global);
+G_LOCK_DECLARE_STATIC (GModule);
const char *g_log_domain_gmodule = "GModule";
static GModule *modules = NULL;
static GModule *main_module = NULL;
GModule *module;
GModule *retval = NULL;
- g_lock (g_module_global);
+ G_LOCK (GModule);
if (main_module && main_module->handle == handle)
retval = main_module;
else
retval = module;
break;
}
- g_unlock (g_module_global);
+ G_UNLOCK (GModule);
return retval;
}
GModule *module;
GModule *retval = NULL;
- g_lock (g_module_global);
+ G_LOCK (GModule);
for (module = modules; module; module = module->next)
if (strcmp (name, module->file_name) == 0)
{
retval = module;
break;
}
- g_unlock (g_module_global);
+ G_UNLOCK (GModule);
return retval;
}
if (!file_name)
{
- g_lock (g_module_global);
+ G_LOCK (GModule);
if (!main_module)
{
handle = _g_module_self ();
main_module->next = NULL;
}
}
- g_unlock (g_module_global);
+ G_UNLOCK (GModule);
return main_module;
}
module->ref_count = 1;
module->is_resident = FALSE;
module->unload = NULL;
- g_lock (g_module_global);
+ G_LOCK (GModule);
module->next = modules;
modules = module;
- g_unlock (g_module_global);
+ G_UNLOCK (GModule);
/* check initialization */
if (g_module_symbol (module, "g_module_check_init", (gpointer) &check_init))
last = NULL;
- g_lock (g_module_global);
+ G_LOCK (GModule);
node = modules;
while (node)
{
node = last->next;
}
module->next = NULL;
- g_unlock (g_module_global);
+ G_UNLOCK (GModule);
_g_module_close (module->handle, FALSE);
g_free (module->file_name);
/* Global variables */
gboolean g_thread_use_default_impl = TRUE;
-gboolean g_thread_supported = FALSE;
+gboolean g_threads_got_initialized = FALSE;
GThreadFunctions g_thread_functions_for_glib_use = {
(GMutex*(*)())g_thread_fail, /* mutex_new */
gpointer private_old = g_thread_specific_private;
g_thread_specific_private = g_private_new (g_static_private_free_data);
- /* we can not use g_private_set here, as g_thread_supported is not
+ /* we can not use g_private_set here, as g_threads_got_initialized is not
yet set TRUE, whereas the private_set function is already set. */
g_thread_functions_for_glib_use.private_set (g_thread_specific_private,
private_old);
GMutex *
g_static_mutex_get_mutex_impl (GMutex** mutex)
{
- if (!g_thread_supported)
+ if (!g_thread_supported ())
return NULL;
g_assert (g_mutex_protect_static_mutex_allocation);
GNode *free_nodes; /* implementation specific */
};
-static G_LOCK_DEFINE(current_allocator);
+G_LOCK_DECLARE_STATIC (current_allocator);
static GAllocator *current_allocator = NULL;
/* HOLDS: current_allocator_lock */
void
g_node_push_allocator (GAllocator *allocator)
{
- g_lock (current_allocator);
+ G_LOCK (current_allocator);
g_node_validate_allocator ( allocator );
allocator->last = current_allocator;
current_allocator = allocator;
- g_unlock (current_allocator);
+ G_UNLOCK (current_allocator);
}
void
g_node_pop_allocator (void)
{
- g_lock (current_allocator);
+ G_LOCK (current_allocator);
if (current_allocator)
{
GAllocator *allocator;
allocator->last = NULL;
allocator->is_unused = TRUE;
}
- g_unlock (current_allocator);
+ G_UNLOCK (current_allocator);
}
{
GNode *node;
- g_lock (current_allocator);
+ G_LOCK (current_allocator);
if (!current_allocator)
{
GAllocator *allocator = g_allocator_new ("GLib default GNode allocator",
node = current_allocator->free_nodes;
current_allocator->free_nodes = node->next;
}
- g_unlock (current_allocator);
+ G_UNLOCK (current_allocator);
node->data = data;
node->next = NULL;
break;
}
- g_lock (current_allocator);
+ G_LOCK (current_allocator);
parent->next = current_allocator->free_nodes;
current_allocator->free_nodes = node;
- g_unlock (current_allocator);
+ G_UNLOCK (current_allocator);
}
void
GSList *free_lists; /* implementation specific */
};
-static G_LOCK_DEFINE(current_allocator);
+G_LOCK_DECLARE_STATIC (current_allocator);
static GAllocator *current_allocator = NULL;
/* HOLDS: current_allocator_lock */
void
g_slist_push_allocator (GAllocator *allocator)
{
- g_lock (current_allocator);
+ G_LOCK (current_allocator);
g_slist_validate_allocator (allocator);
allocator->last = current_allocator;
current_allocator = allocator;
- g_unlock (current_allocator);
+ G_UNLOCK (current_allocator);
}
void
g_slist_pop_allocator (void)
{
- g_lock (current_allocator);
+ G_LOCK (current_allocator);
if (current_allocator)
{
GAllocator *allocator;
allocator->last = NULL;
allocator->is_unused = TRUE;
}
- g_unlock (current_allocator);
+ G_UNLOCK (current_allocator);
}
GSList*
{
GSList *list;
- g_lock (current_allocator);
+ G_LOCK (current_allocator);
if (!current_allocator)
{
GAllocator *allocator = g_allocator_new ("GLib default GSList allocator",
current_allocator->free_lists = list->next;
}
}
- g_unlock (current_allocator);
+ G_UNLOCK (current_allocator);
list->next = NULL;
if (list)
{
list->data = list->next;
- g_lock (current_allocator);
+ G_LOCK (current_allocator);
list->next = current_allocator->free_lists;
current_allocator->free_lists = list;
- g_unlock (current_allocator);
+ G_UNLOCK (current_allocator);
}
}
if (list)
{
list->data = NULL;
- g_lock (current_allocator);
+ G_LOCK (current_allocator);
list->next = current_allocator->free_lists;
current_allocator->free_lists = list;
- g_unlock (current_allocator);
+ G_UNLOCK (current_allocator);
}
}
gint alloc;
};
-static G_LOCK_DEFINE(string_mem_chunk);
+G_LOCK_DECLARE_STATIC (string_mem_chunk);
static GMemChunk *string_mem_chunk = NULL;
/* Hash Functions.
{
GRealString *string;
- g_lock (string_mem_chunk);
+ G_LOCK (string_mem_chunk);
if (!string_mem_chunk)
string_mem_chunk = g_mem_chunk_new ("string mem chunk",
sizeof (GRealString),
1024, G_ALLOC_AND_FREE);
string = g_chunk_new (GRealString, string_mem_chunk);
- g_unlock (string_mem_chunk);
+ G_UNLOCK (string_mem_chunk);
string->alloc = 0;
string->len = 0;
if (free_segment)
g_free (string->str);
- g_lock (string_mem_chunk);
+ G_LOCK (string_mem_chunk);
g_mem_chunk_free (string_mem_chunk, string);
- g_unlock (string_mem_chunk);
+ G_UNLOCK (string_mem_chunk);
}
GString*
+Wed Dec 16 03:16:16 1998 Tim Janik <timj@gtk.org>
+
+ * testgthread.c: s/g_thread_supported/g_thread_supported ()/
+ * gthread.c: s/g_thread_supported/g_threads_got_initialized/
+ (g_thread_init): bail out if G_THREADS_ENABLED is not defined.
+
1998-12-15 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
* Makefile.am (EXTRA_DIST): updated.
-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \
-release $(LT_RELEASE)
-libgthread_la_LIBADD = \
- @G_THREAD_LIBS@
+libgthread_la_LIBADD = @G_THREAD_LIBS@
noinst_PROGRAMS = testgthread
testgthread_LDADD = ../libglib.la libgthread.la
void g_messages_init (void);
void
-g_thread_init(GThreadFunctions* init)
+g_thread_init (GThreadFunctions* init)
{
gboolean supported;
+#ifndef G_THREADS_ENABLED
+ g_error ("GLib thread support is disabled.");
+#endif /* !G_THREADS_ENABLED */
+
if (thread_system_already_initialized)
- g_error ("the glib thread system may only be initialized once.");
+ g_error ("GThread system may only be initialized once.");
thread_system_already_initialized = TRUE;
g_thread_functions_for_glib_use = *init;
- /* It is important, that g_thread_supported is not set before the
- thread initialization functions of the different modules are
- called */
-
- supported =
- init->mutex_new &&
- init->mutex_lock &&
- init->mutex_trylock &&
- init->mutex_unlock &&
- init->mutex_free &&
- init->cond_new &&
- init->cond_signal &&
- init->cond_broadcast &&
- init->cond_wait &&
- init->cond_timed_wait &&
- init->cond_free &&
- init->private_new &&
- init->private_get &&
- init->private_get;
+ /* It is important, that g_threads_got_initialized is not set before the
+ * thread initialization functions of the different modules are called
+ */
+
+ supported = (init->mutex_new &&
+ init->mutex_lock &&
+ init->mutex_trylock &&
+ init->mutex_unlock &&
+ init->mutex_free &&
+ init->cond_new &&
+ init->cond_signal &&
+ init->cond_broadcast &&
+ init->cond_wait &&
+ init->cond_timed_wait &&
+ init->cond_free &&
+ init->private_new &&
+ init->private_get &&
+ init->private_get);
/* if somebody is calling g_thread_init (), it means that he wants to
- have thread support, so check this */
-
+ * have thread support, so check this
+ */
if (!supported)
{
if (g_thread_use_default_impl)
}
/* now call the thread initialization functions of the different
- glib modules. BTW: order does matter, g_mutex_init MUST be first */
-
+ * glib modules. order does matter, g_mutex_init MUST come first.
+ */
g_mutex_init ();
g_mem_init ();
g_messages_init ();
- /* now we can set g_thread_supported and thus enable all the thread
- functions */
-
- g_thread_supported = TRUE;
+ /* now we can set g_threads_got_initialized and thus enable
+ * all the thread functions
+ */
+ g_threads_got_initialized = TRUE;
}
GMutex *mutex = NULL;
GCond *cond = NULL;
GStaticMutex static_mutex = G_STATIC_MUTEX_INIT;
- G_LOCK_DEFINE (test_me);
+ G_LOCK_DECLARE (test_me);
- if (g_thread_supported)
+ if (g_thread_supported ())
{
mutex = g_mutex_new ();
cond = g_cond_new ();
g_cond_signal (cond);
g_cond_broadcast (cond);
- g_lock (test_me);
- g_unlock (test_me);
+ G_LOCK (test_me);
+ G_UNLOCK (test_me);
- if (g_thread_supported)
+ if (g_thread_supported ())
{
g_cond_free (cond);
g_mutex_free (mutex);
static void g_tree_node_check (GTreeNode *node);
-static G_LOCK_DEFINE(g_tree_global);
+G_LOCK_DECLARE_STATIC (g_tree_global);
static GMemChunk *node_mem_chunk = NULL;
static GTreeNode *node_free_list = NULL;
{
GTreeNode *node;
- g_lock (g_tree_global);
+ G_LOCK (g_tree_global);
if (node_free_list)
{
node = node_free_list;
node = g_chunk_new (GTreeNode, node_mem_chunk);
}
- g_unlock (g_tree_global);
+ G_UNLOCK (g_tree_global);
node->balance = 0;
node->left = NULL;
{
g_tree_node_destroy (node->right);
g_tree_node_destroy (node->left);
- g_lock (g_tree_global);
+ G_LOCK (g_tree_global);
node->right = node_free_list;
node_free_list = node;
- g_unlock (g_tree_global);
+ G_UNLOCK (g_tree_global);
}
}
node = g_tree_node_restore_right_balance (new_root, old_balance);
}
- g_lock (g_tree_global);
+ G_LOCK (g_tree_global);
garbage->right = node_free_list;
node_free_list = garbage;
- g_unlock (g_tree_global);
+ G_UNLOCK (g_tree_global);
}
else if (cmp < 0)
{
#endif
}
-static G_LOCK_DEFINE(g_utils_global);
+G_LOCK_DECLARE_STATIC (g_utils_global);
static gchar *g_tmp_dir = NULL;
static gchar *g_user_name = NULL;
gchar*
g_get_user_name (void)
{
- g_lock (g_utils_global);
+ G_LOCK (g_utils_global);
if (!g_tmp_dir)
g_get_any_init ();
- g_unlock (g_utils_global);
+ G_UNLOCK (g_utils_global);
return g_user_name;
}
gchar*
g_get_real_name (void)
{
- g_lock (g_utils_global);
+ G_LOCK (g_utils_global);
if (!g_tmp_dir)
g_get_any_init ();
- g_unlock (g_utils_global);
+ G_UNLOCK (g_utils_global);
return g_real_name;
}
gchar*
g_get_home_dir (void)
{
- g_lock (g_utils_global);
+ G_LOCK (g_utils_global);
if (!g_tmp_dir)
g_get_any_init ();
- g_unlock (g_utils_global);
+ G_UNLOCK (g_utils_global);
return g_home_dir;
}
gchar*
g_get_tmp_dir (void)
{
- g_lock (g_utils_global);
+ G_LOCK (g_utils_global);
if (!g_tmp_dir)
g_get_any_init ();
- g_unlock (g_utils_global);
+ G_UNLOCK (g_utils_global);
return g_tmp_dir;
}
{
gchar* retval;
- g_lock (g_utils_global);
+ G_LOCK (g_utils_global);
retval = g_prgname;
- g_unlock (g_utils_global);
+ G_UNLOCK (g_utils_global);
return retval;
}
{
gchar *c;
- g_lock (g_utils_global);
+ G_LOCK (g_utils_global);
c = g_prgname;
g_prgname = g_strdup (prgname);
g_free (c);
- g_unlock (g_utils_global);
+ G_UNLOCK (g_utils_global);
}
guint