X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=glib.h;h=8f4975a1df6977e360fa07d42665f5952fa26b48;hb=da87b1ac8505eacf293b9dfc985e5ae93a82a4b7;hp=03951b6e81df78e4a3923dfba64d6f7ce637007e;hpb=5c2fb3762f9174d78213b2b2d8934883919b4f67;p=platform%2Fupstream%2Fglib.git diff --git a/glib.h b/glib.h index 03951b6..8f4975a 100644 --- a/glib.h +++ b/glib.h @@ -16,6 +16,14 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ + +/* + * Modified by the GLib Team and others 1997-1999. See the AUTHORS + * file for a list of people on the GLib Team. See the ChangeLog + * files for a list of changes. These files are distributed with + * GLib at ftp://ftp.gtk.org/pub/gtk/. + */ + #ifndef __G_LIB_H__ #define __G_LIB_H__ @@ -50,7 +58,7 @@ * To register hooks which are executed on exit(). * Usually a wrapper for STDC atexit. * - * void *g_memmove(void *dest, const void *src, guint count); + * void g_memmove(gpointer dest, gconstpointer void *src, gulong count); * A wrapper for STDC memmove, or an implementation, if memmove doesn't * exist. The prototype looks like the above, give or take a const, * or size_t. @@ -462,6 +470,13 @@ typedef unsigned short gushort; typedef unsigned long gulong; typedef unsigned int guint; +#define G_GSHORT_FORMAT "hi" +#define G_GUSHORT_FORMAT "hu" +#define G_GINT_FORMAT "i" +#define G_GUINT_FORMAT "u" +#define G_GLONG_FORMAT "li" +#define G_GULONG_FORMAT "lu" + typedef float gfloat; typedef double gdouble; @@ -660,6 +675,11 @@ GUTILS_C_VAR const guint glib_micro_version; GUTILS_C_VAR const guint glib_interface_age; GUTILS_C_VAR const guint glib_binary_age; +#define GLIB_CHECK_VERSION(major,minor,micro) \ + (GLIB_MAJOR_VERSION > (major) || \ + (GLIB_MAJOR_VERSION == (major) && GLIB_MINOR_VERSION > (minor)) || \ + (GLIB_MAJOR_VERSION == (major) && GLIB_MINOR_VERSION == (minor) && \ + GLIB_MICRO_VERSION >= (micro))) /* Forward declarations of glib types. */ @@ -677,10 +697,13 @@ typedef struct _GList GList; typedef struct _GMemChunk GMemChunk; typedef struct _GNode GNode; typedef struct _GPtrArray GPtrArray; +typedef struct _GQueue GQueue; +typedef struct _GRand GRand; typedef struct _GRelation GRelation; typedef struct _GScanner GScanner; typedef struct _GScannerConfig GScannerConfig; typedef struct _GSList GSList; +typedef struct _GStack GStack; typedef struct _GString GString; typedef struct _GStringChunk GStringChunk; typedef struct _GTimer GTimer; @@ -797,6 +820,18 @@ struct _GSList GSList *next; }; +struct _GStack +{ + GList *list; +}; + +struct _GQueue +{ + GList *list; + GList *list_end; + guint list_size; +}; + struct _GString { gchar *str; @@ -852,6 +887,8 @@ GList* g_list_insert_sorted (GList *list, GCompareFunc func); GList* g_list_concat (GList *list1, GList *list2); +GList* g_list_delete (GList *list, + GList *link); GList* g_list_remove (GList *list, gpointer data); GList* g_list_remove_link (GList *list, @@ -931,6 +968,66 @@ gpointer g_slist_nth_data (GSList *list, #define g_slist_next(slist) ((slist) ? (((GSList *)(slist))->next) : NULL) +/* Stacks + */ + +GStack * g_stack_new (void); +void g_stack_free (GStack *stack); +gpointer g_stack_pop (GStack *stack); + +#define g_stack_empty(stack) \ + ((((GStack *)(stack)) && ((GStack *)(stack))->list) ? FALSE : TRUE) + +#define g_stack_peek(stack) \ + ((((GStack *)(stack)) && ((GStack *)(stack))->list) ? \ + ((GStack *)(stack))->list->data : NULL) + +#define g_stack_index(stack,ptr) \ + ((((GStack *)(stack)) && ((GStack *)(stack))->list) ? \ + g_list_index (((GStack *)(stack))->list, (ptr)) : -1) + +#define g_stack_push(stack,data) G_STMT_START { \ + if ((GStack *)(stack)) \ + ((GStack *)(stack))->list = \ + g_list_prepend (((GStack *)(stack))->list, (data)); \ + } G_STMT_END + + + +/* Queues + */ + +GQueue * g_queue_new (void); +void g_queue_free (GQueue *q); +guint g_queue_get_size (GQueue *q); +void g_queue_push_front (GQueue *q, gpointer data); +void g_queue_push_back (GQueue *q, gpointer data); +gpointer g_queue_pop_front (GQueue *q); +gpointer g_queue_pop_back (GQueue *q); + +#define g_queue_empty(queue) \ + ((((GQueue *)(queue)) && ((GQueue *)(queue))->list) ? FALSE : TRUE) + +#define g_queue_peek_front(queue) \ + ((((GQueue *)(queue)) && ((GQueue *)(queue))->list) ? \ + ((GQueue *)(queue))->list->data : NULL) + +#define g_queue_peek_back(queue) \ + ((((GQueue *)(queue)) && ((GQueue *)(queue))->list_end) ? \ + ((GQueue *)(queue))->list_end->data : NULL) + +#define g_queue_index(queue,ptr) \ + ((((GQueue *)(queue)) && ((GQueue *)(queue))->list) ? \ + g_list_index (((GQueue *)(queue))->list, (ptr)) : -1) + +#define g_queue_push g_queue_push_back +#define g_queue_pop g_queue_pop_front +#define g_queue_peek g_queue_peek_front + + + + + /* Hash tables */ GHashTable* g_hash_table_new (GHashFunc hash_func, @@ -952,10 +1049,10 @@ void g_hash_table_thaw (GHashTable *hash_table); void g_hash_table_foreach (GHashTable *hash_table, GHFunc func, gpointer user_data); -gint g_hash_table_foreach_remove (GHashTable *hash_table, +guint g_hash_table_foreach_remove (GHashTable *hash_table, GHRFunc func, gpointer user_data); -gint g_hash_table_size (GHashTable *hash_table); +guint g_hash_table_size (GHashTable *hash_table); /* Caches @@ -1263,7 +1360,7 @@ GLogLevelFlags g_log_set_fatal_mask (const gchar *log_domain, GLogLevelFlags fatal_mask); GLogLevelFlags g_log_set_always_fatal (GLogLevelFlags fatal_mask); #ifndef G_LOG_DOMAIN -#define G_LOG_DOMAIN (NULL) +#define G_LOG_DOMAIN ((gchar*) 0) #endif /* G_LOG_DOMAIN */ #ifdef __GNUC__ #define g_error(format, args...) g_log (G_LOG_DOMAIN, \ @@ -1403,6 +1500,9 @@ void g_blow_chunks (void); /* Timer */ + +#define G_MICROSEC 1000000 + GTimer* g_timer_new (void); void g_timer_destroy (GTimer *timer); void g_timer_start (GTimer *timer); @@ -1410,7 +1510,7 @@ void g_timer_stop (GTimer *timer); void g_timer_reset (GTimer *timer); gdouble g_timer_elapsed (GTimer *timer, gulong *microseconds); - +void g_usleep (gulong microseconds); /* String utility functions that modify a string argument or * return a constant string that must not be freed. @@ -1454,7 +1554,11 @@ gchar* g_strconcat (const gchar *string1, ...); /* NULL terminated */ gchar* g_strjoin (const gchar *separator, ...); /* NULL terminated */ +/* Return a duplicate of the string with \ and " characters escaped by + * a \. The returned string should be freed with g_free(). + */ gchar* g_strescape (gchar *string); + gpointer g_memdup (gconstpointer mem, guint byte_size); @@ -1592,39 +1696,83 @@ gchar* g_string_chunk_insert_const (GStringChunk *chunk, /* Strings */ -GString* g_string_new (const gchar *init); -GString* g_string_sized_new (guint dfl_size); -void g_string_free (GString *string, - gint free_segment); -GString* g_string_assign (GString *lval, - const gchar *rval); -GString* g_string_truncate (GString *string, - gint len); -GString* g_string_append (GString *string, - const gchar *val); -GString* g_string_append_c (GString *string, - gchar c); -GString* g_string_prepend (GString *string, - const gchar *val); -GString* g_string_prepend_c (GString *string, - gchar c); -GString* g_string_insert (GString *string, - gint pos, - const gchar *val); -GString* g_string_insert_c (GString *string, - gint pos, - gchar c); -GString* g_string_erase (GString *string, - gint pos, - gint len); -GString* g_string_down (GString *string); -GString* g_string_up (GString *string); -void g_string_sprintf (GString *string, - const gchar *format, - ...) G_GNUC_PRINTF (2, 3); -void g_string_sprintfa (GString *string, - const gchar *format, - ...) G_GNUC_PRINTF (2, 3); +typedef enum +{ + G_STRING_ERROR_NONE, /* No error occurred */ + G_STRING_ERROR_INVAL, /* Invalid input value to function */ + G_STRING_ERROR_READ, /* read() returned an error - check errno */ + G_STRING_ERROR_NODATA, /* No more input data - result string may contain data */ + G_STRING_ERROR_LENGTH /* max_length reached */ +} GStringError; + +#define g_string_length(fstring) (fstring ? fstring->len : 0) +#define g_string_str(fstring) (fstring ? fstring->str : NULL) +#define g_string_char(fstring, n) (fstring->str[n]) + +#define g_string_copy(a,b) (g_string_assign(a, b->str)) +#define g_string_dup(fstring) (fstring ? g_string_new(fstring->str) :\ + g_string_new(NULL)) + +#define g_string_cmp(a,b) (strcmp(g_string_str(a), \ + g_string_str(b))) +#define g_string_ncmp(a,b,n) (strncmp(g_string_str(a), \ + g_string_str(b), n)) +#define g_string_casecmp(a,b) (g_strcasecmp(g_string_str(a), \ + g_string_str(b))) +#define g_string_ncasecmp(a,b,n) (g_strncasecmp(g_string_str(a), \ + g_string_str(b), n)) + +#define g_string_strcmp(a,b) (strcmp(g_string_str(a), b)) +#define g_string_strcasecmp(a,b) (g_strcasecmp(g_string_str(a), b)) +#define g_string_strncasecmp(a,b,n) (g_strncasecmp(g_string_str(a), b, n)) + +GString* g_string_new (const gchar *init); +GString* g_string_sized_new (guint dfl_size); +void g_string_free (GString *string, + gint free_segment); +GString* g_string_assign (GString *lval, + const gchar *rval); +GString* g_string_truncate (GString *string, + gint len); +GString* g_string_append (GString *string, + const gchar *val); +GString* g_string_append_c (GString *string, + gchar c); +GString* g_string_prepend (GString *string, + const gchar *val); +GString* g_string_prepend_c (GString *string, + gchar c); +GString* g_string_insert (GString *string, + gint pos, + const gchar *val); +GString* g_string_insert_c (GString *string, + gint pos, + gchar c); +GString* g_string_erase (GString *string, + gint pos, + gint len); +GString* g_string_down (GString *string); +GString* g_string_up (GString *string); +void g_string_sprintf (GString *string, + const gchar *format, + ...) G_GNUC_PRINTF (2, 3); +void g_string_sprintfa (GString *string, + const gchar *format, + ...) G_GNUC_PRINTF (2, 3); +GStringError g_string_readline (GString *dest_str, + gint max_length, + gint fd); +GStringError g_string_readline_buffered (GString *dest_str, + GString *buff_str, + gint max_length, + gint fd, + gint match_bare_cr); +GList* g_string_tokenise (GString *string, + gchar *delims, + gint max_tokens, + gint allow_empty); +void g_string_tokenise_free (GList *tokens, + gint free_token); /* Resizable arrays, remove fills any cleared spot and shortens the @@ -1632,10 +1780,10 @@ void g_string_sprintfa (GString *string, * order by moving the last element to the position of the removed */ -#define g_array_append_val(a,v) g_array_append_vals(a,&v,1) -#define g_array_prepend_val(a,v) g_array_prepend_vals(a,&v,1) -#define g_array_insert_val(a,i,v) g_array_insert_vals(a,i,&v,1) -#define g_array_index(a,t,i) (((t*)a->data)[i]) +#define g_array_append_val(a,v) g_array_append_vals (a, &v, 1) +#define g_array_prepend_val(a,v) g_array_prepend_vals (a, &v, 1) +#define g_array_insert_val(a,i,v) g_array_insert_vals (a, i, &v, 1) +#define g_array_index(a,t,i) (((t*) (a)->data) [(i)]) GArray* g_array_new (gboolean zero_terminated, gboolean clear, @@ -1715,6 +1863,8 @@ guint g_int_hash (gconstpointer v); /* This "hash" function will just return the key's adress as an * unsigned integer. Useful for hashing on plain adresses or * simple integer values. + * passing NULL into g_hash_table_new() as GHashFunc has the + * same effect as passing g_direct_hash(). */ guint g_direct_hash (gconstpointer v); gint g_direct_equal (gconstpointer v, @@ -2220,7 +2370,6 @@ gsize g_date_strftime (gchar *s, const gchar *format, GDate *date); - /* GRelation * * Indexed Relations. Imagine a really simple table in a @@ -2271,6 +2420,39 @@ gpointer g_tuples_index (GTuples *tuples, gint field); +/* GRand - a good and fast random number generator: Mersenne Twister + * see http://www.math.keio.ac.jp/~matumoto/emt.html for more info. + * The range functions return a value in the intervall [min,max). + * int -> [0..2^32-1] + * int_range -> [min..max-1] + * double -> [0..1) + * double_range -> [min..max) + */ + +GRand* g_rand_new_with_seed (guint32 seed); +GRand* g_rand_new (void); +void g_rand_free (GRand *rand); + +void g_rand_set_seed (GRand *rand, + guint32 seed); +guint32 g_rand_int (GRand *rand); +gint32 g_rand_int_range (GRand *rand, + gint32 min, + gint32 max); +gdouble g_rand_double (GRand *rand); +gdouble g_rand_double_range (GRand *rand, + gdouble min, + gdouble max); + +void g_random_set_seed (guint32 seed); +guint32 g_random_int (void); +gint32 g_random_int_range (gint32 min, + gint32 max); +gdouble g_random_double (void); +gdouble g_random_double_range (gdouble min, + gdouble max); + + /* Prime numbers. */ @@ -2565,8 +2747,10 @@ GIOChannel *g_io_channel_win32_new_stream_socket (int socket); */ #ifdef NATIVE_WIN32 # define MAXPATHLEN 1024 -# ifdef _MSC_VER + +#ifdef _MSC_VER typedef int pid_t; +#endif /* These POSIXish functions are available in the Microsoft C library * prefixed with underscore (which of course technically speaking is @@ -2575,7 +2759,7 @@ typedef int pid_t; * every now and then...). * * You still need to include the appropriate headers to get the - * prototypes, or . + * prototypes, like , , or . * * For some functions, we provide emulators in glib, which are prefixed * with gwin_. @@ -2583,15 +2767,23 @@ typedef int pid_t; # define getcwd _getcwd # define getpid _getpid # define access _access +#ifdef __GNUC__ +# define stat _stat +# define fileno _fileno +#endif +# define fstat _fstat +# define unlink _unlink # define open _open # define read _read # define write _write # define lseek _lseek # define close _close +# define rmdir _rmdir # define pipe(phandles) _pipe (phandles, 4096, _O_BINARY) # define popen _popen # define pclose _pclose # define fdopen _fdopen +# define hypot _hypot # define ftruncate(fd, size) gwin_ftruncate (fd, size) # define opendir gwin_opendir # define readdir gwin_readdir @@ -2617,37 +2809,68 @@ 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 */ /* GLib Thread support */ + +typedef void (*GThreadFunc) (gpointer value); + +typedef enum +{ + G_THREAD_PRIORITY_LOW, + G_THREAD_PRIORITY_NORMAL, + G_THREAD_PRIORITY_HIGH, + G_THREAD_PRIORITY_URGENT, +} GThreadPriority; + +typedef struct _GThread GThread; +struct _GThread +{ + GThreadPriority priority; + gboolean bound; + gboolean joinable; +}; + 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) (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 data); + GMutex* (*mutex_new) (void); + 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 data); + gpointer (*thread_create) (GThreadFunc thread_func, + gpointer arg, + gulong stack_size, + gboolean joinable, + gboolean bound, + GThreadPriority priority); + void (*thread_yield) (void); + void (*thread_join) (gpointer thread); + void (*thread_exit) (void); + void (*thread_set_priority)(gpointer thread, + GThreadPriority priority); + gpointer (*thread_self) (void); }; GUTILS_C_VAR GThreadFunctions g_thread_functions_for_glib_use; @@ -2695,6 +2918,20 @@ GMutex* g_static_mutex_get_mutex_impl (GMutex **mutex); (void) (private_key = \ (GPrivate*) (value)), \ (private_key, value)) +#define g_thread_yield() G_THREAD_CF (thread_yield, (void)0, ()) +#define g_thread_exit() G_THREAD_CF (thread_exit, (void)0, ()) + +GThread* g_thread_create (GThreadFunc thread_func, + gpointer arg, + gulong stack_size, + gboolean joinable, + gboolean bound, + GThreadPriority priority); +GThread* g_thread_self (); +void g_thread_join (GThread* thread); +void g_thread_set_priority (GThread* thread, + GThreadPriority priority); + /* 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 @@ -2706,6 +2943,7 @@ GMutex* g_static_mutex_get_mutex_impl (GMutex **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)) + struct _GStaticPrivate { guint index; @@ -2715,21 +2953,68 @@ gpointer g_static_private_get (GStaticPrivate *private_key); void g_static_private_set (GStaticPrivate *private_key, gpointer data, GDestroyNotify notify); +gpointer g_static_private_get_for_thread (GStaticPrivate *private_key, + GThread *thread); +void g_static_private_set_for_thread (GStaticPrivate *private_key, + GThread *thread, + gpointer data, + GDestroyNotify notify); +#ifndef G_STATIC_REC_MUTEX_INIT +/* if GStaticRecMutex is not just a differently initialized GStaticMutex, + * the following is done: + * This can't be done in glibconfig.h, as GStaticPrivate and gboolean + * are not yet known there + */ +typedef struct _GStaticRecMutex GStaticRecMutex; +struct _GStaticRecMutex +{ + GStaticMutex mutex; + GStaticPrivate counter; +}; +#define G_STATIC_REC_MUTEX_INIT { G_STATIC_MUTEX_INIT, G_STATIC_PRIVATE_INIT } +void g_static_rec_mutex_lock (GStaticRecMutex* mutex); +gboolean g_static_rec_mutex_trylock (GStaticRecMutex* mutex); +void g_static_rec_mutex_unlock (GStaticRecMutex* mutex); +#define g_static_rec_mutex_get_mutex(mutex) ((mutex)->mutex) +#endif /* G_STATIC_REC_MUTEX_INIT */ + +typedef struct _GStaticRWLock GStaticRWLock; +struct _GStaticRWLock +{ + GStaticMutex mutex; + GCond *read_cond; + GCond *write_cond; + guint read_counter; + gboolean write; + guint want_to_write; +}; -/* 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. +#define G_STATIC_RW_LOCK_INIT { G_STATIC_MUTEX_INIT, NULL, NULL, 0, FALSE, FALSE } + +void g_static_rw_lock_reader_lock (GStaticRWLock* lock); +gboolean g_static_rw_lock_reader_trylock (GStaticRWLock* lock); +void g_static_rw_lock_reader_unlock (GStaticRWLock* lock); +void g_static_rw_lock_writer_lock (GStaticRWLock* lock); +gboolean g_static_rw_lock_writer_trylock (GStaticRWLock* lock); +void g_static_rw_lock_writer_unlock (GStaticRWLock* lock); +void g_static_rw_lock_free (GStaticRWLock* lock); + +/* 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{ \ @@ -2737,29 +3022,30 @@ extern void glib_dummy_decl (void); "file %s: line %d (%s): locking: %s ", \ __FILE__, __LINE__, G_GNUC_PRETTY_FUNCTION, \ #name); \ - g_static_mutex_lock (G_LOCK_NAME (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_DEBUG, \ "file %s: line %d (%s): unlocking: %s ", \ __FILE__, __LINE__, G_GNUC_PRETTY_FUNCTION, \ #name); \ - g_static_mutex_unlock (G_LOCK_NAME (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_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)) + }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)) +# 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 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)