From b37e032581c44135b480dc74ae0355e72eef1372 Mon Sep 17 00:00:00 2001 From: Sebastian Wilhelmi Date: Wed, 10 Feb 1999 09:40:46 +0000 Subject: [PATCH] s/G_LOCK_DECLARE/G_LOCK_DEFINE/ throuhout glib. Added G_LOCK_EXTERN macro 1999-02-10 Sebastian Wilhelmi * glib.h: s/G_LOCK_DECLARE/G_LOCK_DEFINE/ throuhout glib. Added G_LOCK_EXTERN macro to declare a lock externally. --- garray.c | 4 ++-- gcache.c | 2 +- gdataset.c | 4 ++-- gdate.c | 2 +- ghash.c | 2 +- glib.h | 25 ++++++++++++++----------- glib/garray.c | 4 ++-- glib/gcache.c | 2 +- glib/gdataset.c | 4 ++-- glib/gdate.c | 2 +- glib/ghash.c | 2 +- glib/glib.h | 25 ++++++++++++++----------- glib/glist.c | 2 +- glib/gmain.c | 2 +- glib/gnode.c | 2 +- glib/gslist.c | 2 +- glib/gstring.c | 2 +- glib/gtree.c | 2 +- glib/gutils.c | 2 +- glist.c | 2 +- gmain.c | 2 +- gmodule/gmodule.c | 2 +- gnode.c | 2 +- gslist.c | 2 +- gstring.c | 2 +- gthread/testgthread.c | 2 +- gtree.c | 2 +- gutils.c | 2 +- 28 files changed, 58 insertions(+), 52 deletions(-) diff --git a/garray.c b/garray.c index 54bbe44df..ba7adcde6 100644 --- 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* diff --git a/gcache.c b/gcache.c index c9ed61f44..48b6111b5 100644 --- 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, diff --git a/gdataset.c b/gdataset.c index 8aadb9626..5f85359c4 100644 --- a/gdataset.c +++ b/gdataset.c @@ -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 c3b7b3186..5df9787e6 100644 --- 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 8de3a5cd3..02fddbe07 100644 --- 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 46f1465f8..84306afeb 100644 --- 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) diff --git a/glib/garray.c b/glib/garray.c index 54bbe44df..ba7adcde6 100644 --- a/glib/garray.c +++ b/glib/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* diff --git a/glib/gcache.c b/glib/gcache.c index c9ed61f44..48b6111b5 100644 --- a/glib/gcache.c +++ b/glib/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, diff --git a/glib/gdataset.c b/glib/gdataset.c index 8aadb9626..5f85359c4 100644 --- a/glib/gdataset.c +++ b/glib/gdataset.c @@ -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/glib/gdate.c b/glib/gdate.c index c3b7b3186..5df9787e6 100644 --- a/glib/gdate.c +++ b/glib/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/glib/ghash.c b/glib/ghash.c index 8de3a5cd3..02fddbe07 100644 --- a/glib/ghash.c +++ b/glib/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/glib.h b/glib/glib.h index 46f1465f8..84306afeb 100644 --- a/glib/glib.h +++ b/glib/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) diff --git a/glib/glist.c b/glib/glist.c index 802e5269e..535a6997f 100644 --- a/glib/glist.c +++ b/glib/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/glib/gmain.c b/glib/gmain.c index 312402faa..2e5b5f6c0 100644 --- a/glib/gmain.c +++ b/glib/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 = { diff --git a/glib/gnode.c b/glib/gnode.c index 6f4856067..6b4ead54f 100644 --- a/glib/gnode.c +++ b/glib/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 */ diff --git a/glib/gslist.c b/glib/gslist.c index 76452cd27..35c043562 100644 --- a/glib/gslist.c +++ b/glib/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 */ diff --git a/glib/gstring.c b/glib/gstring.c index a2718c695..6a6a39d89 100644 --- a/glib/gstring.c +++ b/glib/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. diff --git a/glib/gtree.c b/glib/gtree.c index 5b4e342bb..f764ac02d 100644 --- a/glib/gtree.c +++ b/glib/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; diff --git a/glib/gutils.c b/glib/gutils.c index 8e4d1f9aa..7fb240995 100644 --- a/glib/gutils.c +++ b/glib/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; diff --git a/glist.c b/glist.c index 802e5269e..535a6997f 100644 --- 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 312402faa..2e5b5f6c0 100644 --- 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 = { diff --git a/gmodule/gmodule.c b/gmodule/gmodule.c index 463bcb16a..3cc5ad21f 100644 --- a/gmodule/gmodule.c +++ b/gmodule/gmodule.c @@ -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 6f4856067..6b4ead54f 100644 --- 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 */ diff --git a/gslist.c b/gslist.c index 76452cd27..35c043562 100644 --- 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 */ diff --git a/gstring.c b/gstring.c index a2718c695..6a6a39d89 100644 --- 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. diff --git a/gthread/testgthread.c b/gthread/testgthread.c index 2eb5b4861..493a47e9b 100644 --- a/gthread/testgthread.c +++ b/gthread/testgthread.c @@ -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 5b4e342bb..f764ac02d 100644 --- 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; diff --git a/gutils.c b/gutils.c index 8e4d1f9aa..7fb240995 100644 --- 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;