mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-24 22:46:15 +01:00
s/G_LOCK_DECLARE/G_LOCK_DEFINE/ throuhout glib. Added G_LOCK_EXTERN macro
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.
This commit is contained in:
parent
a8ff1b4fce
commit
b37e032581
4
garray.c
4
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*
|
||||
|
2
gcache.c
2
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,
|
||||
|
@ -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;
|
||||
|
2
gdate.c
2
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
|
||||
|
2
ghash.c
2
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;
|
||||
|
25
glib.h
25
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)
|
||||
|
@ -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*
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
25
glib/glib.h
25
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)
|
||||
|
@ -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
|
||||
|
@ -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 =
|
||||
{
|
||||
|
@ -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 */
|
||||
|
@ -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 */
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
2
glist.c
2
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
|
||||
|
2
gmain.c
2
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 =
|
||||
{
|
||||
|
@ -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;
|
||||
|
2
gnode.c
2
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 */
|
||||
|
2
gslist.c
2
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 */
|
||||
|
@ -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.
|
||||
|
@ -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 ())
|
||||
{
|
||||
|
2
gtree.c
2
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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user