Module Name:    src
Committed By:   riastradh
Date:           Thu Jul 17 14:28:28 UTC 2014

Modified Files:
        src/sys/external/bsd/drm2/include/linux: bitops.h

Log Message:
Add non-atomic Linux test-and-set operations.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/external/bsd/drm2/include/linux/bitops.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm2/include/linux/bitops.h
diff -u src/sys/external/bsd/drm2/include/linux/bitops.h:1.4 src/sys/external/bsd/drm2/include/linux/bitops.h:1.5
--- src/sys/external/bsd/drm2/include/linux/bitops.h:1.4	Wed Jul 16 20:59:58 2014
+++ src/sys/external/bsd/drm2/include/linux/bitops.h	Thu Jul 17 14:28:28 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: bitops.h,v 1.4 2014/07/16 20:59:58 riastradh Exp $	*/
+/*	$NetBSD: bitops.h,v 1.5 2014/07/17 14:28:28 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -97,6 +97,48 @@ __change_bit(unsigned int n, volatile un
 }
 
 static inline unsigned long
+__test_and_set_bit(unsigned int bit, volatile unsigned long *ptr)
+{
+	const unsigned int units = (sizeof(*ptr) * CHAR_BIT);
+	volatile unsigned long *const p = &ptr[bit / units];
+	const unsigned long mask = (1UL << (bit % units));
+	unsigned long v;
+
+	v = *p;
+	*p |= mask;
+
+	return (v & mask);
+}
+
+static inline unsigned long
+__test_and_clear_bit(unsigned int bit, volatile unsigned long *ptr)
+{
+	const unsigned int units = (sizeof(*ptr) * CHAR_BIT);
+	volatile unsigned long *const p = &ptr[bit / units];
+	const unsigned long mask = (1UL << (bit % units));
+	unsigned long v;
+
+	v = *p;
+	*p &= ~mask;
+
+	return (v & mask);
+}
+
+static inline unsigned long
+__test_and_change_bit(unsigned int bit, volatile unsigned long *ptr)
+{
+	const unsigned int units = (sizeof(*ptr) * CHAR_BIT);
+	volatile unsigned long *const p = &ptr[bit / units];
+	const unsigned long mask = (1UL << (bit % units));
+	unsigned long v;
+
+	v = *p;
+	*p ^= mask;
+
+	return (v & mask);
+}
+
+static inline unsigned long
 find_first_zero_bit(const unsigned long *ptr, unsigned long nbits)
 {
 	const size_t bpl = (CHAR_BIT * sizeof(*ptr));

Reply via email to