s/G_LOCK_DECLARE/G_LOCK_DEFINE/ throuhout glib. Added G_LOCK_EXTERN macro
authorSebastian Wilhelmi <wilhelmi@ira.uka.de>
Wed, 10 Feb 1999 09:40:46 +0000 (09:40 +0000)
committerSebastian Wilhelmi <wilhelmi@src.gnome.org>
Wed, 10 Feb 1999 09:40:46 +0000 (09:40 +0000)
1999-02-10  Sebastian Wilhelmi  <wilhelmi@ira.uka.de>

* glib.h: s/G_LOCK_DECLARE/G_LOCK_DEFINE/ throuhout glib. Added
G_LOCK_EXTERN macro to declare a lock externally.

28 files changed:
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
gnode.c
gslist.c
gstring.c
gthread/testgthread.c
gtree.c
gutils.c

index 54bbe44..ba7adcd 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;
-G_LOCK_DECLARE_STATIC (array_mem_chunk);
+G_LOCK_DEFINE_STATIC (array_mem_chunk);
 
 GArray*
 g_array_new (gboolean zero_terminated,
@@ -250,7 +250,7 @@ static void g_ptr_array_maybe_expand (GRealPtrArray *array,
                                      gint           len);
 
 static GMemChunk *ptr_array_mem_chunk = NULL;
-G_LOCK_DECLARE_STATIC (ptr_array_mem_chunk);
+G_LOCK_DEFINE_STATIC (ptr_array_mem_chunk);
 
 
 GPtrArray*
index c9ed61f..48b6111 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;
-G_LOCK_DECLARE_STATIC (node_mem_chunk);
+G_LOCK_DEFINE_STATIC (node_mem_chunk);
 
 GCache*
 g_cache_new (GCacheNewFunc      value_new_func,
index 8aadb96..5f85359 100644 (file)
@@ -67,7 +67,7 @@ static inline GQuark  g_quark_new                     (gchar          *string);
 
 
 /* --- variables --- */
-G_LOCK_DECLARE_STATIC (g_dataset_global);
+G_LOCK_DEFINE_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;
 
-G_LOCK_DECLARE_STATIC (g_quark_global);
+G_LOCK_DEFINE_STATIC (g_quark_global);
 static GHashTable   *g_quark_ht = NULL;
 static gchar       **g_quarks = NULL;
 static GQuark        g_quark_seq_id = 0;
diff --git a/gdate.c b/gdate.c
index c3b7b31..5df9787 100644 (file)
--- a/gdate.c
+++ b/gdate.c
@@ -392,7 +392,7 @@ g_date_clear (GDate       *d, guint ndates)
   memset (d, 0x0, ndates*sizeof (GDate)); 
 }
 
-G_LOCK_DECLARE_STATIC (g_date_global);
+G_LOCK_DEFINE_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
diff --git a/ghash.c b/ghash.c
index 8de3a5c..02fddbe 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);
 
 
-G_LOCK_DECLARE_STATIC (g_hash_global);
+G_LOCK_DEFINE_STATIC (g_hash_global);
 
 static GMemChunk *node_mem_chunk = NULL;
 static GHashNode *node_free_list = NULL;
