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,26,0)
31 #define GLIB_HAS_GDATETIME
36 #if 0 //GLIB_CHECK_VERSION (2, 31, 0)
37 #define g_mutex_new gst_g_mutex_new
38 static inline GMutex *
39 gst_g_mutex_new (void)
41 GMutex *mutex = g_slice_new (GMutex);
45 #define g_mutex_free gst_g_mutex_free
47 gst_g_mutex_free (GMutex *mutex)
49 g_mutex_clear (mutex);
50 g_slice_free (GMutex, mutex);
52 #define g_static_rec_mutex_init gst_g_static_rec_mutex_init
54 gst_g_static_rec_mutex_init (GStaticRecMutex *mutex)
56 static const GStaticRecMutex init_mutex = G_STATIC_REC_MUTEX_INIT;
60 #define g_cond_new gst_g_cond_new
64 GCond *cond = g_slice_new (GCond);
68 #define g_cond_free gst_g_cond_free
70 gst_g_cond_free (GCond *cond)
73 g_slice_free (GCond, cond);
75 #define g_cond_timed_wait gst_g_cond_timed_wait
76 static inline gboolean
77 gst_g_cond_timed_wait (GCond *cond, GMutex *mutex, GTimeVal *abs_time)
81 if (abs_time == NULL) {
82 g_cond_wait (cond, mutex);
86 end_time = abs_time->tv_sec;
88 end_time += abs_time->tv_usec;
90 /* would be nice if we had clock_rtoffset, but that didn't seem to
91 * make it into the kernel yet...
93 /* if CLOCK_MONOTONIC is not defined then g_get_montonic_time() and
94 * g_get_real_time() are returning the same clock and we'd add ~0
96 end_time += g_get_monotonic_time () - g_get_real_time ();
97 return g_cond_wait_until (cond, mutex, end_time);
99 #endif /* GLIB_CHECK_VERSION (2, 31, 0) */