Module Name:    src
Committed By:   riz
Date:           Fri Nov  6 22:58:20 UTC 2015

Modified Files:
        src/sys/external/bsd/drm2/include/linux [netbsd-7]: bitops.h

Log Message:
Pull up following revision(s) (requested by riastradh in ticket #1001):
        sys/external/bsd/drm2/include/linux/bitops.h: revision 1.10
        sys/external/bsd/drm2/include/linux/bitops.h: revision 1.11
Fix indexing convention of Linux __ffs/__ffs64 shims.
They reject zero input, and yield zero-based indexing, unlike our
ffs/ffs64, which return zero for zero and yield one-based indexing.
May let nouveau make a little more progress toward booting!
Found by mrg@.
Fix comment in previous.


To generate a diff of this commit:
cvs rdiff -u -r1.7.2.2 -r1.7.2.3 \
    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.7.2.2 src/sys/external/bsd/drm2/include/linux/bitops.h:1.7.2.3
--- src/sys/external/bsd/drm2/include/linux/bitops.h:1.7.2.2	Fri Mar  6 21:39:10 2015
+++ src/sys/external/bsd/drm2/include/linux/bitops.h	Fri Nov  6 22:58:20 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: bitops.h,v 1.7.2.2 2015/03/06 21:39:10 snj Exp $	*/
+/*	$NetBSD: bitops.h,v 1.7.2.3 2015/11/06 22:58:20 riz Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -42,16 +42,24 @@
 
 #include <lib/libkern/libkern.h>
 
+/*
+ * Linux __ffs/__ffs64 is zero-based; zero input is undefined.  Our
+ * ffs/ffs64 is one-based; zero input yields zero.
+ */
 static inline unsigned long
 __ffs(unsigned long x)
 {
-	return ffs64(x);
+
+	KASSERT(x != 0);
+	return ffs64(x) - 1;
 }
 
 static inline unsigned long
 __ffs64(uint64_t x)
 {
-	return ffs64(x);
+
+	KASSERT(x != 0);
+	return ffs64(x) - 1;
 }
 
 static inline unsigned int

Reply via email to