diff mbox

[RFC,libdrm] Use __sync_val_compare_and_swap to implement DRM_CAS

Message ID 20101028235913.GA18345@Sempron.nc.rr.com (mailing list archive)
State New, archived
Headers show

Commit Message

Matt Turner Oct. 28, 2010, 11:59 p.m. UTC
None
diff mbox

Patch

diff --git a/xf86drm.h b/xf86drm.h
index 9b89f56..1459b5a 100644
--- a/xf86drm.h
+++ b/xf86drm.h
@@ -333,7 +333,12 @@  typedef struct _drmSetVersion {
 #define DRM_LOCK_HELD  0x80000000U /**< Hardware lock is held */
 #define DRM_LOCK_CONT  0x40000000U /**< Hardware lock is contended */
 
-#if defined(__GNUC__) && (__GNUC__ >= 2)
+#if defined(__GNUC__) && (__GNUC__ >= 4)
+
+#define DRM_CAS(lock, old, new, __ret)	\
+	__ret = __sync_val_compare_and_swap(i&__drm_dummy_lock(lock), (old), (new)) != (old)
+
+#elif defined(__GNUC__) && (__GNUC__ >= 2)
 # if defined(__i386) || defined(__AMD64__) || defined(__x86_64__) || defined(__amd64__)
 				/* Reflect changes here to drmP.h */
 #define DRM_CAS(lock,old,new,__ret)                                    \