version bump to 1.1.8, binary age 0, interface age 0.
authorTim Janik <timj@gtk.org>
Wed, 16 Dec 1998 05:38:35 +0000 (05:38 +0000)
committerTim Janik <timj@src.gnome.org>
Wed, 16 Dec 1998 05:38:35 +0000 (05:38 +0000)
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/.

42 files changed:
ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
acconfig.h
configure.in
garray.c
gcache.c
gdataset.c
gdate.c
ghash.c
glib.h
glib/garray.c
glib/gcache.c
glib/gdataset.c
glib/gdate.c
glib/ghash.c
glib/glib.h
glib/glist.c
glib/gmain.c
glib/gnode.c
glib/gslist.c
glib/gstring.c
glib/gtree.c
glib/gutils.c
glist.c
gmain.c
gmodule/gmodule.c
gmutex.c
gnode.c
gslist.c
gstring.c
gthread/ChangeLog
gthread/Makefile.am
gthread/gthread.c
gthread/testgthread.c
gtree.c
gutils.c

index 16bc72d..622b7eb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,39 @@
+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
index 16bc72d..622b7eb 100644 (file)
@@ -1,3 +1,39 @@
+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
index 16bc72d..622b7eb 100644 (file)
@@ -1,3 +1,39 @@
+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
index 16bc72d..622b7eb 100644 (file)
@@ -1,3 +1,39 @@
+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
index 16bc72d..622b7eb 100644 (file)
@@ -1,3 +1,39 @@
+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
index 16bc72d..622b7eb 100644 (file)
@@ -1,3 +1,39 @@
+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
index 16bc72d..622b7eb 100644 (file)
@@ -1,3 +1,39 @@
+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
index 16bc72d..622b7eb 100644 (file)
@@ -1,3 +1,39 @@
+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
index 4396f7b..76df7d3 100644 (file)
@@ -38,6 +38,7 @@
 #undef ENABLE_MEM_PROFILE
 
 #undef G_COMPILED_WITH_DEBUGGING
+#undef G_THREADS_ENABLED
 #undef HAVE_BROKEN_WCTYPE
 #undef HAVE_DOPRNT
 #undef HAVE_FLOAT_H
index 0645fcb..42ca0ff 100644 (file)
@@ -57,11 +57,16 @@ AM_MAINTAINER_MODE
 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
@@ -513,13 +518,16 @@ dnl ***********************
 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
@@ -813,6 +821,8 @@ outfile_EOF
 
 cat >>$outfile <<outfile_EOF                                               
 
+$g_enable_threads_def G_THREADS_ENABLED
+
 /* definitions for the default mutex implementation */
 outfile_EOF
 
@@ -1053,6 +1063,11 @@ if test x$glib_working_wctype = xno; then
 #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
