Subject: cntlzw() -> cpu.h
To: None <port-powerpc@netbsd.org>
From: Jachym Holecek <freza@dspfpga.com>
List: port-powerpc
Date: 06/13/2006 18:45:50
Hello,

I'd like to merge mutiple definitions of cntlzw() to <powerpc/cpu.h>,
OK to commit?

	-- Jachym

Index: macppc/macppc/extintr.c
===================================================================
RCS file: /cvsroot/src/sys/arch/macppc/macppc/extintr.c,v
retrieving revision 1.55
diff -u -r1.55 extintr.c
--- macppc/macppc/extintr.c	24 Dec 2005 22:45:35 -0000	1.55
+++ macppc/macppc/extintr.c	13 Jun 2006 16:35:36 -0000
@@ -87,6 +87,7 @@
 #include <uvm/uvm_extern.h>
 
 #include <machine/autoconf.h>
+#include <machine/cpu.h>
 #include <machine/intr.h>
 #include <machine/psl.h>
 #include <machine/pio.h>
@@ -103,7 +104,6 @@
 void intr_calculatemasks __P((void));
 int fakeintr __P((void *));
 
-static inline int cntlzw __P((int));
 static inline uint32_t gc_read_irq __P((void));
 static inline int mapirq __P((int));
 static void gc_enable_irq __P((int));
@@ -181,20 +181,6 @@
 	return v;
 }
 
-/*
- * Count leading zeros.
- */
-static inline int
-cntlzw(x)
-	int x;
-{
-	int a;
-
-	__asm volatile ("cntlzw %0,%1" : "=r"(a) : "r"(x));
-
-	return a;
-}
-
 uint32_t
 gc_read_irq()
 {
Index: powerpc/include/cpu.h
===================================================================
RCS file: /cvsroot/src/sys/arch/powerpc/include/cpu.h,v
retrieving revision 1.48
diff -u -r1.48 cpu.h
--- powerpc/include/cpu.h	30 May 2006 22:44:13 -0000	1.48
+++ powerpc/include/cpu.h	13 Jun 2006 16:35:38 -0000
@@ -252,6 +252,15 @@
 	return (pvr);
 }
 
+static __inline int
+cntlzw(uint32_t val)
+{
+	int 			cnt;
+
+	__asm volatile ("cntlzw %0,%1" : "=r"(cnt) : "r"(val));
+	return (cnt);
+}
+
 #if defined(PPC_IBM4XX) || defined(PPC_IBM403)
 /*
  * DCR (Device Control Register) access. These have to be
Index: powerpc/marvell/extintr.c
===================================================================
RCS file: /cvsroot/src/sys/arch/powerpc/marvell/extintr.c,v
retrieving revision 1.15
diff -u -r1.15 extintr.c
--- powerpc/marvell/extintr.c	24 Dec 2005 20:07:28 -0000	1.15
+++ powerpc/marvell/extintr.c	13 Jun 2006 16:35:39 -0000
@@ -90,6 +90,7 @@
 
 #include <machine/psl.h>
 #include <machine/bus.h>
+#include <machine/cpu.h>
 #include <machine/intr.h>
 #ifdef KGDB
 #include <machine/db_machdep.h>
@@ -259,19 +260,6 @@
 }
 
 /*
- * Count leading zeros.
- */
-static inline int
-cntlzw(int x)
-{
-	int a;
-
-	__asm volatile ("cntlzw %0,%1" : "=r"(a) : "r"(x));
-
-	return a;
-}
-
-/*
  * softintr_init - establish softclock, softnet; reserve SIR_HWCLOCK
  */
 STATIC void
Index: powerpc/ibm4xx/intr.c
===================================================================
RCS file: /cvsroot/src/sys/arch/powerpc/ibm4xx/intr.c,v
retrieving revision 1.10
diff -u -r1.10 intr.c
--- powerpc/ibm4xx/intr.c	24 Dec 2005 22:45:36 -0000	1.10
+++ powerpc/ibm4xx/intr.c	13 Jun 2006 16:35:39 -0000
@@ -44,6 +44,7 @@
 
 #include <uvm/uvm_extern.h>
 
+#include <machine/cpu.h>
 #include <machine/intr.h>
 #include <machine/psl.h>
 
@@ -67,7 +68,6 @@
 static const char *intr_typename(int);
 
 static int fakeintr(void *);
-static inline int cntlzw(int);
 
 
 volatile int cpl, ipending;
@@ -77,15 +77,6 @@
 static struct intrhand *intrhand[ICU_LEN];
 
 
-static inline int
-cntlzw(int x)
-{
-	int a;
-
-	__asm volatile ("cntlzw %0,%1" : "=r"(a) : "r"(x));
-	return a;
-}
-
 static int
 fakeintr(void *arg)
 {