[vlc-devel] [PATCH] Mingw support for GC

Rémi Denis-Courmont rdenis at simphalempin.com
Sat Sep 20 16:25:18 CEST 2008


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

diff --git a/src/libvlc.c b/src/libvlc.c
index b7c9e63..41c52cf 100644
--- a/src/libvlc.c
+++ b/src/libvlc.c
@@ -152,7 +152,12 @@ void *vlc_hold (gc_object_t * p_gc)
     uintptr_t refs;
     assert( p_gc );
 
-#ifdef USE_SYNC
+#if defined (WIN32)
+    refs = -1 +
+        __builtin_choose_expr (sizeof (uintptr_t) == 4,
+            InterlockedIncrement (&p_gc->refs),
+            InterlockedIncrement64 (&p_gc->refs));
+#elif defined (USE_SYNC)
     refs = __sync_fetch_and_add (&p_gc->refs, 1);
 #elif defined(__APPLE__)
     refs = OSAtomicIncrement32Barrier((int*)&p_gc->refs) - 1;
@@ -175,7 +180,12 @@ void vlc_release (gc_object_t *p_gc)
 
     assert( p_gc );
 
-#ifdef USE_SYNC
+#if defined (WIN32)
+    refs = 1 +
+        __builtin_choose_expr (sizeof (uintptr_t) == 4,
+            InterlockedDecrement (&p_gc->refs),
+            InterlockedDecrement64 (&p_gc->refs));
+#elif defined (USE_SYNC)
     refs = __sync_fetch_and_sub (&p_gc->refs, 1);
 #elif defined(__APPLE__)
     refs = OSAtomicDecrement32Barrier((int*)&p_gc->refs) + 1;
-- 
1.5.6.5




More information about the vlc-devel mailing list