Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
gbitlock.h
Go to the documentation of this file.
1/*
2 * Copyright © 2008 Ryan Lortie
3 * Copyright © 2010 Codethink Limited
4 *
5 * SPDX-License-Identifier: LGPL-2.1-or-later
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
19 *
20 * Author: Ryan Lortie <desrt@desrt.ca>
21 */
22
23#ifndef __G_BITLOCK_H__
24#define __G_BITLOCK_H__
25
26#include <glib/gtypes.h>
27
28#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
29#error "Only <glib.h> can be included directly."
30#endif
31
33
35void g_bit_lock (volatile gint *address,
36 gint lock_bit);
38gboolean g_bit_trylock (volatile gint *address,
39 gint lock_bit);
41void g_bit_unlock (volatile gint *address,
42 gint lock_bit);
43
45void g_pointer_bit_lock (volatile void *address,
46 gint lock_bit);
47
50 guint lock_bit,
51 guintptr *out_ptr);
52
54gboolean g_pointer_bit_trylock (volatile void *address,
55 gint lock_bit);
57void g_pointer_bit_unlock (volatile void *address,
58 gint lock_bit);
59
62 guint lock_bit,
63 gboolean set,
64 guintptr preserve_mask,
65 gpointer preserve_ptr);
66
68void g_pointer_bit_unlock_and_set (void *address,
69 guint lock_bit,
70 gpointer ptr,
71 guintptr preserve_mask);
72
73#ifdef __GNUC__
74
75#define g_pointer_bit_lock(address, lock_bit) \
76 (G_GNUC_EXTENSION ({ \
77 G_STATIC_ASSERT (sizeof *(address) == sizeof (gpointer)); \
78 g_pointer_bit_lock ((address), (lock_bit)); \
79 }))
80
81#define g_pointer_bit_lock_and_get(address, lock_bit, out_ptr) \
82 (G_GNUC_EXTENSION ({ \
83 G_STATIC_ASSERT (sizeof *(address) == sizeof (gpointer)); \
84 g_pointer_bit_lock_and_get ((address), (lock_bit), (out_ptr)); \
85 }))
86
87#define g_pointer_bit_trylock(address, lock_bit) \
88 (G_GNUC_EXTENSION ({ \
89 G_STATIC_ASSERT (sizeof *(address) == sizeof (gpointer)); \
90 g_pointer_bit_trylock ((address), (lock_bit)); \
91 }))
92
93#define g_pointer_bit_unlock(address, lock_bit) \
94 (G_GNUC_EXTENSION ({ \
95 G_STATIC_ASSERT (sizeof *(address) == sizeof (gpointer)); \
96 g_pointer_bit_unlock ((address), (lock_bit)); \
97 }))
98
99#define g_pointer_bit_unlock_and_set(address, lock_bit, ptr, preserve_mask) \
100 (G_GNUC_EXTENSION ({ \
101 G_STATIC_ASSERT (sizeof *(address) == sizeof (gpointer)); \
102 g_pointer_bit_unlock_and_set ((address), (lock_bit), (ptr), (preserve_mask)); \
103 }))
104
105#endif
106
108
109#endif /* __G_BITLOCK_H_ */
GLIB_AVAILABLE_IN_ALL void g_pointer_bit_lock(volatile void *address, gint lock_bit)
GLIB_AVAILABLE_IN_2_80 void g_pointer_bit_unlock_and_set(void *address, guint lock_bit, gpointer ptr, guintptr preserve_mask)
GLIB_AVAILABLE_IN_2_80 void g_pointer_bit_lock_and_get(gpointer address, guint lock_bit, guintptr *out_ptr)
GLIB_AVAILABLE_IN_ALL void g_bit_unlock(volatile gint *address, gint lock_bit)
GLIB_AVAILABLE_IN_ALL gboolean g_pointer_bit_trylock(volatile void *address, gint lock_bit)
G_BEGIN_DECLS GLIB_AVAILABLE_IN_ALL void g_bit_lock(volatile gint *address, gint lock_bit)
GLIB_AVAILABLE_IN_ALL gboolean g_bit_trylock(volatile gint *address, gint lock_bit)
GLIB_AVAILABLE_IN_ALL void g_pointer_bit_unlock(volatile void *address, gint lock_bit)
GLIB_AVAILABLE_IN_2_80 gpointer g_pointer_bit_lock_mask_ptr(gpointer ptr, guint lock_bit, gboolean set, guintptr preserve_mask, gpointer preserve_ptr)
#define GLIB_AVAILABLE_IN_ALL
#define GLIB_AVAILABLE_IN_2_80
unsigned long guintptr
Definition glibconfig.h:110
#define G_END_DECLS
Definition gmacros.h:910
#define G_BEGIN_DECLS
Definition gmacros.h:909
gint gboolean
Definition gtypes.h:56
void * gpointer
Definition gtypes.h:109
int gint
Definition gtypes.h:55
unsigned int guint
Definition gtypes.h:61