From patchwork Thu Oct 28 23:59:13 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Turner X-Patchwork-Id: 289032 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o9SNxG2r008647 for ; Thu, 28 Oct 2010 23:59:36 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 22D9E9E75C for ; Thu, 28 Oct 2010 16:59:16 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-gy0-f177.google.com (mail-gy0-f177.google.com [209.85.160.177]) by gabe.freedesktop.org (Postfix) with ESMTP id 0CDBD9E75C for ; Thu, 28 Oct 2010 16:59:05 -0700 (PDT) Received: by gyb11 with SMTP id 11so1798859gyb.36 for ; Thu, 28 Oct 2010 16:59:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:received:date:from:to:subject :message-id:mime-version:content-type:content-disposition:user-agent; bh=nXN0udN64vC7Scu4dLg2kOtCDhVJz1Z0qBQdCqsl5hU=; b=OwKtEtxOuXxDz7WDNcwhxz97/rZ2DQ9X7MzMGF7oC/Sq4sAD23QX+RZPK5qyuWkO7D l19sdS9iLQD3zAoHlTHsKe2ZMHSsA/NYznkzHaS1hS2v9AWlPrfARtREyzBDamznNPGu ipjL4Yo5ev8y571v1eBQwDmjvvjgiNVNkgW3g= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:subject:message-id:mime-version:content-type :content-disposition:user-agent; b=AfRMwX3lNscr7iZtRGlViZ5/4jGZMlYLAcs4u0kZpgDaGN6T1Iz1tyjzD6wqKVvvLo iI6CFlCLIu55h7sS7XDTOeoLE98opAG1yBK6zZQZanJtDV0IICPqgZDbEQApfanIYt/Z TYkE8x505Y1rTzVUnNheYYz+7PdeGRcJm+0Nw= Received: by 10.90.27.4 with SMTP id a4mr2189645aga.135.1288310345548; Thu, 28 Oct 2010 16:59:05 -0700 (PDT) Received: from mattst88@gmail.com (cpe-065-190-173-137.nc.res.rr.com [65.190.173.137]) by mx.google.com with ESMTPS id m45sm1188532yha.11.2010.10.28.16.59.02 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 28 Oct 2010 16:59:04 -0700 (PDT) Received: by mattst88@gmail.com (sSMTP sendmail emulation); Thu, 28 Oct 2010 19:59:13 -0400 Date: Thu, 28 Oct 2010 19:59:13 -0400 From: Matt Turner To: dri-devel@lists.freedesktop.org Subject: [RFC libdrm] Use __sync_val_compare_and_swap to implement DRM_CAS Message-ID: <20101028235913.GA18345@Sempron.nc.rr.com> MIME-Version: 1.0 User-Agent: Mutt/1.5.20 (2009-06-14) X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Thu, 28 Oct 2010 23:59:37 +0000 (UTC) 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) \