diff --git a/glib.h b/glib.h
index 46f1465..84306af 100644 (file)
--- a/glib.h
+++ b/glib.h
@@ -2718,20 +2718,22 @@ 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.
+/* these are some convenience macros that expand to nothing if GLib
+ * was configured with --disable-threads. for using StaticMutexes,
+ * you define them with G_LOCK_DEFINE_STATIC (name) or G_LOCK_DEFINE (name)
+ * if you need to export the mutex. With G_LOCK_EXTERN (name) you can
+ * declare such an globally defined lock. 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 void glib_dummy_decl (void);
 #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)         \
+#  define G_LOCK_DEFINE_STATIC(name)   static G_LOCK_DEFINE (name)
+#  define G_LOCK_DEFINE(name)          \
     GStaticMutex G_LOCK_NAME (name) = G_STATIC_MUTEX_INIT 
+#  define G_LOCK_EXTERN(name)          extern GStaticMutex G_LOCK_NAME (name)
 
 #  ifdef G_DEBUG_LOCKS
 #    define G_LOCK(name)               G_STMT_START{             \
@@ -2760,8 +2762,9 @@ extern void glib_dummy_decl (void);
 #    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 void glib_dummy_decl (void)
-#  define G_LOCK_DECLARE(name)         extern void glib_dummy_decl (void)
+#  define G_LOCK_DEFINE_STATIC(name)   extern void glib_dummy_decl (void)
+#  define G_LOCK_DEFINE(name)          extern void glib_dummy_decl (void)
+#  define G_LOCK_EXTERN(name)          extern void glib_dummy_decl (void)
 #  define G_LOCK(name)
 #  define G_UNLOCK(name)
 #  define G_TRYLOCK(name)              (FALSE)
index 54bbe44..ba7adcd 100644 (file)
@@ -46,7 +46,7 @@ static void g_array_maybe_expand (GRealArray *array,
                                  gint        len);
 
 static GMemChunk *array_mem_chunk = NULL;
-G_LOCK_DECLARE_STATIC (array_mem_chunk);
+G_LOCK_DEFINE_STATIC (array_mem_chunk);
 
 GArray*
 g_array_new (gboolean zero_terminated,
@@ -250,7 +250,7 @@ static void g_ptr_array_maybe_expand (GRealPtrArray *array,
                                      gint           len);
 
 static GMemChunk *ptr_array_mem_chunk = NULL;
-G_LOCK_DECLARE_STATIC (ptr_array_mem_chunk);
+G_LOCK_DEFINE_STATIC (ptr_array_mem_chunk);
 
 
 GPtrArray*
index c9ed61f..48b6111 100644 (file)
@@ -61,7 +61,7 @@ static void        g_cache_node_destroy (GCacheNode *node);
 
 
 static GMemChunk *node_mem_chunk = NULL;
-G_LOCK_DECLARE_STATIC (node_mem_chunk);
+G_LOCK_DEFINE_STATIC (node_mem_chunk);
 
 GCache*
 g_cache_new (GCacheNewFunc      value_new_func,
index 8aadb96..5f85359 100644 (file)
@@ -67,7 +67,7 @@ static inline GQuark  g_quark_new                     (gchar          *string);
 
 
 /* --- variables --- */
-G_LOCK_DECLARE_STATIC (g_dataset_global);
+G_LOCK_DEFINE_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;
 
-G_LOCK_DECLARE_STATIC (g_quark_global);
+G_LOCK_DEFINE_STATIC (g_quark_global);
 static GHashTable   *g_quark_ht = NULL;
 static gchar       **g_quarks = NULL;
 static GQuark        g_quark_seq_id = 0;
index c3b7b31..5df9787 100644 (file)
@@ -392,7 +392,7 @@ g_date_clear (GDate       *d, guint ndates)
   memset (d, 0x0, ndates*sizeof (GDate)); 
 }
 
-G_LOCK_DECLARE_STATIC (g_date_global);
+G_LOCK_DEFINE_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
index 8de3a5c..02fddbe 100644 (file)
@@ -57,7 +57,7 @@ static void           g_hash_node_destroy      (GHashNode     *hash_node);
 static void            g_hash_nodes_destroy     (GHashNode     *hash_node);
 
 
-G_LOCK_DECLARE_STATIC (g_hash_global);
+G_LOCK_DEFINE_STATIC (g_hash_global);
 
 static GMemChunk *node_mem_chunk = NULL;
 static GHashNode *node_free_list = NULL;
