This file is indexed.

/usr/include/gaminggear-0/gaminggear/threads.h is in libgaminggear-dev 0.15.1-7.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
#ifndef __GAMINGGEAR_THREADS_H__
#define __GAMINGGEAR_THREADS_H__

/*
 * This file is part of libgaminggear.
 *
 * libgaminggear is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * libgaminggear is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with libgaminggear. If not, see <http://www.gnu.org/licenses/>.
 */

/*! \file gaminggear/threads.h
 *  \brief Wrappers around glib thread synchronization primitives.
 *
 *  Glib changed its api with version 2.32.0. These wrappers provide a
 *  consistent api for all glib-2 versions.
 *  
 *  For details please consult the appropriate glib documentation.
 *  [< 2.32.0](https://developer.gnome.org/glib/2.30/glib-Threads.html)
 *  [>= 2.32.0](https://developer.gnome.org/glib/2.32/glib-Threads.html)
 */

#include <glib.h>

G_BEGIN_DECLS

/*! \typedef GaminggearMutex
 *  \brief A mutex.
 */

/*! \typedef GaminggearCond
 *  \brief A condition.
 */

/*! \typedef GaminggearRecMutex
 *  \brief A recursive mutex.
 */

/*! \typedef GaminggearRWLock
 *  \brief A reader/writer lock.
 */

#if (GLIB_CHECK_VERSION(2, 32, 0))
	typedef GMutex GaminggearMutex;
	typedef GCond GaminggearCond;
	typedef GRecMutex GaminggearRecMutex;
	typedef GRWLock GaminggearRWLock;
#else
	typedef GMutex *GaminggearMutex;
	typedef GCond *GaminggearCond;
	typedef GStaticRecMutex GaminggearRecMutex;
	typedef GStaticRWLock GaminggearRWLock;
#endif

/*! \brief Create new thread.
 *  \since 1.0
 */
static inline GThread *gaminggear_thread_try_new(GThreadFunc func, gpointer data, GError **error) {
#if (GLIB_CHECK_VERSION(2, 32, 0))
	return g_thread_try_new(NULL, func, data, error);
#else
	return g_thread_create(func, data, TRUE, error);
#endif
}

/*! \brief Initializes a GaminggearMutex.
 *  \since 1.0
 */
static inline void gaminggear_mutex_init(GaminggearMutex *mutex) {
#if (GLIB_CHECK_VERSION(2, 32, 0))
	g_mutex_init(mutex);
#else
	*mutex = g_mutex_new();
#endif
}

/*! \brief Frees resources of a GaminggearMutex.
 *  \since 1.0
 */
static inline void gaminggear_mutex_clear(GaminggearMutex *mutex) {
#if (GLIB_CHECK_VERSION(2, 32, 0))
	g_mutex_clear(mutex);
#else
	g_mutex_free(*mutex);
#endif
}

/*! \brief Locks a GaminggearMutex.
 *  \since 1.0
 */
static inline void gaminggear_mutex_lock(GaminggearMutex *mutex) {
#if (GLIB_CHECK_VERSION(2, 32, 0))
	g_mutex_lock(mutex);
#else
	g_mutex_lock(*mutex);
#endif
}

/*! \brief Unlocks a GaminggearMutex.
 *  \since 1.0
 */
static inline void gaminggear_mutex_unlock(GaminggearMutex *mutex) {
#if (GLIB_CHECK_VERSION(2, 32, 0))
	g_mutex_unlock(mutex);
#else
	g_mutex_unlock(*mutex);
#endif
}

/*! \brief Initializes a GaminggearCond.
 *  \since 1.0
 */
static inline void gaminggear_cond_init(GaminggearCond *cond) {
#if (GLIB_CHECK_VERSION(2, 32, 0))
	g_cond_init(cond);
#else
	*cond = g_cond_new();
#endif
}

/*! \brief Frees resources of a GaminggearCond.
 *  \since 1.0
 */
static inline void gaminggear_cond_clear(GaminggearCond *cond) {
#if (GLIB_CHECK_VERSION(2, 32, 0))
	g_cond_clear(cond);
#else
	g_cond_free(*cond);
#endif
}

/*! \brief Waits for a signal.
 *  \since 1.0
 */
static inline void gaminggear_cond_wait(GaminggearCond *cond, GaminggearMutex *mutex) {
#if (GLIB_CHECK_VERSION(2, 32, 0))
	g_cond_wait(cond, mutex);
#else
	g_cond_wait(*cond, *mutex);
#endif
}

/*! \brief Condition handler.
 *  \since 1.0
 *  Should return TRUE if condition is met */
typedef gboolean (*gaminggear_cond_handler)(gpointer user_data);

/*! \brief Waits for a signal until condition is met.
 *  \since 1.0
 */
static inline void gaminggear_cond_wait_for(GaminggearCond *cond, GaminggearMutex *mutex, gaminggear_cond_handler handler, gpointer user_data) {
	while (!handler(user_data))
		gaminggear_cond_wait(cond, mutex);
}

