#define GLIB_HAS_GDATETIME
#endif
+/* See bug #651514 */
+#if GLIB_CHECK_VERSION(2,29,5)
+#define G_ATOMIC_POINTER_COMPARE_AND_EXCHANGE(a,b,c) \
+ g_atomic_pointer_compare_and_exchange ((a),(b),(c))
+#define G_ATOMIC_INT_COMPARE_AND_EXCHANGE(a,b,c) \
+ g_atomic_int_compare_and_exchange ((a),(b),(c))
+#else
+#define G_ATOMIC_POINTER_COMPARE_AND_EXCHANGE(a,b,c) \
+ g_atomic_pointer_compare_and_exchange ((volatile gpointer *)(a),(b),(c))
+#define G_ATOMIC_INT_COMPARE_AND_EXCHANGE(a,b,c) \
+ g_atomic_int_compare_and_exchange ((volatile int *)(a),(b),(c))
+#endif
+
+/* See bug #651514 */
+#if GLIB_CHECK_VERSION(2,29,5)
+#define G_ATOMIC_INT_ADD(a,b) g_atomic_int_add ((a),(b))
+#else
+#define G_ATOMIC_INT_ADD(a,b) g_atomic_int_exchange_and_add ((a),(b))
+#endif
+
/* copies */
/* adaptations */
#include <gst/gst.h>
#include "gstatomicqueue.h"
+#include "glib-compat-private.h"
/**
* SECTION:gstatomicqueue
{
do {
mem->free = g_atomic_pointer_get (&queue->free_list);
- } while (!g_atomic_pointer_compare_and_exchange ((gpointer *) &
- queue->free_list, mem->free, mem));
+ } while (!G_ATOMIC_POINTER_COMPARE_AND_EXCHANGE (&queue->free_list,
+ mem->free, mem));
}
static void
free_list = g_atomic_pointer_get (&queue->free_list);
if (free_list == NULL)
return;
- } while (!g_atomic_pointer_compare_and_exchange ((gpointer *) &
- queue->free_list, free_list, NULL));
+ } while (!G_ATOMIC_POINTER_COMPARE_AND_EXCHANGE (&queue->free_list, free_list,
+ NULL));
while (free_list) {
GstAQueueMem *next = free_list->free;
/* now we try to move the next array as the head memory. If we fail to do that,
* some other reader managed to do it first and we retry */
- if (!g_atomic_pointer_compare_and_exchange ((gpointer *) &
- queue->head_mem, head_mem, next))
+ if (!G_ATOMIC_POINTER_COMPARE_AND_EXCHANGE (&queue->head_mem, head_mem,
+ next))
continue;
/* when we managed to swing the head pointer the old head is now
/* now we try to move the next array as the head memory. If we fail to do that,
* some other reader managed to do it first and we retry */
- if (!g_atomic_pointer_compare_and_exchange ((gpointer *) &
- queue->head_mem, head_mem, next))
+ if (!G_ATOMIC_POINTER_COMPARE_AND_EXCHANGE (&queue->head_mem, head_mem,
+ next))
continue;
/* when we managed to swing the head pointer the old head is now
mem = new_queue_mem ((size << 1) + 1, tail);
/* try to make our new array visible to other writers */
- if (!g_atomic_pointer_compare_and_exchange ((gpointer *) &
- queue->tail_mem, tail_mem, mem)) {
+ if (!G_ATOMIC_POINTER_COMPARE_AND_EXCHANGE (&queue->tail_mem, tail_mem,
+ mem)) {
/* we tried to swap the new writer array but something changed. This is
* because some other writer beat us to it, we free our memory and try
* again */
* an element at the same moment
*/
oclass = GST_ELEMENT_GET_CLASS (element);
- if (!g_atomic_pointer_compare_and_exchange (
- (gpointer) & oclass->elementfactory, NULL, factory))
+ if (!G_ATOMIC_POINTER_COMPARE_AND_EXCHANGE (&oclass->elementfactory, NULL,
+ factory))
gst_object_unref (factory);
GST_DEBUG ("created element \"%s\"", GST_PLUGIN_FEATURE_NAME (factory));
#endif
#include "gst_private.h"
+#include "glib-compat-private.h"
#include <sys/types.h>
#define IS_FLUSHING(s) (g_atomic_int_get(&(s)->flushing))
#define SET_FLUSHING(s,val) (g_atomic_int_set(&(s)->flushing, (val)))
-#define INC_WAITING(s) (g_atomic_int_exchange_and_add(&(s)->waiting, 1))
-#define DEC_WAITING(s) (g_atomic_int_exchange_and_add(&(s)->waiting, -1))
+#define INC_WAITING(s) (G_ATOMIC_INT_ADD(&(s)->waiting, 1))
+#define DEC_WAITING(s) (G_ATOMIC_INT_ADD(&(s)->waiting, -1))
#define GET_WAITING(s) (g_atomic_int_get(&(s)->waiting))
#define TEST_REBUILD(s) (g_atomic_int_compare_and_exchange(&(s)->rebuild, 1, 0))
{
gboolean result = TRUE;
- if (g_atomic_int_exchange_and_add (&set->control_pending, 1) == 0) {
+ if (G_ATOMIC_INT_ADD (&set->control_pending, 1) == 0) {
/* raise when nothing pending */
result = WAKE_EVENT (set);
}
break;
else
/* retry again until we read it successfully */
- g_atomic_int_exchange_and_add (&set->control_pending, 1);
+ G_ATOMIC_INT_ADD (&set->control_pending, 1);
}
}
return old;
#include "gstenumtypes.h"
#include "gstpoll.h"
#include "gstutils.h"
+#include "glib-compat-private.h"
#include <errno.h>
#define GET_ENTRY_STATUS(e) (g_atomic_int_get(&GST_CLOCK_ENTRY_STATUS(e)))
#define SET_ENTRY_STATUS(e,val) (g_atomic_int_set(&GST_CLOCK_ENTRY_STATUS(e),(val)))
-#define CAS_ENTRY_STATUS(e,old,val) (g_atomic_int_compare_and_exchange(\
- ((volatile gint *)&GST_CLOCK_ENTRY_STATUS(e)), (old), (val)))
+#define CAS_ENTRY_STATUS(e,old,val) (G_ATOMIC_INT_COMPARE_AND_EXCHANGE(\
+ (&GST_CLOCK_ENTRY_STATUS(e)), (old), (val)))
/* Define this to get some extra debug about jitter from each clock_wait */
#undef WAIT_DEBUGGING
#include "gstparse.h"
#include "gstvalue.h"
#include "gst-i18n-lib.h"
+#include "glib-compat-private.h"
#include <math.h>
/**
gst_util_seqnum_next (void)
{
static gint counter = 0;
- return g_atomic_int_exchange_and_add (&counter, 1);
+ return G_ATOMIC_INT_ADD (&counter, 1);
}
/**
#include <gst/gst.h>
#include <stdio.h>
#include "gstmultiqueue.h"
+#include <gst/glib-compat-private.h>
/**
* GstSingleQueue:
goto was_eos;
/* Get a unique incrementing id */
- curid = g_atomic_int_exchange_and_add ((gint *) & mq->counter, 1);
+ curid = G_ATOMIC_INT_ADD ((gint *) & mq->counter, 1);
GST_LOG_OBJECT (mq, "SingleQueue %d : about to enqueue buffer %p with id %d",
sq->id, buffer, curid);
goto was_eos;
/* Get an unique incrementing id. */
- curid = g_atomic_int_exchange_and_add ((gint *) & mq->counter, 1);
+ curid = G_ATOMIC_INT_ADD ((gint *) & mq->counter, 1);
item = gst_multi_queue_event_item_new ((GstMiniObject *) event, curid);
#include <stdio.h>
#include <stdlib.h>
#include <gst/gst.h>
+#include <gst/glib-compat-private.h>
#define MAX_THREADS 100
while (running) {
gst_clock_get_time (sysclock);
- prev = g_atomic_int_exchange_and_add (&count, 1);
+ prev = G_ATOMIC_INT_ADD (&count, 1);
if (prev == G_MAXINT)
g_warning ("overflow");
}