gobject: Clean up logic in property checks
[glib.git] / glib / gbitlock.h
blob641ee69660fe22f419fc341dd3d684b80ed093a1
1 /*
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, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
20 * Author: Ryan Lortie <desrt@desrt.ca>
23 #ifndef __G_BITLOCK_H__
24 #define __G_BITLOCK_H__
26 #include <glib/gtypes.h>
28 #if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
29 #error "Only <glib.h> can be included directly."
30 #endif
32 G_BEGIN_DECLS
34 void g_bit_lock (volatile gint *address,
35 gint lock_bit);
36 gboolean g_bit_trylock (volatile gint *address,
37 gint lock_bit);
38 void g_bit_unlock (volatile gint *address,
39 gint lock_bit);
41 void g_pointer_bit_lock (volatile void *address,
42 gint lock_bit);
43 gboolean g_pointer_bit_trylock (volatile void *address,
44 gint lock_bit);
45 void g_pointer_bit_unlock (volatile void *address,
46 gint lock_bit);
48 #ifdef __GNUC__
50 #define g_pointer_bit_lock(address, lock_bit) \
51 (G_GNUC_EXTENSION ({ \
52 G_STATIC_ASSERT (sizeof *(address) == sizeof (gpointer)); \
53 g_pointer_bit_lock ((address), (lock_bit)); \
54 }))
56 #define g_pointer_bit_trylock(address, lock_bit) \
57 (G_GNUC_EXTENSION ({ \
58 G_STATIC_ASSERT (sizeof *(address) == sizeof (gpointer)); \
59 g_pointer_bit_trylock ((address), (lock_bit)); \
60 }))
62 #define g_pointer_bit_unlock(address, lock_bit) \
63 (G_GNUC_EXTENSION ({ \
64 G_STATIC_ASSERT (sizeof *(address) == sizeof (gpointer)); \
65 g_pointer_bit_unlock ((address), (lock_bit)); \
66 }))
68 #endif
70 G_END_DECLS
72 #endif /* __G_BITLOCK_H_ */