/*! \brief Waits for a signal until condition is met or time expired.
 *  \retval FALSE on timeout, TRUE if condition was met.
 *  \since 1.0
 */
static inline gboolean gaminggear_cond_wait_for_timed(GaminggearCond *cond, GaminggearMutex *mutex, glong microseconds, gaminggear_cond_handler handler, gpointer user_data) {
#if (GLIB_CHECK_VERSION(2, 32, 0))
	gint64 end_time = g_get_monotonic_time() + microseconds;
	while(!handler(user_data)) {
		if (!g_cond_wait_until(cond, mutex, end_time))
			return FALSE;
	}
	return TRUE;
#else
	GTimeVal end_time;
	g_get_current_time(&end_time);
	g_time_val_add(&end_time, microseconds);
	while (!handler(user_data)) {
		if (!g_cond_timed_wait(*cond, *mutex, &end_time))
			return FALSE;
	}
	return TRUE;
#endif
}

/*! \brief Wake up a waiting thread.
 *  \since 1.0
 */
static inline void gaminggear_cond_signal(GaminggearCond *cond) {
#if (GLIB_CHECK_VERSION(2, 32, 0))
	g_cond_signal(cond);
#else
	g_cond_signal(*cond);
#endif
}

/*! \brief Initializes a GaminggearRecMutex.
 *  \since 1.0
 */
static inline void gaminggear_rec_mutex_init(GaminggearRecMutex *mutex) {
#if (GLIB_CHECK_VERSION(2, 32, 0))
	g_rec_mutex_init(mutex);
#else
	g_static_rec_mutex_init(mutex);
#endif
}

/*! \brief Frees resources of a GaminggearRecMutex.
 *  \since 1.0
 */
static inline void gaminggear_rec_mutex_clear(GaminggearRecMutex *mutex) {
#if (GLIB_CHECK_VERSION(2, 32, 0))
	g_rec_mutex_clear(mutex);
#else
	g_static_rec_mutex_free(mutex);
#endif
}

/*! \brief Locks a GaminggearRecMutex.
 *  \since 1.0
 */
static inline void gaminggear_rec_mutex_lock(GaminggearRecMutex *mutex) {
#if (GLIB_CHECK_VERSION(2, 32, 0))
	g_rec_mutex_lock(mutex);
#else
	g_static_rec_mutex_lock(mutex);
#endif
}

/*! \brief Unlocks a GaminggearRecMutex.
 *  \since 1.0
 */
static inline void gaminggear_rec_mutex_unlock(GaminggearRecMutex *mutex) {
#if (GLIB_CHECK_VERSION(2, 32, 0))
	g_rec_mutex_unlock(mutex);
#else
	g_static_rec_mutex_unlock(mutex);
#endif
}

/*! \brief Initializes a GaminggearRWLock.
 *  \since 1.0
 */
static inline void gaminggear_rw_lock_init(GaminggearRWLock *lock) {
#if (GLIB_CHECK_VERSION(2, 32, 0))
	g_rw_lock_init(lock);
#else
	g_static_rw_lock_init(lock);
#endif
}

/*! \brief Frees resources of a GaminggearRWLock.
 *  \since 1.0
 */
static inline void gaminggear_rw_lock_clear(GaminggearRWLock *lock) {
#if (GLIB_CHECK_VERSION(2, 32, 0))
	g_rw_lock_clear(lock);
#else
	g_static_rw_lock_free(lock);
#endif
}

/*! \brief Locks a GaminggearRWLock in reader mode.
 *  \since 1.0
 */
static inline void gaminggear_rw_lock_reader_lock(GaminggearRWLock *lock) {
#if (GLIB_CHECK_VERSION(2, 32, 0))
	g_rw_lock_reader_lock(lock);
#else
	g_static_rw_lock_reader_lock(lock);
#endif
}

/*! \brief Unlocks a reader mode locked GaminggearRWLock.
 *  \since 1.0
 */
static inline void gaminggear_rw_lock_reader_unlock(GaminggearRWLock *lock) {
#if (GLIB_CHECK_VERSION(2, 32, 0))
	g_rw_lock_reader_unlock(lock);
#else
	g_static_rw_lock_reader_unlock(lock);
#endif
}

/*! \brief Locks a GaminggearRWLock in writer mode.
 *  \since 1.0
 */
static inline void gaminggear_rw_lock_writer_lock(GaminggearRWLock *lock) {
#if (GLIB_CHECK_VERSION(2, 32, 0))
	g_rw_lock_writer_lock(lock);
#else
	g_static_rw_lock_writer_lock(lock);
#endif
}

/*! \brief Unlocks a writer mode locked GaminggearRWLock.
 *  \since 1.0
 */
static inline void gaminggear_rw_lock_writer_unlock(GaminggearRWLock *lock) {
#if (GLIB_CHECK_VERSION(2, 32, 0))
	g_rw_lock_writer_unlock(lock);
#else
	g_static_rw_lock_writer_unlock(lock);
#endif
}

G_END_DECLS

#endif