index 7f0803e..94c1b24 100644 (file)
--- a/garray.c
+++ b/garray.c
@@ -46,7 +46,7 @@ static void g_array_maybe_expand (GRealArray *array,
                                  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,
@@ -55,14 +55,14 @@ 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;
@@ -81,9 +81,9 @@ g_array_free (GArray  *array,
   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*
@@ -250,7 +250,7 @@ static void g_ptr_array_maybe_expand (GRealPtrArray *array,
                                      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*
@@ -258,14 +258,14 @@ g_ptr_array_new (void)
 {
   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;
@@ -283,9 +283,9 @@ g_ptr_array_free (GPtrArray   *array,
   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
index 800bb2b..c9ed61f 100644 (file)
--- a/gcache.c
+++ b/gcache.c
@@ -61,7 +61,7 @@ static void        g_cache_node_destroy (GCacheNode *node);
 
 
 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,
@@ -198,13 +198,13 @@ g_cache_node_new (gpointer value)
 {
   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;
@@ -215,7 +215,7 @@ g_cache_node_new (gpointer value)
 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);
 }
index f22b21d..8aadb96 100644 (file)
@@ -67,7 +67,7 @@ static inline GQuark  g_quark_new                     (gchar          *string);
 
 
 /* --- 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? */
@@ -76,7 +76,7 @@ static GMemChunk    *g_data_mem_chunk = NULL;
 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;
@@ -121,13 +121,13 @@ g_datalist_clear (GData **datalist)
 {
   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 */
@@ -174,7 +174,7 @@ g_dataset_destroy (gconstpointer  dataset_location)
 {
   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;
@@ -183,7 +183,7 @@ g_dataset_destroy (gconstpointer  dataset_location)
       if (dataset)
        g_dataset_destroy_internal (dataset);
     }
-  g_unlock (g_dataset_global);
+  G_UNLOCK (g_dataset_global);
 }
 
 /* HOLDS: g_dataset_global_lock */
@@ -312,7 +312,7 @@ g_dataset_id_set_data_full (gconstpointer  dataset_location,
        return;
     }
   
-  g_lock (g_dataset_global);
+  G_LOCK (g_dataset_global);
   if (!g_dataset_location_ht)
     g_data_initialize ();
  
@@ -328,7 +328,7 @@ g_dataset_id_set_data_full (gconstpointer  dataset_location,
     }
   
   g_data_set_internal (&dataset->datalist, key_id, data, destroy_func, dataset);
-  g_unlock (g_dataset_global);
+  G_UNLOCK (g_dataset_global);
 }
 
 void
@@ -348,12 +348,12 @@ g_datalist_id_set_data_full (GData          **datalist,
        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
@@ -362,7 +362,7 @@ g_dataset_id_remove_no_notify (gconstpointer  dataset_location,
 {
   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;
@@ -371,7 +371,7 @@ g_dataset_id_remove_no_notify (gconstpointer  dataset_location,
       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
@@ -380,10 +380,10 @@ g_datalist_id_remove_no_notify (GData     **datalist,
 {
   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
@@ -392,7 +392,7 @@ g_dataset_id_get_data (gconstpointer  dataset_location,
 {
   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;
@@ -405,12 +405,12 @@ g_dataset_id_get_data (gconstpointer  dataset_location,
          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;
 }
@@ -443,11 +443,11 @@ g_dataset_foreach (gconstpointer    dataset_location,
   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;
@@ -458,7 +458,7 @@ g_dataset_foreach (gconstpointer    dataset_location,
     }
   else
     {
-      g_unlock (g_dataset_global);
+      G_UNLOCK (g_dataset_global);
     }
 }
 
@@ -510,10 +510,10 @@ g_quark_try_string (const gchar *string)
   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;
 }
@@ -525,7 +525,7 @@ g_quark_from_string (const gchar *string)
   
   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
@@ -536,7 +536,7 @@ g_quark_from_string (const gchar *string)
   
   if (!quark)
     quark = g_quark_new (g_strdup (string));
-  g_unlock (g_quark_global);
+  G_UNLOCK (g_quark_global);
   
   return quark;
 }
@@ -548,7 +548,7 @@ g_quark_from_static_string (const gchar *string)
   
   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
@@ -559,7 +559,7 @@ g_quark_from_static_string (const gchar *string)
 
   if (!quark)
     quark = g_quark_new ((gchar*) string);
-  g_unlock (g_quark_global);
+  G_UNLOCK (g_quark_global);
  
   return quark;
 }
@@ -568,10 +568,10 @@ gchar*
 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;
 }
diff --git a/gdate.c b/gdate.c
index 6672436..471aaad 100644 (file)
--- a/gdate.c
+++ b/gdate.c
@@ -388,7 +388,7 @@ g_date_clear (GDate       *d, guint ndates)
   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
@@ -652,7 +652,7 @@ g_date_set_parse (GDate       *d,
   /* set invalid */
   g_date_clear (d, 1);
   
-  g_lock (g_date_global);
+  G_LOCK (g_date_global);
 
   g_date_prepare_to_parse (str, &pt);
   
@@ -664,7 +664,7 @@ g_date_set_parse (GDate       *d,
   
   if (pt.num_ints == 4) 
     {
-      g_unlock (g_date_global);
+      G_UNLOCK (g_date_global);
       return; /* presumably a typo; bail out. */
     }
   
@@ -782,7 +782,7 @@ g_date_set_parse (GDate       *d,
   else 
     g_message ("Rejected DMY %u %u %u", day, m, y);
 #endif
-  g_unlock (g_date_global);
+  G_UNLOCK (g_date_global);
 }
 
 void         
diff --git a/ghash.c b/ghash.c
index 7240363..ed564e1 100644 (file)
--- a/ghash.c
+++ b/ghash.c
@@ -57,7 +57,7 @@ static void           g_hash_node_destroy      (GHashNode     *hash_node);
 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;
@@ -345,7 +345,7 @@ g_hash_node_new (gpointer key,
 {
   GHashNode *hash_node;
   
-  g_lock (g_hash_global);
+  G_LOCK (g_hash_global);
   if (node_free_list)
     {
       hash_node = node_free_list;
@@ -360,7 +360,7 @@ g_hash_node_new (gpointer key,
       
       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;
@@ -372,10 +372,10 @@ g_hash_node_new (gpointer key,
 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
@@ -391,8 +391,8 @@ g_hash_nodes_destroy (GHashNode *hash_node)
   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);
 }
diff --git a/glib.h b/glib.h
index 4ea3097..24e5a6b 100644 (file)
--- a/glib.h
+++ b/glib.h
@@ -2007,7 +2007,8 @@ gint              g_scanner_stat_mode             (const gchar    *filename);
 } G_STMT_END
 
 
-/* Completion */
+/* GCompletion
+ */
 
 struct _GCompletion
 {
@@ -2030,28 +2031,32 @@ GList*       g_completion_complete     (GCompletion*    cmp,
 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,
@@ -2061,8 +2066,8 @@ typedef enum {
   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,
@@ -2078,22 +2083,17 @@ typedef enum {
   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
@@ -2109,105 +2109,95 @@ struct _GDate {
   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);
@@ -2217,11 +2207,7 @@ guint8       g_date_sunday_weeks_in_year  (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.
@@ -2230,12 +2216,12 @@ void         g_date_to_struct_tm          (GDate       *d,
 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.
  *
@@ -2295,47 +2281,47 @@ gpointer   g_tuples_index     (GTuples     *tuples,
 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
@@ -2351,27 +2337,27 @@ struct _GIOChannel
 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);
@@ -2400,19 +2386,20 @@ guint    g_io_add_watch         (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);
@@ -2424,10 +2411,9 @@ struct _GSourceFuncs {
   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,
@@ -2438,67 +2424,65 @@ void g_source_remove                (guint          tag);
 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).
@@ -2521,7 +2505,6 @@ struct _GIOChannel
                                 */
 #endif
 };
-
 GIOChannel *g_iochannel_new            (gint        fd);
 void        g_iochannel_free           (GIOChannel *channel);
 void        g_iochannel_close_and_free (GIOChannel *channel);
@@ -2529,16 +2512,14 @@ void        g_iochannel_wakeup_peer    (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
@@ -2553,30 +2534,27 @@ typedef int pid_t;
  * 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;
@@ -2586,7 +2564,6 @@ struct dirent
 {
   gchar  d_name[NAME_MAX + 1];
 };
-
 /* emulation functions */
 extern int     gwin_ftruncate  (gint            f,
                                 guint           size);
@@ -2594,145 +2571,153 @@ DIR*          gwin_opendir    (const gchar    *dirname);
 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)      (GMutexmutex);
-  gboolean (*mutex_trylock)   (GMutexmutex);
-  void     (*mutex_unlock)    (GMutexmutex);
-  void     (*mutex_free)      (GMutexmutex);
+  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
 }
index 7f0803e..94c1b24 100644 (file)
@@ -46,7 +46,7 @@ static void g_array_maybe_expand (GRealArray *array,
                                  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,
@@ -55,14 +55,14 @@ 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;
@@ -81,9 +81,9 @@ g_array_free (GArray  *array,
   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*
@@ -250,7 +250,7 @@ static void g_ptr_array_maybe_expand (GRealPtrArray *array,
                                      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*
@@ -258,14 +258,14 @@ g_ptr_array_new (void)
 {
   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;
@@ -283,9 +283,9 @@ g_ptr_array_free (GPtrArray   *array,
   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
index 800bb2b..c9ed61f 100644 (file)
@@ -61,7 +61,7 @@ static void        g_cache_node_destroy (GCacheNode *node);
 
 
 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,
@@ -198,13 +198,13 @@ g_cache_node_new (gpointer value)
 {
   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;
@@ -215,7 +215,7 @@ g_cache_node_new (gpointer value)
 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);
 }
index f22b21d..8aadb96 100644 (file)
@@ -67,7 +67,7 @@ static inline GQuark  g_quark_new                     (gchar          *string);
 
 
 /* --- 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? */
@@ -76,7 +76,7 @@ static GMemChunk    *g_data_mem_chunk = NULL;
 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;
@@ -121,13 +121,13 @@ g_datalist_clear (GData **datalist)
 {
   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 */
@@ -174,7 +174,7 @@ g_dataset_destroy (gconstpointer  dataset_location)
 {
   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;
@@ -183,7 +183,7 @@ g_dataset_destroy (gconstpointer  dataset_location)
       if (dataset)
        g_dataset_destroy_internal (dataset);
     }
-  g_unlock (g_dataset_global);
+  G_UNLOCK (g_dataset_global);
 }
 
 /* HOLDS: g_dataset_global_lock */
@@ -312,7 +312,7 @@ g_dataset_id_set_data_full (gconstpointer  dataset_location,
        return;
     }
   
-  g_lock (g_dataset_global);
+  G_LOCK (g_dataset_global);
   if (!g_dataset_location_ht)
     g_data_initialize ();
  
@@ -328,7 +328,7 @@ g_dataset_id_set_data_full (gconstpointer  dataset_location,
     }
   
   g_data_set_internal (&dataset->datalist, key_id, data, destroy_func, dataset);
-  g_unlock (g_dataset_global);
+  G_UNLOCK (g_dataset_global);
 }
 
 void
@@ -348,12 +348,12 @@ g_datalist_id_set_data_full (GData          **datalist,
        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
@@ -362,7 +362,7 @@ g_dataset_id_remove_no_notify (gconstpointer  dataset_location,
 {
   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;
@@ -371,7 +371,7 @@ g_dataset_id_remove_no_notify (gconstpointer  dataset_location,
       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
@@ -380,10 +380,10 @@ g_datalist_id_remove_no_notify (GData     **datalist,
 {
   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
@@ -392,7 +392,7 @@ g_dataset_id_get_data (gconstpointer  dataset_location,
 {
   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;
@@ -405,12 +405,12 @@ g_dataset_id_get_data (gconstpointer  dataset_location,
          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;
 }
@@ -443,11 +443,11 @@ g_dataset_foreach (gconstpointer    dataset_location,
   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;
@@ -458,7 +458,7 @@ g_dataset_foreach (gconstpointer    dataset_location,
     }
   else
     {
-      g_unlock (g_dataset_global);
+      G_UNLOCK (g_dataset_global);
     }
 }
 
@@ -510,10 +510,10 @@ g_quark_try_string (const gchar *string)
   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;
 }
@@ -525,7 +525,7 @@ g_quark_from_string (const gchar *string)
   
   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
@@ -536,7 +536,7 @@ g_quark_from_string (const gchar *string)
   
   if (!quark)
     quark = g_quark_new (g_strdup (string));
-  g_unlock (g_quark_global);
+  G_UNLOCK (g_quark_global);
   
   return quark;
 }
@@ -548,7 +548,7 @@ g_quark_from_static_string (const gchar *string)
   
   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
@@ -559,7 +559,7 @@ g_quark_from_static_string (const gchar *string)
 
   if (!quark)
     quark = g_quark_new ((gchar*) string);
-  g_unlock (g_quark_global);
+  G_UNLOCK (g_quark_global);
  
   return quark;
 }
@@ -568,10 +568,10 @@ gchar*
 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;
 }
index 6672436..471aaad 100644 (file)
@@ -388,7 +388,7 @@ g_date_clear (GDate       *d, guint ndates)
   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
@@ -652,7 +652,7 @@ g_date_set_parse (GDate       *d,
   /* set invalid */
   g_date_clear (d, 1);
   
-  g_lock (g_date_global);
+  G_LOCK (g_date_global);
 
   g_date_prepare_to_parse (str, &pt);
   
@@ -664,7 +664,7 @@ g_date_set_parse (GDate       *d,
   
   if (pt.num_ints == 4) 
     {
-      g_unlock (g_date_global);
+      G_UNLOCK (g_date_global);
       return; /* presumably a typo; bail out. */
     }
   
@@ -782,7 +782,7 @@ g_date_set_parse (GDate       *d,
   else 
     g_message ("Rejected DMY %u %u %u", day, m, y);
 #endif
-  g_unlock (g_date_global);
+  G_UNLOCK (g_date_global);
 }
 
 void         
index 7240363..ed564e1 100644 (file)
@@ -57,7 +57,7 @@ static void           g_hash_node_destroy      (GHashNode     *hash_node);
 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;
@@ -345,7 +345,7 @@ g_hash_node_new (gpointer key,
 {
   GHashNode *hash_node;
   
-  g_lock (g_hash_global);
+  G_LOCK (g_hash_global);
   if (node_free_list)
     {
       hash_node = node_free_list;
@@ -360,7 +360,7 @@ g_hash_node_new (gpointer key,
       
       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;
@@ -372,10 +372,10 @@ g_hash_node_new (gpointer key,
 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
@@ -391,8 +391,8 @@ g_hash_nodes_destroy (GHashNode *hash_node)
   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);
 }
index 4ea3097..24e5a6b 100644 (file)
@@ -2007,7 +2007,8 @@ gint              g_scanner_stat_mode             (const gchar    *filename);
 } G_STMT_END
 
 
-/* Completion */
+/* GCompletion
+ */
 
 struct _GCompletion
 {
@@ -2030,28 +2031,32 @@ GList*       g_completion_complete     (GCompletion*    cmp,
 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,
@@ -2061,8 +2066,8 @@ typedef enum {
   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,
@@ -2078,22 +2083,17 @@ typedef enum {
   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
@@ -2109,105 +2109,95 @@ struct _GDate {
   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);
@@ -2217,11 +2207,7 @@ guint8       g_date_sunday_weeks_in_year  (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.
@@ -2230,12 +2216,12 @@ void         g_date_to_struct_tm          (GDate       *d,
 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.
  *
@@ -2295,47 +2281,47 @@ gpointer   g_tuples_index     (GTuples     *tuples,
 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
@@ -2351,27 +2337,27 @@ struct _GIOChannel
 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);
@@ -2400,19 +2386,20 @@ guint    g_io_add_watch         (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);
@@ -2424,10 +2411,9 @@ struct _GSourceFuncs {
   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,
@@ -2438,67 +2424,65 @@ void g_source_remove                (guint          tag);
 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).
@@ -2521,7 +2505,6 @@ struct _GIOChannel
                                 */
 #endif
 };
-
 GIOChannel *g_iochannel_new            (gint        fd);
 void        g_iochannel_free           (GIOChannel *channel);
 void        g_iochannel_close_and_free (GIOChannel *channel);
@@ -2529,16 +2512,14 @@ void        g_iochannel_wakeup_peer    (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
@@ -2553,30 +2534,27 @@ typedef int pid_t;
  * 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;
@@ -2586,7 +2564,6 @@ struct dirent
 {
   gchar  d_name[NAME_MAX + 1];
 };
-
 /* emulation functions */
 extern int     gwin_ftruncate  (gint            f,
                                 guint           size);
@@ -2594,145 +2571,153 @@ DIR*          gwin_opendir    (const gchar    *dirname);
 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)      (GMutexmutex);
-  gboolean (*mutex_trylock)   (GMutexmutex);
-  void     (*mutex_unlock)    (GMutexmutex);
-  void     (*mutex_free)      (GMutexmutex);
+  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
 }
index d4ddc6f..8656e3e 100644 (file)
@@ -36,7 +36,7 @@ struct _GAllocator /* from gmem.c */
 };
 
 static GAllocator      *current_allocator = NULL;
-static G_LOCK_DEFINE(current_allocator);
+G_LOCK_DECLARE_STATIC (current_allocator);
 
 /* HOLDS: current_allocator_lock */
 static void
@@ -70,17 +70,17 @@ g_list_validate_allocator (GAllocator *allocator)
 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;
@@ -90,7 +90,7 @@ g_list_pop_allocator (void)
       allocator->last = NULL;
       allocator->is_unused = TRUE;
     }
-  g_unlock (current_allocator);
+  G_UNLOCK (current_allocator);
 }
 
 GList*
@@ -98,7 +98,7 @@ g_list_alloc (void)
 {
   GList *list;
 
-  g_lock (current_allocator);
+  G_LOCK (current_allocator);
   if (!current_allocator)
     {
       GAllocator *allocator = g_allocator_new ("GLib default GList allocator",
@@ -126,7 +126,7 @@ g_list_alloc (void)
          current_allocator->free_lists = list->next;
        }
     }
-  g_unlock (current_allocator);
+  G_UNLOCK (current_allocator);
   list->next = NULL;
   list->prev = NULL;
   
@@ -139,10 +139,10 @@ g_list_free (GList *list)
   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);
     }
 }
 
@@ -152,10 +152,10 @@ g_list_free_1 (GList *list)
   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);
     }
 }
 
index 5d3ae8d..a6b0e5e 100644 (file)
@@ -101,7 +101,7 @@ static GHookList source_list = { 0 };
 /* 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,
@@ -232,7 +232,7 @@ g_source_add (gint           priority,
   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));
@@ -261,7 +261,7 @@ g_source_add (gint           priority,
       write (wake_up_pipe[1], "A", 1);
     }
 
-  g_unlock (main_loop);
+  G_UNLOCK (main_loop);
 
   return return_val;
 }
@@ -271,7 +271,7 @@ g_source_remove (guint tag)
 {
   GHook *hook;
 
-  g_lock (main_loop);
+  G_LOCK (main_loop);
 
   hook = g_hook_get (&source_list, tag);
   if (hook)
@@ -281,7 +281,7 @@ g_source_remove (guint tag)
       g_hook_destroy_link (&source_list, hook);
     }
 
-  g_unlock (main_loop);
+  G_UNLOCK (main_loop);
 }
 
 void 
@@ -289,7 +289,7 @@ g_source_remove_by_user_data (gpointer user_data)
 {
   GHook *hook;
   
-  g_lock (main_loop);
+  G_LOCK (main_loop);
   
   hook = g_hook_find_data (&source_list, TRUE, user_data);
   if (hook)
@@ -299,7 +299,7 @@ g_source_remove_by_user_data (gpointer user_data)
       g_hook_destroy_link (&source_list, hook);
     }
 
-  g_unlock (main_loop);
+  G_UNLOCK (main_loop);
 }
 
 static gboolean
@@ -315,7 +315,7 @@ g_source_remove_by_source_data (gpointer source_data)
 {
   GHook *hook;
 
-  g_lock (main_loop);
+  G_LOCK (main_loop);
 
   hook = g_hook_find (&source_list, TRUE, 
                             g_source_find_source_data, source_data);
@@ -326,7 +326,7 @@ g_source_remove_by_source_data (gpointer source_data)
       g_hook_destroy_link (&source_list, hook);
     }
 
-  g_unlock (main_loop);
+  G_UNLOCK (main_loop);
 }
 
 void g_get_current_time (GTimeVal *result)
@@ -360,11 +360,11 @@ g_main_dispatch (GTimeVal *current_time)
          
          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;
          
@@ -394,7 +394,7 @@ g_main_iterate (gboolean block, gboolean dispatch)
 
   g_get_current_time (&current_time);
 
-  g_lock (main_loop);
+  G_LOCK (main_loop);
   
   /* If recursing, finish up current dispatch, before starting over */
   if (pending_dispatches)
@@ -402,7 +402,7 @@ g_main_iterate (gboolean block, gboolean dispatch)
       if (dispatch)
        g_main_dispatch (&current_time);
       
-      g_unlock (main_loop);
+      G_UNLOCK (main_loop);
       return TRUE;
     }
 
@@ -434,7 +434,7 @@ g_main_iterate (gboolean block, gboolean dispatch)
          if (!dispatch)
            {
              g_hook_unref (&source_list, hook);
-             g_unlock (main_loop);
+             G_UNLOCK (main_loop);
              return TRUE;
            }
          else
@@ -499,7 +499,7 @@ g_main_iterate (gboolean block, gboolean dispatch)
          else
            {
              g_hook_unref (&source_list, hook);
-             g_unlock (main_loop);
+             G_UNLOCK (main_loop);
              return TRUE;
            }
        }
@@ -519,7 +519,7 @@ g_main_iterate (gboolean block, gboolean dispatch)
       retval = TRUE;
     }
 
-  g_unlock (main_loop);
+  G_UNLOCK (main_loop);
 
   return retval;
 }
@@ -605,10 +605,10 @@ g_main_poll (gint timeout, gboolean use_priority, gint priority)
 
   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)
     {
@@ -634,9 +634,9 @@ void
 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 
@@ -676,7 +676,7 @@ g_main_poll_add_unlocked (gint     priority,
 
   n_poll_records++;
 
-  g_unlock (main_loop);
+  G_UNLOCK (main_loop);
 }
 
 void 
@@ -684,7 +684,7 @@ g_main_poll_remove (GPollFD *fd)
 {
   GPollRec *pollrec, *lastrec;
 
-  g_lock (main_loop);
+  G_LOCK (main_loop);
   
   lastrec = NULL;
   pollrec = poll_records;
@@ -708,7 +708,7 @@ g_main_poll_remove (GPollFD *fd)
       pollrec = pollrec->next;
     }
 
-  g_unlock (main_loop);
+  G_UNLOCK (main_loop);
 }
 
 void 
index c9c135a..23245b3 100644 (file)
@@ -39,7 +39,7 @@ struct _GAllocator /* from gmem.c */
   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 */
@@ -74,17 +74,17 @@ g_node_validate_allocator (GAllocator *allocator)
 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;
@@ -94,7 +94,7 @@ g_node_pop_allocator (void)
       allocator->last = NULL;
       allocator->is_unused = TRUE;
     }
-  g_unlock (current_allocator);
+  G_UNLOCK (current_allocator);
 }
 
 
@@ -104,7 +104,7 @@ g_node_new (gpointer data)
 {
   GNode *node;
 
-  g_lock (current_allocator);
+  G_LOCK (current_allocator);
   if (!current_allocator)
     {
        GAllocator *allocator = g_allocator_new ("GLib default GNode allocator",
@@ -120,7 +120,7 @@ g_node_new (gpointer data)
       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;
@@ -147,10 +147,10 @@ g_nodes_free (GNode *node)
        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
index ec59e6c..8b20a3d 100644 (file)
@@ -35,7 +35,7 @@ struct _GAllocator /* from gmem.c */
   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 */
@@ -70,17 +70,17 @@ g_slist_validate_allocator (GAllocator *allocator)
 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;
@@ -90,7 +90,7 @@ g_slist_pop_allocator (void)
       allocator->last = NULL;
       allocator->is_unused = TRUE;
     }
-  g_unlock (current_allocator);
+  G_UNLOCK (current_allocator);
 }
 
 GSList*
@@ -98,7 +98,7 @@ g_slist_alloc (void)
 {
   GSList *list;
 
-  g_lock (current_allocator);
+  G_LOCK (current_allocator);
   if (!current_allocator)
     {
       GAllocator *allocator = g_allocator_new ("GLib default GSList allocator",
@@ -126,7 +126,7 @@ g_slist_alloc (void)
          current_allocator->free_lists = list->next;
        }
     }
-  g_unlock (current_allocator);
+  G_UNLOCK (current_allocator);
   
   list->next = NULL;
 
@@ -139,10 +139,10 @@ g_slist_free (GSList *list)
   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);
     }
 }
 
@@ -152,10 +152,10 @@ g_slist_free_1 (GSList *list)
   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);
     }
 }
 
index 312a540..a2718c6 100644 (file)
@@ -48,7 +48,7 @@ struct _GRealString
   gint   alloc;
 };
 
-static G_LOCK_DEFINE(string_mem_chunk);
+G_LOCK_DECLARE_STATIC (string_mem_chunk);
 static GMemChunk *string_mem_chunk = NULL;
 
 /* Hash Functions.
@@ -207,14 +207,14 @@ g_string_sized_new (guint dfl_size)
 {
   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;
@@ -248,9 +248,9 @@ g_string_free (GString *string,
   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*
index 006f15d..0fbf62f 100644 (file)
@@ -83,7 +83,7 @@ static GTreeNode* g_tree_node_rotate_right          (GTreeNode      *node);
 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;
 
@@ -94,7 +94,7 @@ g_tree_node_new (gpointer key,
 {
   GTreeNode *node;
 
-  g_lock (g_tree_global);
+  G_LOCK (g_tree_global);
   if (node_free_list)
     {
       node = node_free_list;
@@ -110,7 +110,7 @@ g_tree_node_new (gpointer key,
 
       node = g_chunk_new (GTreeNode, node_mem_chunk);
    }
-  g_unlock (g_tree_global);
+  G_UNLOCK (g_tree_global);
 
   node->balance = 0;
   node->left = NULL;
@@ -128,10 +128,10 @@ g_tree_node_destroy (GTreeNode *node)
     {
       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);
    }
 }
 
@@ -385,10 +385,10 @@ g_tree_node_remove (GTreeNode    *node,
          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)
     {
index 9a91199..c6958f1 100644 (file)
@@ -371,7 +371,7 @@ g_getenv (const gchar *variable)
 #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;
@@ -455,10 +455,10 @@ g_get_any_init (void)
 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;
 }
@@ -466,10 +466,10 @@ g_get_user_name (void)
 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;
 }
@@ -483,10 +483,10 @@ g_get_real_name (void)
 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;
 }
@@ -501,10 +501,10 @@ g_get_home_dir (void)
 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;
 }
@@ -516,9 +516,9 @@ g_get_prgname (void)
 {
   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;
 }
@@ -528,11 +528,11 @@ g_set_prgname (const gchar *prgname)
 {
   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
diff --git a/glist.c b/glist.c
index d4ddc6f..8656e3e 100644 (file)
--- a/glist.c
+++ b/glist.c
@@ -36,7 +36,7 @@ struct _GAllocator /* from gmem.c */
 };
 
 static GAllocator      *current_allocator = NULL;
-static G_LOCK_DEFINE(current_allocator);
+G_LOCK_DECLARE_STATIC (current_allocator);
 
 /* HOLDS: current_allocator_lock */
 static void
@@ -70,17 +70,17 @@ g_list_validate_allocator (GAllocator *allocator)
 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;
@@ -90,7 +90,7 @@ g_list_pop_allocator (void)
       allocator->last = NULL;
       allocator->is_unused = TRUE;
     }
-  g_unlock (current_allocator);
+  G_UNLOCK (current_allocator);
 }
 
 GList*
@@ -98,7 +98,7 @@ g_list_alloc (void)
 {
   GList *list;
 
-  g_lock (current_allocator);
+  G_LOCK (current_allocator);
   if (!current_allocator)
     {
       GAllocator *allocator = g_allocator_new ("GLib default GList allocator",
@@ -126,7 +126,7 @@ g_list_alloc (void)
          current_allocator->free_lists = list->next;
        }
     }
-  g_unlock (current_allocator);
+  G_UNLOCK (current_allocator);
   list->next = NULL;
   list->prev = NULL;
   
@@ -139,10 +139,10 @@ g_list_free (GList *list)
   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);
     }
 }
 
@@ -152,10 +152,10 @@ g_list_free_1 (GList *list)
   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);
     }
 }
 
diff --git a/gmain.c b/gmain.c
index 5d3ae8d..a6b0e5e 100644 (file)
--- a/gmain.c
+++ b/gmain.c
@@ -101,7 +101,7 @@ static GHookList source_list = { 0 };
 /* 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,
@@ -232,7 +232,7 @@ g_source_add (gint           priority,
   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));
@@ -261,7 +261,7 @@ g_source_add (gint           priority,
       write (wake_up_pipe[1], "A", 1);
     }
 
-  g_unlock (main_loop);
+  G_UNLOCK (main_loop);
 
   return return_val;
 }
@@ -271,7 +271,7 @@ g_source_remove (guint tag)
 {
   GHook *hook;
 
-  g_lock (main_loop);
+  G_LOCK (main_loop);
 
   hook = g_hook_get (&source_list, tag);
   if (hook)
@@ -281,7 +281,7 @@ g_source_remove (guint tag)
       g_hook_destroy_link (&source_list, hook);
     }
 
-  g_unlock (main_loop);
+  G_UNLOCK (main_loop);
 }
 
 void 
@@ -289,7 +289,7 @@ g_source_remove_by_user_data (gpointer user_data)
 {
   GHook *hook;
   
-  g_lock (main_loop);
+  G_LOCK (main_loop);
   
   hook = g_hook_find_data (&source_list, TRUE, user_data);
   if (hook)
@@ -299,7 +299,7 @@ g_source_remove_by_user_data (gpointer user_data)
       g_hook_destroy_link (&source_list, hook);
     }
 
-  g_unlock (main_loop);
+  G_UNLOCK (main_loop);
 }
 
 static gboolean
@@ -315,7 +315,7 @@ g_source_remove_by_source_data (gpointer source_data)
 {
   GHook *hook;
 
-  g_lock (main_loop);
+  G_LOCK (main_loop);
 
   hook = g_hook_find (&source_list, TRUE, 
                             g_source_find_source_data, source_data);
@@ -326,7 +326,7 @@ g_source_remove_by_source_data (gpointer source_data)
       g_hook_destroy_link (&source_list, hook);
     }
 
-  g_unlock (main_loop);
+  G_UNLOCK (main_loop);
 }
 
 void g_get_current_time (GTimeVal *result)
@@ -360,11 +360,11 @@ g_main_dispatch (GTimeVal *current_time)
          
          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;
          
@@ -394,7 +394,7 @@ g_main_iterate (gboolean block, gboolean dispatch)
 
   g_get_current_time (&current_time);
 
-  g_lock (main_loop);
+  G_LOCK (main_loop);
   
   /* If recursing, finish up current dispatch, before starting over */
   if (pending_dispatches)
@@ -402,7 +402,7 @@ g_main_iterate (gboolean block, gboolean dispatch)
       if (dispatch)
        g_main_dispatch (&current_time);
       
-      g_unlock (main_loop);
+      G_UNLOCK (main_loop);
       return TRUE;
     }
 
@@ -434,7 +434,7 @@ g_main_iterate (gboolean block, gboolean dispatch)
          if (!dispatch)
            {
              g_hook_unref (&source_list, hook);
-             g_unlock (main_loop);
+             G_UNLOCK (main_loop);
              return TRUE;
            }
          else
@@ -499,7 +499,7 @@ g_main_iterate (gboolean block, gboolean dispatch)
          else
            {
              g_hook_unref (&source_list, hook);
-             g_unlock (main_loop);
+             G_UNLOCK (main_loop);
              return TRUE;
            }
        }
