svn commit: r213819 - projects/ofed/head/sys/ofed/include/linux

Jeff Roberson jeff at FreeBSD.org
Thu Oct 14 01:46:21 UTC 2010


Author: jeff
Date: Thu Oct 14 01:46:20 2010
New Revision: 213819
URL: http://svn.freebsd.org/changeset/base/213819

Log:
   - Add implementations of test_and_set and test_and_clear
  
  Sponsored by:	Isilon Systems, iX Systems, and Panasas.

Modified:
  projects/ofed/head/sys/ofed/include/linux/bitops.h

Modified: projects/ofed/head/sys/ofed/include/linux/bitops.h
==============================================================================
--- projects/ofed/head/sys/ofed/include/linux/bitops.h	Thu Oct 14 01:45:49 2010	(r213818)
+++ projects/ofed/head/sys/ofed/include/linux/bitops.h	Thu Oct 14 01:46:20 2010	(r213819)
@@ -280,4 +280,30 @@ bitmap_empty(unsigned long *addr, int si
 #define	test_bit(i, a)							\
     !!(atomic_load_acq_int(&((volatile int *)(a))[(i)/NBINT]) & 1 << ((i) % NBINT))
 
+static inline long
+test_and_clear_bit(long bit, long *var)
+{
+	long val;
+
+	bit = 1 << bit;
+	do {
+		val = *(volatile long *)var;
+	} while (atomic_cmpset_long(var, val, val & ~bit) == 0);
+
+	return !!(val & bit);
+}
+
+static inline long
+test_and_set_bit(long bit, long *var)
+{
+	long val;
+
+	bit = 1 << bit;
+	do {
+		val = *(volatile long *)var;
+	} while (atomic_cmpset_long(var, val, val | bit) == 0);
+
+	return !!(val & bit);
+}
+
 #endif	/* _LINUX_BITOPS_H_ */


More information about the svn-src-projects mailing list