3 * Functions copied from glib 2.10
5 * Copyright 2005 David Schleef <ds@schleef.org>
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
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 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
23 #ifndef __GLIB_COMPAT_PRIVATE_H__
24 #define __GLIB_COMPAT_PRIVATE_H__
30 #if !GLIB_CHECK_VERSION(2,25,0)
32 #if defined (_MSC_VER) && !defined(_WIN64)
33 typedef struct _stat32 GStatBuf;
35 typedef struct stat GStatBuf;
40 #if GLIB_CHECK_VERSION(2,26,0)
41 #define GLIB_HAS_GDATETIME
45 #if GLIB_CHECK_VERSION(2,29,5)
46 #define G_ATOMIC_POINTER_COMPARE_AND_EXCHANGE(a,b,c) \
47 g_atomic_pointer_compare_and_exchange ((a),(b),(c))
48 #define G_ATOMIC_INT_COMPARE_AND_EXCHANGE(a,b,c) \
49 g_atomic_int_compare_and_exchange ((a),(b),(c))
51 #define G_ATOMIC_POINTER_COMPARE_AND_EXCHANGE(a,b,c) \
52 g_atomic_pointer_compare_and_exchange ((volatile gpointer *)(a),(b),(c))
53 #define G_ATOMIC_INT_COMPARE_AND_EXCHANGE(a,b,c) \
54 g_atomic_int_compare_and_exchange ((volatile int *)(a),(b),(c))
58 #if GLIB_CHECK_VERSION(2,29,5)
59 #define G_ATOMIC_INT_ADD(a,b) g_atomic_int_add ((a),(b))
61 #define G_ATOMIC_INT_ADD(a,b) g_atomic_int_exchange_and_add ((a),(b))
66 #if GLIB_CHECK_VERSION (2, 31, 0)
67 #define g_mutex_new gst_g_mutex_new
68 static inline GMutex *
69 gst_g_mutex_new (void)
71 GMutex *mutex = g_slice_new (GMutex);
75 #define g_mutex_free gst_g_mutex_free
77 gst_g_mutex_free (GMutex *mutex)
79 g_mutex_clear (mutex);
80 g_slice_free (GMutex, mutex);
82 #define g_static_rec_mutex_init gst_g_static_rec_mutex_init
84 gst_g_static_rec_mutex_init (GStaticRecMutex *mutex)
86 static const GStaticRecMutex init_mutex = G_STATIC_REC_MUTEX_INIT;
90 #define g_cond_new gst_g_cond_new
94 GCond *cond = g_slice_new (GCond);
98 #define g_cond_free gst_g_cond_free
100 gst_g_cond_free (GCond *cond)
103 g_slice_free (GCond, cond);
105 #define g_cond_timed_wait gst_g_cond_timed_wait
106 static inline gboolean
107 gst_g_cond_timed_wait (GCond *cond, GMutex *mutex, GTimeVal *abs_time)
111 if (abs_time == NULL) {
112 g_cond_wait (cond, mutex);
116 end_time = abs_time->tv_sec;
118 end_time += abs_time->tv_usec;
120 /* would be nice if we had clock_rtoffset, but that didn't seem to
121 * make it into the kernel yet...
123 /* if CLOCK_MONOTONIC is not defined then g_get_montonic_time() and
124 * g_get_real_time() are returning the same clock and we'd add ~0
126 end_time += g_get_monotonic_time () - g_get_real_time ();
127 return g_cond_wait_until (cond, mutex, end_time);
129 #endif /* GLIB_CHECK_VERSION (2, 31, 0) */