3 * Functions copied from glib 2.10
5 * Copyright 2005 David Schleef <ds@schleef.org>
8 #ifndef __GLIB_COMPAT_PRIVATE_H__
9 #define __GLIB_COMPAT_PRIVATE_H__
15 #if !GLIB_CHECK_VERSION(2,25,0)
17 #if defined (_MSC_VER) && !defined(_WIN64)
18 typedef struct _stat32 GStatBuf;
20 typedef struct stat GStatBuf;
25 #if GLIB_CHECK_VERSION(2,26,0)
26 #define GLIB_HAS_GDATETIME
30 #if GLIB_CHECK_VERSION(2,29,5)
31 #define G_ATOMIC_POINTER_COMPARE_AND_EXCHANGE(a,b,c) \
32 g_atomic_pointer_compare_and_exchange ((a),(b),(c))
33 #define G_ATOMIC_INT_COMPARE_AND_EXCHANGE(a,b,c) \
34 g_atomic_int_compare_and_exchange ((a),(b),(c))
36 #define G_ATOMIC_POINTER_COMPARE_AND_EXCHANGE(a,b,c) \
37 g_atomic_pointer_compare_and_exchange ((volatile gpointer *)(a),(b),(c))
38 #define G_ATOMIC_INT_COMPARE_AND_EXCHANGE(a,b,c) \
39 g_atomic_int_compare_and_exchange ((volatile int *)(a),(b),(c))
43 #if GLIB_CHECK_VERSION(2,29,5)
44 #define G_ATOMIC_INT_ADD(a,b) g_atomic_int_add ((a),(b))
46 #define G_ATOMIC_INT_ADD(a,b) g_atomic_int_exchange_and_add ((a),(b))
51 #if GLIB_CHECK_VERSION (2, 31, 0)
52 #define g_mutex_new gst_g_mutex_new
53 static inline GMutex *
54 gst_g_mutex_new (void)
56 GMutex *mutex = g_slice_new (GMutex);
60 #define g_mutex_free gst_g_mutex_free
62 gst_g_mutex_free (GMutex *mutex)
64 g_mutex_clear (mutex);
65 g_slice_free (GMutex, mutex);
67 #define g_static_rec_mutex_init gst_g_static_rec_mutex_init
69 gst_g_static_rec_mutex_init (GStaticRecMutex *mutex)
71 static const GStaticRecMutex init_mutex = G_STATIC_REC_MUTEX_INIT;
75 #define g_cond_new gst_g_cond_new
79 GCond *cond = g_slice_new (GCond);
83 #define g_cond_free gst_g_cond_free
85 gst_g_cond_free (GCond *cond)
88 g_slice_free (GCond, cond);
90 #define g_cond_timed_wait gst_g_cond_timed_wait
91 static inline gboolean
92 gst_g_cond_timed_wait (GCond *cond, GMutex *mutex, GTimeVal *abs_time)
96 if (abs_time == NULL) {
97 g_cond_wait (cond, mutex);
101 end_time = abs_time->tv_sec;
103 end_time += abs_time->tv_usec;
105 /* would be nice if we had clock_rtoffset, but that didn't seem to
106 * make it into the kernel yet...
108 /* if CLOCK_MONOTONIC is not defined then g_get_montonic_time() and
109 * g_get_real_time() are returning the same clock and we'd add ~0
111 end_time += g_get_monotonic_time () - g_get_real_time ();
112 return g_cond_wait_until (cond, mutex, end_time);
114 #endif /* GLIB_CHECK_VERSION (2, 31, 0) */