Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/riastradh-drm2]: src/sys/external/bsd/drm2/include/linux Add Linuxoid no...
details: https://anonhg.NetBSD.org/src/rev/8d945bb017b2
branches: riastradh-drm2
changeset: 788513:8d945bb017b2
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sun Sep 08 15:37:34 2013 +0000
description:
Add Linuxoid non-atomic __set/clear_bit to <linux/bitops.h>.
diffstat:
sys/external/bsd/drm2/include/linux/bitops.h | 50 +++++++++++++++++++++++++++-
1 files changed, 49 insertions(+), 1 deletions(-)
diffs (69 lines):
diff -r 14193c134869 -r 8d945bb017b2 sys/external/bsd/drm2/include/linux/bitops.h
--- a/sys/external/bsd/drm2/include/linux/bitops.h Sun Sep 08 15:37:04 2013 +0000
+++ b/sys/external/bsd/drm2/include/linux/bitops.h Sun Sep 08 15:37:34 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bitops.h,v 1.1.2.2 2013/07/24 03:44:39 riastradh Exp $ */
+/* $NetBSD: bitops.h,v 1.1.2.3 2013/09/08 15:37:34 riastradh Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -32,6 +32,13 @@
#ifndef _LINUX_BITOPS_H_
#define _LINUX_BITOPS_H_
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/atomic.h>
+#include <sys/cdefs.h>
+
+#include <machine/limits.h>
+
#include <lib/libkern/libkern.h>
static inline unsigned int
@@ -40,4 +47,45 @@
return popcount32(n);
}
+/*
+ * XXX Don't define BITS_PER_LONG as sizeof(unsigned long)*CHAR_BIT
+ * because that won't work in preprocessor conditionals, where it often
+ * turns up.
+ */
+
+#define BITS_TO_LONGS(n) \
+ roundup2((n), (sizeof(unsigned long) * CHAR_BIT))
+
+static inline int
+test_bit(unsigned int n, const volatile unsigned long *p)
+{
+ const unsigned units = (sizeof(unsigned long) * CHAR_BIT);
+
+ return ((p[n / units] & (1UL << (n % units))) != 0);
+}
+
+static inline void
+__set_bit(unsigned int n, volatile unsigned long *p)
+{
+ const unsigned units = (sizeof(unsigned long) * CHAR_BIT);
+
+ p[n / units] |= (1UL << (n % units));
+}
+
+static inline void
+__clear_bit(unsigned int n, volatile unsigned long *p)
+{
+ const unsigned units = (sizeof(unsigned long) * CHAR_BIT);
+
+ p[n / units] &= ~(1UL << (n % units));
+}
+
+static inline void
+__change_bit(unsigned int n, volatile unsigned long *p)
+{
+ const unsigned units = (sizeof(unsigned long) * CHAR_BIT);
+
+ p[n / units] ^= (1UL << (n % units));
+}
+
#endif /* _LINUX_BITOPS_H_ */
Home |
Main Index |
Thread Index |
Old Index