index 46f1465..84306af 100644 (file)
@@ -2718,20 +2718,22 @@ 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.
+/* these are some convenience macros that expand to nothing if GLib
+ * was configured with --disable-threads. for using StaticMutexes,
+ * you define them with G_LOCK_DEFINE_STATIC (name) or G_LOCK_DEFINE (name)
+ * if you need to export the mutex. With G_LOCK_EXTERN (name) you can
+ * declare such an globally defined lock. 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 void glib_dummy_decl (void);
 #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)         \
+#  define G_LOCK_DEFINE_STATIC(name)   static G_LOCK_DEFINE (name)
+#  define G_LOCK_DEFINE(name)          \
     GStaticMutex G_LOCK_NAME (name) = G_STATIC_MUTEX_INIT 
+#  define G_LOCK_EXTERN(name)          extern GStaticMutex G_LOCK_NAME (name)
 
 #  ifdef G_DEBUG_LOCKS
 #    define G_LOCK(name)               G_STMT_START{             \
@@ -2760,8 +2762,9 @@ extern void glib_dummy_decl (void);
 #    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 void glib_dummy_decl (void)
-#  define G_LOCK_DECLARE(name)         extern void glib_dummy_decl (void)
+#  define G_LOCK_DEFINE_STATIC(name)   extern void glib_dummy_decl (void)
+#  define G_LOCK_DEFINE(name)          extern void glib_dummy_decl (void)
+#  define G_LOCK_EXTERN(name)          extern void glib_dummy_decl (void)
 #  define G_LOCK(name)
 #  define G_UNLOCK(name)
 #  define G_TRYLOCK(name)              (FALSE)
index 802e526..535a699 100644 (file)
@@ -36,7 +36,7 @@ struct _GAllocator /* from gmem.c */
 };
 
 static GAllocator      *current_allocator = NULL;
-G_LOCK_DECLARE_STATIC (current_allocator);
+G_LOCK_DEFINE_STATIC (current_allocator);
 
 /* HOLDS: current_allocator_lock */
 static void
index 312402f..2e5b5f6 100644 (file)
@@ -128,7 +128,7 @@ static gint in_check_or_prepare = 0;
 /* The following lock is used for both the list of sources
  * and the list of poll records
  */
-G_LOCK_DECLARE_STATIC (main_loop);
+G_LOCK_DEFINE_STATIC (main_loop);
 
 static GSourceFuncs timeout_funcs =
 {
index 6f48560..6b4ead5 100644 (file)
@@ -39,7 +39,7 @@ struct _GAllocator /* from gmem.c */
   GNode         *free_nodes; /* implementation specific */
 };
 
-G_LOCK_DECLARE_STATIC (current_allocator);
+G_LOCK_DEFINE_STATIC (current_allocator);
 static GAllocator *current_allocator = NULL;
 
 /* HOLDS: current_allocator_lock */
index 76452cd..35c0435 100644 (file)
@@ -35,7 +35,7 @@ struct _GAllocator /* from gmem.c */
   GSList        *free_lists; /* implementation specific */
 };
 
-G_LOCK_DECLARE_STATIC (current_allocator);
+G_LOCK_DEFINE_STATIC (current_allocator);
 static GAllocator       *current_allocator = NULL;
 
 /* HOLDS: current_allocator_lock */
index a2718c6..6a6a39d 100644 (file)
@@ -48,7 +48,7 @@ struct _GRealString
   gint   alloc;
 };
 
-G_LOCK_DECLARE_STATIC (string_mem_chunk);
+G_LOCK_DEFINE_STATIC (string_mem_chunk);
 static GMemChunk *string_mem_chunk = NULL;
 
 /* Hash Functions.
index 5b4e342..f764ac0 100644 (file)
@@ -83,7 +83,7 @@ static GTreeNode* g_tree_node_rotate_right          (GTreeNode      *node);
 static void       g_tree_node_check                 (GTreeNode      *node);
 
 
-G_LOCK_DECLARE_STATIC (g_tree_global);
+G_LOCK_DEFINE_STATIC (g_tree_global);
 static GMemChunk *node_mem_chunk = NULL;
 static GTreeNode *node_free_list = NULL;
 
index 8e4d1f9..7fb2409 100644 (file)
@@ -372,7 +372,7 @@ g_getenv (const gchar *variable)
 }
 
 
-G_LOCK_DECLARE_STATIC (g_utils_global);
+G_LOCK_DEFINE_STATIC (g_utils_global);
 
 static gchar   *g_tmp_dir = NULL;
 static gchar   *g_user_name = NULL;
diff --git a/glist.c b/glist.c
index 802e526..535a699 100644 (file)
--- a/glist.c
+++ b/glist.c
@@ -36,7 +36,7 @@ struct _GAllocator /* from gmem.c */
 };
 
 static GAllocator      *current_allocator = NULL;
