Revision
42
Author
robert@fledge.watson.org
Date
2009-09-26 04:43:02 -0700 (Sat, 26 Sep 2009)

Log Message

Cast the results of __sync_lock_test_and_set() back to the original type
passed into dispatch_atomic_xchg() so that the caller isn't doing an
implicit conversion from an integer type to a pointer.  This fixes
errors when using gcc built-in atomics with clang on FreeBSD/i386.

Modified Paths

Diff

Modified: trunk/src/hw_shims.h (41 => 42)


--- trunk/src/hw_shims.h	2009-09-25 18:31:19 UTC (rev 41)
+++ trunk/src/hw_shims.h	2009-09-26 11:43:02 UTC (rev 42)
@@ -39,7 +39,7 @@
 #if 0 && defined(__i386__) || defined(__x86_64__)
 #define dispatch_atomic_xchg(p, n)	({ typeof(*(p)) _r; asm("xchg %0, %1" : "=r" (_r) : "m" (*(p)), "0" (n)); _r; })
 #else
-#define dispatch_atomic_xchg(p, n)	__sync_lock_test_and_set((p), (n))
+#define dispatch_atomic_xchg(p, n)	((typeof(*(p)))__sync_lock_test_and_set((p), (n)))
 #endif
 #define dispatch_atomic_cmpxchg(p, o, n)	__sync_bool_compare_and_swap((p), (o), (n))
 #define dispatch_atomic_inc(p)	__sync_add_and_fetch((p), 1)