2 * Copyright © 2008 Ryan Lortie
3 * Copyright © 2010 Codethink Limited
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the licence, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18 * Author: Ryan Lortie <desrt@desrt.ca>
21 #ifndef __G_BITLOCK_H__
22 #define __G_BITLOCK_H__
24 #include <glib/gtypes.h>
26 #if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
27 #error "Only <glib.h> can be included directly."
33 void g_bit_lock (volatile gint *address,
36 gboolean g_bit_trylock (volatile gint *address,
39 void g_bit_unlock (volatile gint *address,
43 void g_pointer_bit_lock (volatile void *address,
46 gboolean g_pointer_bit_trylock (volatile void *address,
49 void g_pointer_bit_unlock (volatile void *address,
54 #define g_pointer_bit_lock(address, lock_bit) \
55 (G_GNUC_EXTENSION ({ \
56 G_STATIC_ASSERT (sizeof *(address) == sizeof (gpointer)); \
57 g_pointer_bit_lock ((address), (lock_bit)); \
60 #define g_pointer_bit_trylock(address, lock_bit) \
61 (G_GNUC_EXTENSION ({ \
62 G_STATIC_ASSERT (sizeof *(address) == sizeof (gpointer)); \
63 g_pointer_bit_trylock ((address), (lock_bit)); \
66 #define g_pointer_bit_unlock(address, lock_bit) \
67 (G_GNUC_EXTENSION ({ \
68 G_STATIC_ASSERT (sizeof *(address) == sizeof (gpointer)); \
69 g_pointer_bit_unlock ((address), (lock_bit)); \
76 #endif /* __G_BITLOCK_H_ */