-G_LOCK_DECLARE_STATIC (current_allocator);
+G_LOCK_DEFINE_STATIC (current_allocator);
 
 /* HOLDS: current_allocator_lock */
 static void
diff --git a/gmain.c b/gmain.c
index 312402f..2e5b5f6 100644 (file)
--- a/gmain.c
+++ b/gmain.c
@@ -128,7 +128,7 @@ static gint in_check_or_prepare = 0;
 /* The following lock is used for both the list of sources
  * and the list of poll records
  */
-G_LOCK_DECLARE_STATIC (main_loop);
+G_LOCK_DEFINE_STATIC (main_loop);
 
 static GSourceFuncs timeout_funcs =
 {
index 463bcb1..3cc5ad2 100644 (file)
@@ -64,7 +64,7 @@ static inline GModule*        g_module_find_by_name   (const gchar    *name);
 
 
 /* --- variables --- */
-G_LOCK_DECLARE_STATIC (GModule);
+G_LOCK_DEFINE_STATIC (GModule);
 const char           *g_log_domain_gmodule = "GModule";
 static GModule      *modules = NULL;
 static GModule      *main_module = NULL;
diff --git a/gnode.c b/gnode.c
index 6f48560..6b4ead5 100644 (file)
--- a/gnode.c
+++ b/gnode.c
@@ -39,7 +39,7 @@ struct _GAllocator /* from gmem.c */
   GNode         *free_nodes; /* implementation specific */
 };
 
-G_LOCK_DECLARE_STATIC (current_allocator);
+G_LOCK_DEFINE_STATIC (current_allocator);
 static GAllocator *current_allocator = NULL;
 
 /* HOLDS: current_allocator_lock */
index 76452cd..35c0435 100644 (file)
--- a/gslist.c
+++ b/gslist.c
@@ -35,7 +35,7 @@ struct _GAllocator /* from gmem.c */
   GSList        *free_lists; /* implementation specific */
 };
 
-G_LOCK_DECLARE_STATIC (current_allocator);
+G_LOCK_DEFINE_STATIC (current_allocator);
 static GAllocator       *current_allocator = NULL;
 
 /* HOLDS: current_allocator_lock */
index a2718c6..6a6a39d 100644 (file)
--- a/gstring.c
+++ b/gstring.c
@@ -48,7 +48,7 @@ struct _GRealString
   gint   alloc;
 };
 
-G_LOCK_DECLARE_STATIC (string_mem_chunk);
+G_LOCK_DEFINE_STATIC (string_mem_chunk);
 static GMemChunk *string_mem_chunk = NULL;
 
 /* Hash Functions.
index 2eb5b48..493a47e 100644 (file)
@@ -15,7 +15,7 @@ test_mutexes (void)
   GMutex *mutex = NULL;
   GCond *cond = NULL;
   GStaticMutex static_mutex = G_STATIC_MUTEX_INIT;
-  G_LOCK_DECLARE (test_me);
+  G_LOCK_DEFINE (test_me);
 
   if (g_thread_supported ())
     {
diff --git a/gtree.c b/gtree.c
index 5b4e342..f764ac0 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);
 
 
-G_LOCK_DECLARE_STATIC (g_tree_global);
+G_LOCK_DEFINE_STATIC (g_tree_global);
 static GMemChunk *node_mem_chunk = NULL;
 static GTreeNode *node_free_list = NULL;
 
index 8e4d1f9..7fb2409 100644 (file)
--- a/gutils.c
+++ b/gutils.c
@@ -372,7 +372,7 @@ g_getenv (const gchar *variable)
 }
 
 
-G_LOCK_DECLARE_STATIC (g_utils_global);
+G_LOCK_DEFINE_STATIC (g_utils_global);
 
 static gchar   *g_tmp_dir = NULL;
 static gchar   *g_user_name = NULL;