/usr/include/glib-2.0/glib/gthread.h
Line  | Count  | Source (jump to first uncovered line)  | 
1  |  | /* GLIB - Library of useful routines for C programming  | 
2  |  |  * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald  | 
3  |  |  *  | 
4  |  |  * This library is free software; you can redistribute it and/or  | 
5  |  |  * modify it under the terms of the GNU Lesser General Public  | 
6  |  |  * License as published by the Free Software Foundation; either  | 
7  |  |  * version 2.1 of the License, or (at your option) any later version.  | 
8  |  |  *  | 
9  |  |  * This library is distributed in the hope that it will be useful, but  | 
10  |  |  * WITHOUT ANY WARRANTY; without even the implied warranty of  | 
11  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU  | 
12  |  |  * Lesser General Public License for more details.  | 
13  |  |  *  | 
14  |  |  * You should have received a copy of the GNU Lesser General Public  | 
15  |  |  * License along with this library; if not, see <http://www.gnu.org/licenses/>.  | 
16  |  |  */  | 
17  |  |  | 
18  |  | /*  | 
19  |  |  * Modified by the GLib Team and others 1997-2000.  See the AUTHORS  | 
20  |  |  * file for a list of people on the GLib Team.  See the ChangeLog  | 
21  |  |  * files for a list of changes.  These files are distributed with  | 
22  |  |  * GLib at ftp://ftp.gtk.org/pub/gtk/.  | 
23  |  |  */  | 
24  |  |  | 
25  |  | #ifndef __G_THREAD_H__  | 
26  |  | #define __G_THREAD_H__  | 
27  |  |  | 
28  |  | #if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)  | 
29  |  | #error "Only <glib.h> can be included directly."  | 
30  |  | #endif  | 
31  |  |  | 
32  |  | #include <glib/gatomic.h>  | 
33  |  | #include <glib/gerror.h>  | 
34  |  | #include <glib/gutils.h>  | 
35  |  |  | 
36  |  | G_BEGIN_DECLS  | 
37  |  |  | 
38  |  | #define G_THREAD_ERROR g_thread_error_quark ()  | 
39  |  | GLIB_AVAILABLE_IN_ALL  | 
40  |  | GQuark g_thread_error_quark (void);  | 
41  |  |  | 
42  |  | typedef enum  | 
43  |  | { | 
44  |  |   G_THREAD_ERROR_AGAIN /* Resource temporarily unavailable */  | 
45  |  | } GThreadError;  | 
46  |  |  | 
47  |  | typedef gpointer (*GThreadFunc) (gpointer data);  | 
48  |  |  | 
49  |  | typedef struct _GThread         GThread;  | 
50  |  |  | 
51  |  | typedef union  _GMutex          GMutex;  | 
52  |  | typedef struct _GRecMutex       GRecMutex;  | 
53  |  | typedef struct _GRWLock         GRWLock;  | 
54  |  | typedef struct _GCond           GCond;  | 
55  |  | typedef struct _GPrivate        GPrivate;  | 
56  |  | typedef struct _GOnce           GOnce;  | 
57  |  |  | 
58  |  | union _GMutex  | 
59  |  | { | 
60  |  |   /*< private >*/  | 
61  |  |   gpointer p;  | 
62  |  |   guint i[2];  | 
63  |  | };  | 
64  |  |  | 
65  |  | struct _GRWLock  | 
66  |  | { | 
67  |  |   /*< private >*/  | 
68  |  |   gpointer p;  | 
69  |  |   guint i[2];  | 
70  |  | };  | 
71  |  |  | 
72  |  | struct _GCond  | 
73  |  | { | 
74  |  |   /*< private >*/  | 
75  |  |   gpointer p;  | 
76  |  |   guint i[2];  | 
77  |  | };  | 
78  |  |  | 
79  |  | struct _GRecMutex  | 
80  |  | { | 
81  |  |   /*< private >*/  | 
82  |  |   gpointer p;  | 
83  |  |   guint i[2];  | 
84  |  | };  | 
85  |  |  | 
86  |  | #define G_PRIVATE_INIT(notify) { NULL, (notify), { NULL, NULL } } | 
87  |  | struct _GPrivate  | 
88  |  | { | 
89  |  |   /*< private >*/  | 
90  |  |   gpointer       p;  | 
91  |  |   GDestroyNotify notify;  | 
92  |  |   gpointer future[2];  | 
93  |  | };  | 
94  |  |  | 
95  |  | typedef enum  | 
96  |  | { | 
97  |  |   G_ONCE_STATUS_NOTCALLED,  | 
98  |  |   G_ONCE_STATUS_PROGRESS,  | 
99  |  |   G_ONCE_STATUS_READY  | 
100  |  | } GOnceStatus;  | 
101  |  |  | 
102  |  | #define G_ONCE_INIT { G_ONCE_STATUS_NOTCALLED, NULL } | 
103  |  | struct _GOnce  | 
104  |  | { | 
105  |  |   volatile GOnceStatus status;  | 
106  |  |   volatile gpointer retval;  | 
107  |  | };  | 
108  |  |  | 
109  |  | #define G_LOCK_NAME(name)             g__ ## name ## _lock  | 
110  |  | #define G_LOCK_DEFINE_STATIC(name)    static G_LOCK_DEFINE (name)  | 
111  |  | #define G_LOCK_DEFINE(name)           GMutex G_LOCK_NAME (name)  | 
112  |  | #define G_LOCK_EXTERN(name)           extern GMutex G_LOCK_NAME (name)  | 
113  |  |  | 
114  |  | #ifdef G_DEBUG_LOCKS  | 
115  |  | #  define G_LOCK(name)                G_STMT_START{             \ | 
116  |  |       g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG,                   \  | 
117  |  |              "file %s: line %d (%s): locking: %s ",             \  | 
118  |  |              __FILE__,        __LINE__, G_STRFUNC,              \  | 
119  |  |              #name);                                            \  | 
120  |  |       g_mutex_lock (&G_LOCK_NAME (name));                       \  | 
121  |  |    }G_STMT_END  | 
122  |  | #  define G_UNLOCK(name)              G_STMT_START{             \ | 
123  |  |       g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG,                   \  | 
124  |  |              "file %s: line %d (%s): unlocking: %s ",           \  | 
125  |  |              __FILE__,        __LINE__, G_STRFUNC,              \  | 
126  |  |              #name);                                            \  | 
127  |  |      g_mutex_unlock (&G_LOCK_NAME (name));                      \  | 
128  |  |    }G_STMT_END  | 
129  |  | #  define G_TRYLOCK(name)                                       \  | 
130  |  |       (g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG,                  \  | 
131  |  |              "file %s: line %d (%s): try locking: %s ",         \  | 
132  |  |              __FILE__,        __LINE__, G_STRFUNC,              \  | 
133  |  |              #name), g_mutex_trylock (&G_LOCK_NAME (name)))  | 
134  |  | #else  /* !G_DEBUG_LOCKS */  | 
135  |  | #  define G_LOCK(name) g_mutex_lock       (&G_LOCK_NAME (name))  | 
136  |  | #  define G_UNLOCK(name) g_mutex_unlock   (&G_LOCK_NAME (name))  | 
137  |  | #  define G_TRYLOCK(name) g_mutex_trylock (&G_LOCK_NAME (name))  | 
138  |  | #endif /* !G_DEBUG_LOCKS */  | 
139  |  |  | 
140  |  | GLIB_AVAILABLE_IN_2_32  | 
141  |  | GThread *       g_thread_ref                    (GThread        *thread);  | 
142  |  | GLIB_AVAILABLE_IN_2_32  | 
143  |  | void            g_thread_unref                  (GThread        *thread);  | 
144  |  | GLIB_AVAILABLE_IN_2_32  | 
145  |  | GThread *       g_thread_new                    (const gchar    *name,  | 
146  |  |                                                  GThreadFunc     func,  | 
147  |  |                                                  gpointer        data);  | 
148  |  | GLIB_AVAILABLE_IN_2_32  | 
149  |  | GThread *       g_thread_try_new                (const gchar    *name,  | 
150  |  |                                                  GThreadFunc     func,  | 
151  |  |                                                  gpointer        data,  | 
152  |  |                                                  GError        **error);  | 
153  |  | GLIB_AVAILABLE_IN_ALL  | 
154  |  | GThread *       g_thread_self                   (void);  | 
155  |  | GLIB_AVAILABLE_IN_ALL  | 
156  |  | void            g_thread_exit                   (gpointer        retval);  | 
157  |  | GLIB_AVAILABLE_IN_ALL  | 
158  |  | gpointer        g_thread_join                   (GThread        *thread);  | 
159  |  | GLIB_AVAILABLE_IN_ALL  | 
160  |  | void            g_thread_yield                  (void);  | 
161  |  |  | 
162  |  |  | 
163  |  | GLIB_AVAILABLE_IN_2_32  | 
164  |  | void            g_mutex_init                    (GMutex         *mutex);  | 
165  |  | GLIB_AVAILABLE_IN_2_32  | 
166  |  | void            g_mutex_clear                   (GMutex         *mutex);  | 
167  |  | GLIB_AVAILABLE_IN_ALL  | 
168  |  | void            g_mutex_lock                    (GMutex         *mutex);  | 
169  |  | GLIB_AVAILABLE_IN_ALL  | 
170  |  | gboolean        g_mutex_trylock                 (GMutex         *mutex);  | 
171  |  | GLIB_AVAILABLE_IN_ALL  | 
172  |  | void            g_mutex_unlock                  (GMutex         *mutex);  | 
173  |  |  | 
174  |  | GLIB_AVAILABLE_IN_2_32  | 
175  |  | void            g_rw_lock_init                  (GRWLock        *rw_lock);  | 
176  |  | GLIB_AVAILABLE_IN_2_32  | 
177  |  | void            g_rw_lock_clear                 (GRWLock        *rw_lock);  | 
178  |  | GLIB_AVAILABLE_IN_2_32  | 
179  |  | void            g_rw_lock_writer_lock           (GRWLock        *rw_lock);  | 
180  |  | GLIB_AVAILABLE_IN_2_32  | 
181  |  | gboolean        g_rw_lock_writer_trylock        (GRWLock        *rw_lock);  | 
182  |  | GLIB_AVAILABLE_IN_2_32  | 
183  |  | void            g_rw_lock_writer_unlock         (GRWLock        *rw_lock);  | 
184  |  | GLIB_AVAILABLE_IN_2_32  | 
185  |  | void            g_rw_lock_reader_lock           (GRWLock        *rw_lock);  | 
186  |  | GLIB_AVAILABLE_IN_2_32  | 
187  |  | gboolean        g_rw_lock_reader_trylock        (GRWLock        *rw_lock);  | 
188  |  | GLIB_AVAILABLE_IN_2_32  | 
189  |  | void            g_rw_lock_reader_unlock         (GRWLock        *rw_lock);  | 
190  |  |  | 
191  |  | GLIB_AVAILABLE_IN_2_32  | 
192  |  | void            g_rec_mutex_init                (GRecMutex      *rec_mutex);  | 
193  |  | GLIB_AVAILABLE_IN_2_32  | 
194  |  | void            g_rec_mutex_clear               (GRecMutex      *rec_mutex);  | 
195  |  | GLIB_AVAILABLE_IN_2_32  | 
196  |  | void            g_rec_mutex_lock                (GRecMutex      *rec_mutex);  | 
197  |  | GLIB_AVAILABLE_IN_2_32  | 
198  |  | gboolean        g_rec_mutex_trylock             (GRecMutex      *rec_mutex);  | 
199  |  | GLIB_AVAILABLE_IN_2_32  | 
200  |  | void            g_rec_mutex_unlock              (GRecMutex      *rec_mutex);  | 
201  |  |  | 
202  |  | GLIB_AVAILABLE_IN_2_32  | 
203  |  | void            g_cond_init                     (GCond          *cond);  | 
204  |  | GLIB_AVAILABLE_IN_2_32  | 
205  |  | void            g_cond_clear                    (GCond          *cond);  | 
206  |  | GLIB_AVAILABLE_IN_ALL  | 
207  |  | void            g_cond_wait                     (GCond          *cond,  | 
208  |  |                                                  GMutex         *mutex);  | 
209  |  | GLIB_AVAILABLE_IN_ALL  | 
210  |  | void            g_cond_signal                   (GCond          *cond);  | 
211  |  | GLIB_AVAILABLE_IN_ALL  | 
212  |  | void            g_cond_broadcast                (GCond          *cond);  | 
213  |  | GLIB_AVAILABLE_IN_2_32  | 
214  |  | gboolean        g_cond_wait_until               (GCond          *cond,  | 
215  |  |                                                  GMutex         *mutex,  | 
216  |  |                                                  gint64          end_time);  | 
217  |  |  | 
218  |  | GLIB_AVAILABLE_IN_ALL  | 
219  |  | gpointer        g_private_get                   (GPrivate       *key);  | 
220  |  | GLIB_AVAILABLE_IN_ALL  | 
221  |  | void            g_private_set                   (GPrivate       *key,  | 
222  |  |                                                  gpointer        value);  | 
223  |  | GLIB_AVAILABLE_IN_2_32  | 
224  |  | void            g_private_replace               (GPrivate       *key,  | 
225  |  |                                                  gpointer        value);  | 
226  |  |  | 
227  |  | GLIB_AVAILABLE_IN_ALL  | 
228  |  | gpointer        g_once_impl                     (GOnce          *once,  | 
229  |  |                                                  GThreadFunc     func,  | 
230  |  |                                                  gpointer        arg);  | 
231  |  | GLIB_AVAILABLE_IN_ALL  | 
232  |  | gboolean        g_once_init_enter               (volatile void  *location);  | 
233  |  | GLIB_AVAILABLE_IN_ALL  | 
234  |  | void            g_once_init_leave               (volatile void  *location,  | 
235  |  |                                                  gsize           result);  | 
236  |  |  | 
237  |  | #ifdef G_ATOMIC_OP_MEMORY_BARRIER_NEEDED  | 
238  |  | # define g_once(once, func, arg) g_once_impl ((once), (func), (arg))  | 
239  |  | #else /* !G_ATOMIC_OP_MEMORY_BARRIER_NEEDED*/  | 
240  |  | # define g_once(once, func, arg) \  | 
241  |  |   (((once)->status == G_ONCE_STATUS_READY) ? \  | 
242  |  |    (once)->retval : \  | 
243  |  |    g_once_impl ((once), (func), (arg)))  | 
244  |  | #endif /* G_ATOMIC_OP_MEMORY_BARRIER_NEEDED */  | 
245  |  |  | 
246  |  | #ifdef __GNUC__  | 
247  |  | # define g_once_init_enter(location) \  | 
248  |  |   (G_GNUC_EXTENSION ({                                               \ | 
249  |  |     G_STATIC_ASSERT (sizeof *(location) == sizeof (gpointer));       \  | 
250  |  |     (void) (0 ? (gpointer) *(location) : NULL);                      \  | 
251  |  |     (!g_atomic_pointer_get (location) &&                             \  | 
252  |  |      g_once_init_enter (location));                                  \  | 
253  |  |   }))  | 
254  |  | # define g_once_init_leave(location, result) \  | 
255  |  |   (G_GNUC_EXTENSION ({                                               \ | 
256  |  |     G_STATIC_ASSERT (sizeof *(location) == sizeof (gpointer));       \  | 
257  |  |     0 ? (void) (*(location) = (result)) : (void) 0;                  \  | 
258  |  |     g_once_init_leave ((location), (gsize) (result));                \  | 
259  |  |   }))  | 
260  |  | #else  | 
261  |  | # define g_once_init_enter(location) \  | 
262  |  |   (g_once_init_enter((location)))  | 
263  |  | # define g_once_init_leave(location, result) \  | 
264  |  |   (g_once_init_leave((location), (gsize) (result)))  | 
265  |  | #endif  | 
266  |  |  | 
267  |  | GLIB_AVAILABLE_IN_2_36  | 
268  |  | guint          g_get_num_processors (void);  | 
269  |  |  | 
270  |  | /**  | 
271  |  |  * GMutexLocker:  | 
272  |  |  *  | 
273  |  |  * Opaque type. See g_mutex_locker_new() for details.  | 
274  |  |  * Since: 2.44  | 
275  |  |  */  | 
276  |  | typedef void GMutexLocker;  | 
277  |  |  | 
278  |  | /**  | 
279  |  |  * g_mutex_locker_new:  | 
280  |  |  * @mutex: a mutex to lock  | 
281  |  |  *  | 
282  |  |  * Lock @mutex and return a new #GMutexLocker. Unlock with  | 
283  |  |  * g_mutex_locker_free(). Using g_mutex_unlock() on @mutex  | 
284  |  |  * while a #GMutexLocker exists can lead to undefined behaviour.  | 
285  |  |  *  | 
286  |  |  * No allocation is performed, it is equivalent to a g_mutex_lock() call.  | 
287  |  |  *  | 
288  |  |  * This is intended to be used with g_autoptr().  Note that g_autoptr()  | 
289  |  |  * is only available when using GCC or clang, so the following example  | 
290  |  |  * will only work with those compilers:  | 
291  |  |  * |[  | 
292  |  |  * typedef struct  | 
293  |  |  * { | 
294  |  |  *   ...  | 
295  |  |  *   GMutex mutex;  | 
296  |  |  *   ...  | 
297  |  |  * } MyObject;  | 
298  |  |  *  | 
299  |  |  * static void  | 
300  |  |  * my_object_do_stuff (MyObject *self)  | 
301  |  |  * { | 
302  |  |  *   g_autoptr(GMutexLocker) locker = g_mutex_locker_new (&self->mutex);  | 
303  |  |  *  | 
304  |  |  *   // Code with mutex locked here  | 
305  |  |  *  | 
306  |  |  *   if (cond)  | 
307  |  |  *     // No need to unlock  | 
308  |  |  *     return;  | 
309  |  |  *  | 
310  |  |  *   // Optionally early unlock  | 
311  |  |  *   g_clear_pointer (&locker, g_mutex_locker_free);  | 
312  |  |  *  | 
313  |  |  *   // Code with mutex unlocked here  | 
314  |  |  * }  | 
315  |  |  * ]|  | 
316  |  |  *  | 
317  |  |  * Returns: a #GMutexLocker  | 
318  |  |  * Since: 2.44  | 
319  |  |  */  | 
320  |  | static inline GMutexLocker *  | 
321  |  | g_mutex_locker_new (GMutex *mutex)  | 
322  | 0  | { | 
323  | 0  |   g_mutex_lock (mutex);  | 
324  | 0  |   return (GMutexLocker *) mutex;  | 
325  | 0  | } Unexecuted instantiation: cac-aca.c:g_mutex_locker_new Unexecuted instantiation: cac.c:g_mutex_locker_new Unexecuted instantiation: card_7816.c:g_mutex_locker_new Unexecuted instantiation: common.c:g_mutex_locker_new Unexecuted instantiation: event.c:g_mutex_locker_new Unexecuted instantiation: gp.c:g_mutex_locker_new Unexecuted instantiation: msft.c:g_mutex_locker_new Unexecuted instantiation: simpletlv.c:g_mutex_locker_new Unexecuted instantiation: vcard.c:g_mutex_locker_new Unexecuted instantiation: vcard_emul_nss.c:g_mutex_locker_new Unexecuted instantiation: vcard_emul_type.c:g_mutex_locker_new Unexecuted instantiation: vcardt.c:g_mutex_locker_new Unexecuted instantiation: vreader.c:g_mutex_locker_new Unexecuted instantiation: fuzz_simpletlv.c:g_mutex_locker_new  | 
326  |  |  | 
327  |  | /**  | 
328  |  |  * g_mutex_locker_free:  | 
329  |  |  * @locker: a GMutexLocker  | 
330  |  |  *  | 
331  |  |  * Unlock @locker's mutex. See g_mutex_locker_new() for details.  | 
332  |  |  *  | 
333  |  |  * No memory is freed, it is equivalent to a g_mutex_unlock() call.  | 
334  |  |  *  | 
335  |  |  * Since: 2.44  | 
336  |  |  */  | 
337  |  | static inline void  | 
338  |  | g_mutex_locker_free (GMutexLocker *locker)  | 
339  | 0  | { | 
340  | 0  |   g_mutex_unlock ((GMutex *) locker);  | 
341  | 0  | } Unexecuted instantiation: cac-aca.c:g_mutex_locker_free Unexecuted instantiation: cac.c:g_mutex_locker_free Unexecuted instantiation: card_7816.c:g_mutex_locker_free Unexecuted instantiation: common.c:g_mutex_locker_free Unexecuted instantiation: event.c:g_mutex_locker_free Unexecuted instantiation: gp.c:g_mutex_locker_free Unexecuted instantiation: msft.c:g_mutex_locker_free Unexecuted instantiation: simpletlv.c:g_mutex_locker_free Unexecuted instantiation: vcard.c:g_mutex_locker_free Unexecuted instantiation: vcard_emul_nss.c:g_mutex_locker_free Unexecuted instantiation: vcard_emul_type.c:g_mutex_locker_free Unexecuted instantiation: vcardt.c:g_mutex_locker_free Unexecuted instantiation: vreader.c:g_mutex_locker_free Unexecuted instantiation: fuzz_simpletlv.c:g_mutex_locker_free  | 
342  |  |  | 
343  |  | /**  | 
344  |  |  * GRecMutexLocker:  | 
345  |  |  *  | 
346  |  |  * Opaque type. See g_rec_mutex_locker_new() for details.  | 
347  |  |  * Since: 2.60  | 
348  |  |  */  | 
349  |  | typedef void GRecMutexLocker;  | 
350  |  |  | 
351  |  | /**  | 
352  |  |  * g_rec_mutex_locker_new:  | 
353  |  |  * @rec_mutex: a recursive mutex to lock  | 
354  |  |  *  | 
355  |  |  * Lock @rec_mutex and return a new #GRecMutexLocker. Unlock with  | 
356  |  |  * g_rec_mutex_locker_free(). Using g_rec_mutex_unlock() on @rec_mutex  | 
357  |  |  * while a #GRecMutexLocker exists can lead to undefined behaviour.  | 
358  |  |  *  | 
359  |  |  * No allocation is performed, it is equivalent to a g_rec_mutex_lock() call.  | 
360  |  |  *  | 
361  |  |  * This is intended to be used with g_autoptr().  Note that g_autoptr()  | 
362  |  |  * is only available when using GCC or clang, so the following example  | 
363  |  |  * will only work with those compilers:  | 
364  |  |  * |[  | 
365  |  |  * typedef struct  | 
366  |  |  * { | 
367  |  |  *   ...  | 
368  |  |  *   GRecMutex rec_mutex;  | 
369  |  |  *   ...  | 
370  |  |  * } MyObject;  | 
371  |  |  *  | 
372  |  |  * static void  | 
373  |  |  * my_object_do_stuff (MyObject *self)  | 
374  |  |  * { | 
375  |  |  *   g_autoptr(GRecMutexLocker) locker = g_rec_mutex_locker_new (&self->rec_mutex);  | 
376  |  |  *  | 
377  |  |  *   // Code with rec_mutex locked here  | 
378  |  |  *  | 
379  |  |  *   if (cond)  | 
380  |  |  *     // No need to unlock  | 
381  |  |  *     return;  | 
382  |  |  *  | 
383  |  |  *   // Optionally early unlock  | 
384  |  |  *   g_clear_pointer (&locker, g_rec_mutex_locker_free);  | 
385  |  |  *  | 
386  |  |  *   // Code with rec_mutex unlocked here  | 
387  |  |  * }  | 
388  |  |  * ]|  | 
389  |  |  *  | 
390  |  |  * Returns: a #GRecMutexLocker  | 
391  |  |  * Since: 2.60  | 
392  |  |  */  | 
393  |  | G_GNUC_BEGIN_IGNORE_DEPRECATIONS  | 
394  |  | static inline GRecMutexLocker *  | 
395  |  | g_rec_mutex_locker_new (GRecMutex *rec_mutex)  | 
396  | 0  | { | 
397  | 0  |   g_rec_mutex_lock (rec_mutex);  | 
398  | 0  |   return (GRecMutexLocker *) rec_mutex;  | 
399  | 0  | } Unexecuted instantiation: cac-aca.c:g_rec_mutex_locker_new Unexecuted instantiation: cac.c:g_rec_mutex_locker_new Unexecuted instantiation: card_7816.c:g_rec_mutex_locker_new Unexecuted instantiation: common.c:g_rec_mutex_locker_new Unexecuted instantiation: event.c:g_rec_mutex_locker_new Unexecuted instantiation: gp.c:g_rec_mutex_locker_new Unexecuted instantiation: msft.c:g_rec_mutex_locker_new Unexecuted instantiation: simpletlv.c:g_rec_mutex_locker_new Unexecuted instantiation: vcard.c:g_rec_mutex_locker_new Unexecuted instantiation: vcard_emul_nss.c:g_rec_mutex_locker_new Unexecuted instantiation: vcard_emul_type.c:g_rec_mutex_locker_new Unexecuted instantiation: vcardt.c:g_rec_mutex_locker_new Unexecuted instantiation: vreader.c:g_rec_mutex_locker_new Unexecuted instantiation: fuzz_simpletlv.c:g_rec_mutex_locker_new  | 
400  |  | G_GNUC_END_IGNORE_DEPRECATIONS  | 
401  |  |  | 
402  |  | /**  | 
403  |  |  * g_rec_mutex_locker_free:  | 
404  |  |  * @locker: a GRecMutexLocker  | 
405  |  |  *  | 
406  |  |  * Unlock @locker's recursive mutex. See g_rec_mutex_locker_new() for details.  | 
407  |  |  *  | 
408  |  |  * No memory is freed, it is equivalent to a g_rec_mutex_unlock() call.  | 
409  |  |  *  | 
410  |  |  * Since: 2.60  | 
411  |  |  */  | 
412  |  | G_GNUC_BEGIN_IGNORE_DEPRECATIONS  | 
413  |  | static inline void  | 
414  |  | g_rec_mutex_locker_free (GRecMutexLocker *locker)  | 
415  | 0  | { | 
416  | 0  |   g_rec_mutex_unlock ((GRecMutex *) locker);  | 
417  | 0  | } Unexecuted instantiation: cac-aca.c:g_rec_mutex_locker_free Unexecuted instantiation: cac.c:g_rec_mutex_locker_free Unexecuted instantiation: card_7816.c:g_rec_mutex_locker_free Unexecuted instantiation: common.c:g_rec_mutex_locker_free Unexecuted instantiation: event.c:g_rec_mutex_locker_free Unexecuted instantiation: gp.c:g_rec_mutex_locker_free Unexecuted instantiation: msft.c:g_rec_mutex_locker_free Unexecuted instantiation: simpletlv.c:g_rec_mutex_locker_free Unexecuted instantiation: vcard.c:g_rec_mutex_locker_free Unexecuted instantiation: vcard_emul_nss.c:g_rec_mutex_locker_free Unexecuted instantiation: vcard_emul_type.c:g_rec_mutex_locker_free Unexecuted instantiation: vcardt.c:g_rec_mutex_locker_free Unexecuted instantiation: vreader.c:g_rec_mutex_locker_free Unexecuted instantiation: fuzz_simpletlv.c:g_rec_mutex_locker_free  | 
418  |  | G_GNUC_END_IGNORE_DEPRECATIONS  | 
419  |  |  | 
420  |  | /**  | 
421  |  |  * GRWLockWriterLocker:  | 
422  |  |  *  | 
423  |  |  * Opaque type. See g_rw_lock_writer_locker_new() for details.  | 
424  |  |  * Since: 2.62  | 
425  |  |  */  | 
426  |  | typedef void GRWLockWriterLocker;  | 
427  |  |  | 
428  |  | /**  | 
429  |  |  * g_rw_lock_writer_locker_new:  | 
430  |  |  * @rw_lock: a #GRWLock  | 
431  |  |  *  | 
432  |  |  * Obtain a write lock on @rw_lock and return a new #GRWLockWriterLocker.  | 
433  |  |  * Unlock with g_rw_lock_writer_locker_free(). Using g_rw_lock_writer_unlock()  | 
434  |  |  * on @rw_lock while a #GRWLockWriterLocker exists can lead to undefined  | 
435  |  |  * behaviour.  | 
436  |  |  *  | 
437  |  |  * No allocation is performed, it is equivalent to a g_rw_lock_writer_lock() call.  | 
438  |  |  *  | 
439  |  |  * This is intended to be used with g_autoptr().  Note that g_autoptr()  | 
440  |  |  * is only available when using GCC or clang, so the following example  | 
441  |  |  * will only work with those compilers:  | 
442  |  |  * |[  | 
443  |  |  * typedef struct  | 
444  |  |  * { | 
445  |  |  *   ...  | 
446  |  |  *   GRWLock rw_lock;  | 
447  |  |  *   GPtrArray *array;  | 
448  |  |  *   ...  | 
449  |  |  * } MyObject;  | 
450  |  |  *  | 
451  |  |  * static gchar *  | 
452  |  |  * my_object_get_data (MyObject *self, guint index)  | 
453  |  |  * { | 
454  |  |  *   g_autoptr(GRWLockReaderLocker) locker = g_rw_lock_reader_locker_new (&self->rw_lock);  | 
455  |  |  *  | 
456  |  |  *   // Code with a read lock obtained on rw_lock here  | 
457  |  |  *  | 
458  |  |  *   if (self->array == NULL)  | 
459  |  |  *     // No need to unlock  | 
460  |  |  *     return NULL;  | 
461  |  |  *  | 
462  |  |  *   if (index < self->array->len)  | 
463  |  |  *     // No need to unlock  | 
464  |  |  *     return g_ptr_array_index (self->array, index);  | 
465  |  |  *  | 
466  |  |  *   // Optionally early unlock  | 
467  |  |  *   g_clear_pointer (&locker, g_rw_lock_reader_locker_free);  | 
468  |  |  *  | 
469  |  |  *   // Code with rw_lock unlocked here  | 
470  |  |  *   return NULL;  | 
471  |  |  * }  | 
472  |  |  *  | 
473  |  |  * static void  | 
474  |  |  * my_object_set_data (MyObject *self, guint index, gpointer data)  | 
475  |  |  * { | 
476  |  |  *   g_autoptr(GRWLockWriterLocker) locker = g_rw_lock_writer_locker_new (&self->rw_lock);  | 
477  |  |  *  | 
478  |  |  *   // Code with a write lock obtained on rw_lock here  | 
479  |  |  *  | 
480  |  |  *   if (self->array == NULL)  | 
481  |  |  *     self->array = g_ptr_array_new ();  | 
482  |  |  *  | 
483  |  |  *   if (cond)  | 
484  |  |  *     // No need to unlock  | 
485  |  |  *     return;  | 
486  |  |  *  | 
487  |  |  *   if (index >= self->array->len)  | 
488  |  |  *     g_ptr_array_set_size (self->array, index+1);  | 
489  |  |  *   g_ptr_array_index (self->array, index) = data;  | 
490  |  |  *  | 
491  |  |  *   // Optionally early unlock  | 
492  |  |  *   g_clear_pointer (&locker, g_rw_lock_writer_locker_free);  | 
493  |  |  *  | 
494  |  |  *   // Code with rw_lock unlocked here  | 
495  |  |  * }  | 
496  |  |  * ]|  | 
497  |  |  *  | 
498  |  |  * Returns: a #GRWLockWriterLocker  | 
499  |  |  * Since: 2.62  | 
500  |  |  */  | 
501  |  | G_GNUC_BEGIN_IGNORE_DEPRECATIONS  | 
502  |  | static inline GRWLockWriterLocker *  | 
503  |  | g_rw_lock_writer_locker_new (GRWLock *rw_lock)  | 
504  | 0  | { | 
505  | 0  |   g_rw_lock_writer_lock (rw_lock);  | 
506  | 0  |   return (GRWLockWriterLocker *) rw_lock;  | 
507  | 0  | } Unexecuted instantiation: cac-aca.c:g_rw_lock_writer_locker_new Unexecuted instantiation: cac.c:g_rw_lock_writer_locker_new Unexecuted instantiation: card_7816.c:g_rw_lock_writer_locker_new Unexecuted instantiation: common.c:g_rw_lock_writer_locker_new Unexecuted instantiation: event.c:g_rw_lock_writer_locker_new Unexecuted instantiation: gp.c:g_rw_lock_writer_locker_new Unexecuted instantiation: msft.c:g_rw_lock_writer_locker_new Unexecuted instantiation: simpletlv.c:g_rw_lock_writer_locker_new Unexecuted instantiation: vcard.c:g_rw_lock_writer_locker_new Unexecuted instantiation: vcard_emul_nss.c:g_rw_lock_writer_locker_new Unexecuted instantiation: vcard_emul_type.c:g_rw_lock_writer_locker_new Unexecuted instantiation: vcardt.c:g_rw_lock_writer_locker_new Unexecuted instantiation: vreader.c:g_rw_lock_writer_locker_new Unexecuted instantiation: fuzz_simpletlv.c:g_rw_lock_writer_locker_new  | 
508  |  | G_GNUC_END_IGNORE_DEPRECATIONS  | 
509  |  |  | 
510  |  | /**  | 
511  |  |  * g_rw_lock_writer_locker_free:  | 
512  |  |  * @locker: a GRWLockWriterLocker  | 
513  |  |  *  | 
514  |  |  * Release a write lock on @locker's read-write lock. See  | 
515  |  |  * g_rw_lock_writer_locker_new() for details.  | 
516  |  |  *  | 
517  |  |  * No memory is freed, it is equivalent to a g_rw_lock_writer_unlock() call.  | 
518  |  |  *  | 
519  |  |  * Since: 2.62  | 
520  |  |  */  | 
521  |  | G_GNUC_BEGIN_IGNORE_DEPRECATIONS  | 
522  |  | static inline void  | 
523  |  | g_rw_lock_writer_locker_free (GRWLockWriterLocker *locker)  | 
524  | 0  | { | 
525  | 0  |   g_rw_lock_writer_unlock ((GRWLock *) locker);  | 
526  | 0  | } Unexecuted instantiation: cac-aca.c:g_rw_lock_writer_locker_free Unexecuted instantiation: cac.c:g_rw_lock_writer_locker_free Unexecuted instantiation: card_7816.c:g_rw_lock_writer_locker_free Unexecuted instantiation: common.c:g_rw_lock_writer_locker_free Unexecuted instantiation: event.c:g_rw_lock_writer_locker_free Unexecuted instantiation: gp.c:g_rw_lock_writer_locker_free Unexecuted instantiation: msft.c:g_rw_lock_writer_locker_free Unexecuted instantiation: simpletlv.c:g_rw_lock_writer_locker_free Unexecuted instantiation: vcard.c:g_rw_lock_writer_locker_free Unexecuted instantiation: vcard_emul_nss.c:g_rw_lock_writer_locker_free Unexecuted instantiation: vcard_emul_type.c:g_rw_lock_writer_locker_free Unexecuted instantiation: vcardt.c:g_rw_lock_writer_locker_free Unexecuted instantiation: vreader.c:g_rw_lock_writer_locker_free Unexecuted instantiation: fuzz_simpletlv.c:g_rw_lock_writer_locker_free  | 
527  |  | G_GNUC_END_IGNORE_DEPRECATIONS  | 
528  |  |  | 
529  |  | /**  | 
530  |  |  * GRWLockReaderLocker:  | 
531  |  |  *  | 
532  |  |  * Opaque type. See g_rw_lock_reader_locker_new() for details.  | 
533  |  |  * Since: 2.62  | 
534  |  |  */  | 
535  |  | typedef void GRWLockReaderLocker;  | 
536  |  |  | 
537  |  | /**  | 
538  |  |  * g_rw_lock_reader_locker_new:  | 
539  |  |  * @rw_lock: a #GRWLock  | 
540  |  |  *  | 
541  |  |  * Obtain a read lock on @rw_lock and return a new #GRWLockReaderLocker.  | 
542  |  |  * Unlock with g_rw_lock_reader_locker_free(). Using g_rw_lock_reader_unlock()  | 
543  |  |  * on @rw_lock while a #GRWLockReaderLocker exists can lead to undefined  | 
544  |  |  * behaviour.  | 
545  |  |  *  | 
546  |  |  * No allocation is performed, it is equivalent to a g_rw_lock_reader_lock() call.  | 
547  |  |  *  | 
548  |  |  * This is intended to be used with g_autoptr(). For a code sample, see  | 
549  |  |  * g_rw_lock_writer_locker_new().  | 
550  |  |  *  | 
551  |  |  * Returns: a #GRWLockReaderLocker  | 
552  |  |  * Since: 2.62  | 
553  |  |  */  | 
554  |  | G_GNUC_BEGIN_IGNORE_DEPRECATIONS  | 
555  |  | static inline GRWLockReaderLocker *  | 
556  |  | g_rw_lock_reader_locker_new (GRWLock *rw_lock)  | 
557  | 0  | { | 
558  | 0  |   g_rw_lock_reader_lock (rw_lock);  | 
559  | 0  |   return (GRWLockReaderLocker *) rw_lock;  | 
560  | 0  | } Unexecuted instantiation: cac-aca.c:g_rw_lock_reader_locker_new Unexecuted instantiation: cac.c:g_rw_lock_reader_locker_new Unexecuted instantiation: card_7816.c:g_rw_lock_reader_locker_new Unexecuted instantiation: common.c:g_rw_lock_reader_locker_new Unexecuted instantiation: event.c:g_rw_lock_reader_locker_new Unexecuted instantiation: gp.c:g_rw_lock_reader_locker_new Unexecuted instantiation: msft.c:g_rw_lock_reader_locker_new Unexecuted instantiation: simpletlv.c:g_rw_lock_reader_locker_new Unexecuted instantiation: vcard.c:g_rw_lock_reader_locker_new Unexecuted instantiation: vcard_emul_nss.c:g_rw_lock_reader_locker_new Unexecuted instantiation: vcard_emul_type.c:g_rw_lock_reader_locker_new Unexecuted instantiation: vcardt.c:g_rw_lock_reader_locker_new Unexecuted instantiation: vreader.c:g_rw_lock_reader_locker_new Unexecuted instantiation: fuzz_simpletlv.c:g_rw_lock_reader_locker_new  | 
561  |  | G_GNUC_END_IGNORE_DEPRECATIONS  | 
562  |  |  | 
563  |  | /**  | 
564  |  |  * g_rw_lock_reader_locker_free:  | 
565  |  |  * @locker: a GRWLockReaderLocker  | 
566  |  |  *  | 
567  |  |  * Release a read lock on @locker's read-write lock. See  | 
568  |  |  * g_rw_lock_reader_locker_new() for details.  | 
569  |  |  *  | 
570  |  |  * No memory is freed, it is equivalent to a g_rw_lock_reader_unlock() call.  | 
571  |  |  *  | 
572  |  |  * Since: 2.62  | 
573  |  |  */  | 
574  |  | G_GNUC_BEGIN_IGNORE_DEPRECATIONS  | 
575  |  | static inline void  | 
576  |  | g_rw_lock_reader_locker_free (GRWLockReaderLocker *locker)  | 
577  | 0  | { | 
578  | 0  |   g_rw_lock_reader_unlock ((GRWLock *) locker);  | 
579  | 0  | } Unexecuted instantiation: cac-aca.c:g_rw_lock_reader_locker_free Unexecuted instantiation: cac.c:g_rw_lock_reader_locker_free Unexecuted instantiation: card_7816.c:g_rw_lock_reader_locker_free Unexecuted instantiation: common.c:g_rw_lock_reader_locker_free Unexecuted instantiation: event.c:g_rw_lock_reader_locker_free Unexecuted instantiation: gp.c:g_rw_lock_reader_locker_free Unexecuted instantiation: msft.c:g_rw_lock_reader_locker_free Unexecuted instantiation: simpletlv.c:g_rw_lock_reader_locker_free Unexecuted instantiation: vcard.c:g_rw_lock_reader_locker_free Unexecuted instantiation: vcard_emul_nss.c:g_rw_lock_reader_locker_free Unexecuted instantiation: vcard_emul_type.c:g_rw_lock_reader_locker_free Unexecuted instantiation: vcardt.c:g_rw_lock_reader_locker_free Unexecuted instantiation: vreader.c:g_rw_lock_reader_locker_free Unexecuted instantiation: fuzz_simpletlv.c:g_rw_lock_reader_locker_free  | 
580  |  | G_GNUC_END_IGNORE_DEPRECATIONS  | 
581  |  |  | 
582  |  | G_END_DECLS  | 
583  |  |  | 
584  |  | #endif /* __G_THREAD_H__ */  |