From owner-svn-src-head@FreeBSD.ORG Sun Aug 25 14:33:50 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 8C848E7E; Sun, 25 Aug 2013 14:33:50 +0000 (UTC) (envelope-from dumbbell@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 796BC20AD; Sun, 25 Aug 2013 14:33:50 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r7PEXopj038877; Sun, 25 Aug 2013 14:33:50 GMT (envelope-from dumbbell@svn.freebsd.org) Received: (from dumbbell@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r7PEXoxF038875; Sun, 25 Aug 2013 14:33:50 GMT (envelope-from dumbbell@svn.freebsd.org) Message-Id: <201308251433.r7PEXoxF038875@svn.freebsd.org> From: Jean-Sebastien Pedron Date: Sun, 25 Aug 2013 14:33:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r254860 - head/sys/dev/drm2 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Aug 2013 14:33:50 -0000 Author: dumbbell Date: Sun Aug 25 14:33:49 2013 New Revision: 254860 URL: http://svnweb.freebsd.org/changeset/base/254860 Log: drm: Update drm_atomic.h, now that projects/atomic64 is in HEAD Submitted by: jkim@ Modified: head/sys/dev/drm2/drm_atomic.h Modified: head/sys/dev/drm2/drm_atomic.h ============================================================================== --- head/sys/dev/drm2/drm_atomic.h Sun Aug 25 14:29:47 2013 (r254859) +++ head/sys/dev/drm2/drm_atomic.h Sun Aug 25 14:33:49 2013 (r254860) @@ -32,62 +32,51 @@ #include __FBSDID("$FreeBSD$"); -/* Many of these implementations are rather fake, but good enough. */ +typedef uint32_t atomic_t; +typedef uint64_t atomic64_t; -typedef u_int32_t atomic_t; +#define BITS_TO_LONGS(x) howmany(x, sizeof(long) * NBBY) -#define atomic_set(p, v) (*(p) = (v)) -#define atomic_read(p) (*(p)) -#define atomic_inc(p) atomic_add_int(p, 1) -#define atomic_dec(p) atomic_subtract_int(p, 1) -#define atomic_add(n, p) atomic_add_int(p, n) -#define atomic_sub(n, p) atomic_subtract_int(p, n) +#define atomic_set(p, v) atomic_store_rel_int(p, v) +#define atomic_read(p) atomic_load_acq_int(p) -static __inline atomic_t -test_and_set_bit(int b, volatile void *p) -{ - int s = splhigh(); - unsigned int m = 1<> 5), 1 << (b & 0x1f)); -} - -static __inline void -set_bit(int b, volatile void *p) -{ - atomic_set_int(((volatile int *)p) + (b >> 5), 1 << (b & 0x1f)); -} - -static __inline int -test_bit(int b, volatile void *p) -{ - return ((volatile int *)p)[b >> 5] & (1 << (b & 0x1f)); -} +#define atomic_add(v, p) atomic_add_int(p, v) +#define atomic_sub(v, p) atomic_subtract_int(p, v) +#define atomic_inc(p) atomic_add(1, p) +#define atomic_dec(p) atomic_sub(1, p) + +#define atomic_add_return(v, p) (atomic_fetchadd_int(p, v) + (v)) +#define atomic_sub_return(v, p) (atomic_fetchadd_int(p, -(v)) - (v)) +#define atomic_inc_return(p) atomic_add_return(1, p) +#define atomic_dec_return(p) atomic_sub_return(1, p) + +#define atomic_add_and_test(v, p) (atomic_add_return(v, p) == 0) +#define atomic_sub_and_test(v, p) (atomic_sub_return(v, p) == 0) +#define atomic_inc_and_test(p) (atomic_inc_return(p) == 0) +#define atomic_dec_and_test(p) (atomic_dec_return(p) == 0) + +#define atomic_xchg(p, v) atomic_swap_int(p, v) +#define atomic64_xchg(p, v) atomic_swap_64(p, v) + +#define clear_bit(b, p) \ + atomic_clear_int((volatile u_int *)(p) + (b) / 32, 1 << (b) % 32) +#define set_bit(b, p) \ + atomic_set_int((volatile u_int *)(p) + (b) / 32, 1 << (b) % 32) +#define test_bit(b, p) \ + (atomic_load_acq_int((volatile u_int *)(p) + (b) / 32) & (1 << (b) % 32)) +#define test_and_set_bit(b, p) \ + atomic_testandset_int((volatile u_int *)(p) + (b) / 32, b) static __inline int find_first_zero_bit(volatile void *p, int max) { - int b; - volatile int *ptr = (volatile int *)p; + volatile int *np = p; + int i, n; - for (b = 0; b < max; b += 32) { - if (ptr[b >> 5] != ~0) { - for (;;) { - if ((ptr[b >> 5] & (1 << (b & 0x1f))) == 0) - return b; - b++; - } - } + for (i = 0; i < max / (NBBY * sizeof(int)); i++) { + n = ~np[i]; + if (n != 0) + return (i * NBBY * sizeof(int) + ffs(n) - 1); } - return max; + return (max); } - -#define BITS_TO_LONGS(x) (howmany((x), NBBY * sizeof(long)))