@@ -519,7 +519,7 @@ g_main_iterate (gboolean block, gboolean dispatch)
       retval = TRUE;
     }
 
-  g_unlock (main_loop);
+  G_UNLOCK (main_loop);
 
   return retval;
 }
@@ -605,10 +605,10 @@ g_main_poll (gint timeout, gboolean use_priority, gint priority)
 
   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)
     {
@@ -634,9 +634,9 @@ void
 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 
@@ -676,7 +676,7 @@ g_main_poll_add_unlocked (gint     priority,
 
   n_poll_records++;
 
-  g_unlock (main_loop);
+  G_UNLOCK (main_loop);
 }
 
 void 
@@ -684,7 +684,7 @@ g_main_poll_remove (GPollFD *fd)
 {
   GPollRec *pollrec, *lastrec;
 
-  g_lock (main_loop);
+  G_LOCK (main_loop);
   
   lastrec = NULL;
   pollrec = poll_records;
@@ -708,7 +708,7 @@ g_main_poll_remove (GPollFD *fd)
       pollrec = pollrec->next;
     }
 
-  g_unlock (main_loop);
+  G_UNLOCK (main_loop);
 }
 
 void 
index 71f6145..99f38a6 100644 (file)
@@ -64,7 +64,7 @@ static inline GModule*        g_module_find_by_name   (const gchar    *name);
 
 
 /* --- 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;
@@ -78,7 +78,7 @@ g_module_find_by_handle (gpointer handle)
   GModule *module;
   GModule *retval = NULL;
   
-  g_lock (g_module_global);
+  G_LOCK (GModule);
   if (main_module && main_module->handle == handle)
     retval = main_module;
   else
@@ -88,7 +88,7 @@ g_module_find_by_handle (gpointer handle)
          retval = module;
          break;
        }
-  g_unlock (g_module_global);
+  G_UNLOCK (GModule);
 
   return retval;
 }
@@ -99,14 +99,14 @@ g_module_find_by_name (const gchar *name)
   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;
 }
@@ -198,7 +198,7 @@ g_module_open (const gchar    *file_name,
   
   if (!file_name)
     {      
-      g_lock (g_module_global);
+      G_LOCK (GModule);
       if (!main_module)
        {
          handle = _g_module_self ();
@@ -213,7 +213,7 @@ g_module_open (const gchar    *file_name,
              main_module->next = NULL;
            }
        }
-      g_unlock (g_module_global);
+      G_UNLOCK (GModule);
 
       return main_module;
     }
@@ -256,10 +256,10 @@ g_module_open (const gchar    *file_name,
       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))
@@ -313,7 +313,7 @@ g_module_close (GModule            *module)
       
       last = NULL;
       
-      g_lock (g_module_global);
+      G_LOCK (GModule);
       node = modules;
       while (node)
        {
@@ -329,7 +329,7 @@ g_module_close (GModule            *module)
          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);
index 2716f17..dfcad9d 100644 (file)
--- a/gmutex.c
+++ b/gmutex.c
@@ -40,7 +40,7 @@ static void g_thread_fail (void);
 /* 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 */
