]> git.sesse.net Git - vlc/commitdiff
libvlc: only use sync_ on GGCs that have it.
authorDerk-Jan Hartman <hartman@videolan.org>
Fri, 19 Sep 2008 21:37:03 +0000 (23:37 +0200)
committerDerk-Jan Hartman <hartman@videolan.org>
Fri, 19 Sep 2008 21:40:05 +0000 (23:40 +0200)
This fixes [d635ae4ed0f1064c07e9209599799c659112f720]

src/libvlc.c

index 7e2ae2e8d24fc0878a22efb787de42806241cae8..b67cf89c3a68c20fd95564c7c6c38d76fa93a889 100644 (file)
 #   include <hal/libhal.h>
 #endif
 
+#if defined(__GNUC__)
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 0)
+#define USE_SYNC
+#endif
+#endif
+
 #include <vlc_playlist.h>
 #include <vlc_interface.h>
 
@@ -119,7 +125,7 @@ void *vlc_gc_init (gc_object_t *p_gc, void (*pf_destruct) (gc_object_t *))
     p_gc->pf_destructor = pf_destruct;
 
     p_gc->refs = 1;
-#ifdef __GNUC__
+#ifdef USE_SYNC
     __sync_synchronize ();
 #else
     /* Nobody else can possibly lock the spin - it's there as a barrier */
@@ -140,7 +146,7 @@ void *vlc_hold (gc_object_t * p_gc)
     uintptr_t refs;
     assert( p_gc );
 
-#ifdef __GNUC__
+#ifdef USE_SYNC
     refs = __sync_fetch_and_add (&p_gc->refs, 1);
 #else
     vlc_spin_lock (&p_gc->spin);
@@ -161,7 +167,7 @@ void vlc_release (gc_object_t *p_gc)
 
     assert( p_gc );
 
-#ifdef __GNUC__
+#ifdef USE_SYNC
     refs = __sync_fetch_and_sub (&p_gc->refs, 1);
 #else
     vlc_spin_lock (&p_gc->spin);