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 54bbe44dfe5e6683fd8722e4319440e68a4dd9bd..ba7adcde684ee7ff6ee833e8e04cac502af9b499 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 c9ed61f44b64c6518313bd88e2dd4183af171c69..48b6111b5d3045c728ddb4bd440417065497cf82 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 8aadb9626a398f13ebbe5d7dd6d4621f8b5d8bd9..5f85359c4b3cbb16c01c1ec7e5602fe9986e727e 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 c3b7b31862c138037e33f1f93b573ce0029cd25e..5df9787e6c494e24249fe3343d3f2a95a671430f 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 8de3a5cd340c74c0395a753884390ec036025c05..02fddbe071b68ec2a5e7dac9c12ea4ed8d069ce1 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 46f1465f8f5ec3c92cd4f997b3d420c3a0b45a6f..84306afeb66db08e8c0653abeace73154e84422a 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 54bbe44dfe5e6683fd8722e4319440e68a4dd9bd..ba7adcde684ee7ff6ee833e8e04cac502af9b499 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 c9ed61f44b64c6518313bd88e2dd4183af171c69..48b6111b5d3045c728ddb4bd440417065497cf82 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 8aadb9626a398f13ebbe5d7dd6d4621f8b5d8bd9..5f85359c4b3cbb16c01c1ec7e5602fe9986e727e 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 c3b7b31862c138037e33f1f93b573ce0029cd25e..5df9787e6c494e24249fe3343d3f2a95a671430f 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 8de3a5cd340c74c0395a753884390ec036025c05..02fddbe071b68ec2a5e7dac9c12ea4ed8d069ce1 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 46f1465f8f5ec3c92cd4f997b3d420c3a0b45a6f..84306afeb66db08e8c0653abeace73154e84422a 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 802e5269e01cb2e6c36848600e6b2c6fbdfd657a..535a6997f19f1d2018a511b7efb173829b509023 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 312402faa6cda90cd56dc4cf490cd929e852c5ae..2e5b5f6c014427aafc51a797ef2896fae04e9f44 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 6f48560679107e09d14a22d770152b0c50c1bf71..6b4ead54fd706911c83ece5f2cce6e9f59ec2851 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 76452cd27ed62e36ee2e2c5b1c0b62b49298fc24..35c04356258209e4777885cd2c4f0ac60a31a86a 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 a2718c69539df9ba5db7bcd4019a1fdf5a3903ba..6a6a39d89c3969135dd5ef1fa4060609567ec3a2 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 5b4e342bb3385510357f965cec897c235e78f513..f764ac02de68d94b8f3570aa13b5277446ae252a 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 8e4d1f9aa655bd2c1c8a3172d0f51bb7a287aa1b..7fb240995d6f79ff1a3768a7949cc66fed792f37 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 802e5269e01cb2e6c36848600e6b2c6fbdfd657a..535a6997f19f1d2018a511b7efb173829b509023 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 312402faa6cda90cd56dc4cf490cd929e852c5ae..2e5b5f6c014427aafc51a797ef2896fae04e9f44 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 463bcb16a1c6bb32a990559dc70dd2a00942da60..3cc5ad21f5482ebd6bce0ab3073dd1acce2a840d 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 6f48560679107e09d14a22d770152b0c50c1bf71..6b4ead54fd706911c83ece5f2cce6e9f59ec2851 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 76452cd27ed62e36ee2e2c5b1c0b62b49298fc24..35c04356258209e4777885cd2c4f0ac60a31a86a 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 a2718c69539df9ba5db7bcd4019a1fdf5a3903ba..6a6a39d89c3969135dd5ef1fa4060609567ec3a2 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 2eb5b4861d3c57c029071127f3a7662167d0d130..493a47e9be6a1438d63b38bceaf9886ca6e4a871 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 5b4e342bb3385510357f965cec897c235e78f513..f764ac02de68d94b8f3570aa13b5277446ae252a 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 8e4d1f9aa655bd2c1c8a3172d0f51bb7a287aa1b..7fb240995d6f79ff1a3768a7949cc66fed792f37 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;