@@ -76,7 +76,7 @@ g_mutex_init (void)
   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);
@@ -88,7 +88,7 @@ g_mutex_init (void)
 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);
diff --git a/gnode.c b/gnode.c
index c9c135a..23245b3 100644 (file)
--- a/gnode.c
+++ b/gnode.c
@@ -39,7 +39,7 @@ struct _GAllocator /* from gmem.c */
   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 */
@@ -74,17 +74,17 @@ g_node_validate_allocator (GAllocator *allocator)
 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;
@@ -94,7 +94,7 @@ g_node_pop_allocator (void)
       allocator->last = NULL;
       allocator->is_unused = TRUE;
     }
-  g_unlock (current_allocator);
+  G_UNLOCK (current_allocator);
 }
 
 
@@ -104,7 +104,7 @@ g_node_new (gpointer data)
 {
   GNode *node;
 
-  g_lock (current_allocator);
+  G_LOCK (current_allocator);
   if (!current_allocator)
     {
        GAllocator *allocator = g_allocator_new ("GLib default GNode allocator",
@@ -120,7 +120,7 @@ g_node_new (gpointer data)
       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;
@@ -147,10 +147,10 @@ g_nodes_free (GNode *node)
        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
index ec59e6c..8b20a3d 100644 (file)
--- a/gslist.c
+++ b/gslist.c
@@ -35,7 +35,7 @@ struct _GAllocator /* from gmem.c */
   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 */
@@ -70,17 +70,17 @@ g_slist_validate_allocator (GAllocator *allocator)
 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;
@@ -90,7 +90,7 @@ g_slist_pop_allocator (void)
       allocator->last = NULL;
       allocator->is_unused = TRUE;
     }
-  g_unlock (current_allocator);
+  G_UNLOCK (current_allocator);
 }
 
 GSList*
@@ -98,7 +98,7 @@ g_slist_alloc (void)
 {
   GSList *list;
 
-  g_lock (current_allocator);
+  G_LOCK (current_allocator);
   if (!current_allocator)
     {
       GAllocator *allocator = g_allocator_new ("GLib default GSList allocator",
@@ -126,7 +126,7 @@ g_slist_alloc (void)
          current_allocator->free_lists = list->next;
        }
     }
-  g_unlock (current_allocator);
+  G_UNLOCK (current_allocator);
   
   list->next = NULL;
 
@@ -139,10 +139,10 @@ g_slist_free (GSList *list)
   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);
     }
 }
 
