[vlc-devel] commit: libvlc: only use sync_ on GGCs that have it. (Derk-Jan Hartman )

git version control git at videolan.org
Fri Sep 19 23:36:38 CEST 2008


vlc | branch: master | Derk-Jan Hartman <hartman at videolan.org> | Fri Sep 19 23:37:03 2008 +0200| [360eeee37d0ad3aba5f55c04a853f24ae5d213dd] | committer: Derk-Jan Hartman 

libvlc: only use sync_ on GGCs that have it.

This fixes [d635ae4ed0f1064c07e9209599799c659112f720]

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=360eeee37d0ad3aba5f55c04a853f24ae5d213dd
---

 src/libvlc.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/libvlc.c b/src/libvlc.c
index 7e2ae2e..b67cf89 100644
--- a/src/libvlc.c
+++ b/src/libvlc.c
@@ -76,6 +76,12 @@
 #   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);




More information about the vlc-devel mailing list