@@ -152,10 +152,10 @@ g_slist_free_1 (GSList *list)
   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);
     }
 }
 
index 312a540..a2718c6 100644 (file)
--- a/gstring.c
+++ b/gstring.c
@@ -48,7 +48,7 @@ struct _GRealString
   gint   alloc;
 };
 
-static G_LOCK_DEFINE(string_mem_chunk);
+G_LOCK_DECLARE_STATIC (string_mem_chunk);
 static GMemChunk *string_mem_chunk = NULL;
 
 /* Hash Functions.
@@ -207,14 +207,14 @@ g_string_sized_new (guint dfl_size)
 {
   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;
@@ -248,9 +248,9 @@ g_string_free (GString *string,
   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*
index d6805ef..04b0ecd 100644 (file)
@@ -1,3 +1,9 @@
+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.
index c81bbec..72242b6 100644 (file)
@@ -17,8 +17,7 @@ libgthread_la_LDFLAGS = \
        -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 
index 8ada7f8..bca35ac 100644 (file)
@@ -40,12 +40,16 @@ void g_mem_init (void);
 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;
 
@@ -56,29 +60,28 @@ g_thread_init(GThreadFunctions* init)
 
   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)
@@ -88,14 +91,14 @@ g_thread_init(GThreadFunctions* init)
     }
 
   /* 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;
 }
index 5312e34..f6445ac 100644 (file)
@@ -13,9 +13,9 @@ test_mutexes ()
   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 ();
@@ -30,10 +30,10 @@ test_mutexes ()
   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);
diff --git a/gtree.c b/gtree.c
index 006f15d..0fbf62f 100644 (file)
--- a/gtree.c
+++ b/gtree.c
@@ -83,7 +83,7 @@ static GTreeNode* g_tree_node_rotate_right          (GTreeNode      *node);
 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;
 
@@ -94,7 +94,7 @@ g_tree_node_new (gpointer key,
 {
   GTreeNode *node;
 
-  g_lock (g_tree_global);
+  G_LOCK (g_tree_global);
   if (node_free_list)
     {
       node = node_free_list;
@@ -110,7 +110,7 @@ g_tree_node_new (gpointer key,
 
       node = g_chunk_new (GTreeNode, node_mem_chunk);
    }
-  g_unlock (g_tree_global);
+  G_UNLOCK (g_tree_global);
 
   node->balance = 0;
   node->left = NULL;
@@ -128,10 +128,10 @@ g_tree_node_destroy (GTreeNode *node)
     {
       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);
    }
 }
 
@@ -385,10 +385,10 @@ g_tree_node_remove (GTreeNode    *node,
          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)
     {
index 9a91199..c6958f1 100644 (file)
--- a/gutils.c
+++ b/gutils.c
@@ -371,7 +371,7 @@ g_getenv (const gchar *variable)
 #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;
@@ -455,10 +455,10 @@ g_get_any_init (void)
 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;
 }
@@ -466,10 +466,10 @@ g_get_user_name (void)
 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;
 }
@@ -483,10 +483,10 @@ g_get_real_name (void)
 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;
 }
@@ -501,10 +501,10 @@ g_get_home_dir (void)
 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;
 }
@@ -516,9 +516,9 @@ g_get_prgname (void)
 {
   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;
 }
@@ -528,11 +528,11 @@ g_set_prgname (const gchar *prgname)
 {
   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