Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch Use __builtin_clz instead of cntlzw



details:   https://anonhg.NetBSD.org/src/rev/fede8d27d661
branches:  trunk
changeset: 766243:fede8d27d661
user:      matt <matt%NetBSD.org@localhost>
date:      Sun Jun 19 07:59:46 2011 +0000

description:
Use __builtin_clz instead of cntlzw

diffstat:

 sys/arch/amigappc/amigappc/pic_amiga.c |   6 +++---
 sys/arch/macppc/macppc/pic_heathrow.c  |   8 ++++----
 sys/arch/macppc/macppc/pic_ohare.c     |  14 +++++++-------
 sys/arch/powerpc/oea/pmap.c            |  11 ++++++-----
 sys/arch/rs6000/rs6000/pic_iocc.c      |   6 +++---
 5 files changed, 23 insertions(+), 22 deletions(-)

diffs (193 lines):

diff -r bd17c12737e5 -r fede8d27d661 sys/arch/amigappc/amigappc/pic_amiga.c
--- a/sys/arch/amigappc/amigappc/pic_amiga.c    Sun Jun 19 07:34:24 2011 +0000
+++ b/sys/arch/amigappc/amigappc/pic_amiga.c    Sun Jun 19 07:59:46 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pic_amiga.c,v 1.2 2010/02/02 19:15:33 phx Exp $ */
+/* $NetBSD: pic_amiga.c,v 1.3 2011/06/19 07:59:47 matt Exp $ */
 
 /*-
  * Copyright (c) 2008,2009,2010 Frank Wille.
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pic_amiga.c,v 1.2 2010/02/02 19:15:33 phx Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic_amiga.c,v 1.3 2011/06/19 07:59:47 matt Exp $");
 
 #include <sys/param.h>
 #include <sys/malloc.h>
@@ -104,7 +104,7 @@
                if (!(dmask & ~(iplmask - 1))) {
 
                        /* Lower the emulated PPC IPL to the next highest */
-                       newipl = 31 - cntlzw(dmask);
+                       newipl = 31 - __builtin_clz(dmask);
                        P5write(P5_IPL_EMU, P5_SET_CLEAR | P5_DISABLE_INT |
                            (newipl ^ P5_IPL_MASK));
                        P5write(P5_IPL_EMU, P5_DISABLE_INT | newipl);
diff -r bd17c12737e5 -r fede8d27d661 sys/arch/macppc/macppc/pic_heathrow.c
--- a/sys/arch/macppc/macppc/pic_heathrow.c     Sun Jun 19 07:34:24 2011 +0000
+++ b/sys/arch/macppc/macppc/pic_heathrow.c     Sun Jun 19 07:59:46 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pic_heathrow.c,v 1.5 2010/12/20 00:25:37 matt Exp $ */
+/*     $NetBSD: pic_heathrow.c,v 1.6 2011/06/19 07:59:47 matt Exp $ */
 
 /*-
  * Copyright (c) 2007 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pic_heathrow.c,v 1.5 2010/12/20 00:25:37 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic_heathrow.c,v 1.6 2011/06/19 07:59:47 matt Exp $");
 
 #include "opt_interrupt.h"
 
@@ -232,14 +232,14 @@
                return 255;
 
        if (heathrow->pending_events_l != 0) {
-               bit = 31 - cntlzw(heathrow->pending_events_l);
+               bit = 31 - __builtin_clz(heathrow->pending_events_l);
                mask = 1 << bit;
                heathrow->pending_events_l &= ~mask;
                return bit;
        }
 
        if (heathrow->pending_events_h != 0) {
-               bit = 31 - cntlzw(heathrow->pending_events_h);
+               bit = 31 - __builtin_clz(heathrow->pending_events_h);
                mask = 1 << bit;
                heathrow->pending_events_h &= ~mask;
                return bit + 32;
diff -r bd17c12737e5 -r fede8d27d661 sys/arch/macppc/macppc/pic_ohare.c
--- a/sys/arch/macppc/macppc/pic_ohare.c        Sun Jun 19 07:34:24 2011 +0000
+++ b/sys/arch/macppc/macppc/pic_ohare.c        Sun Jun 19 07:59:46 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pic_ohare.c,v 1.8 2010/12/20 00:25:37 matt Exp $ */
+/*     $NetBSD: pic_ohare.c,v 1.9 2011/06/19 07:59:47 matt Exp $ */
 
 /*-
  * Copyright (c) 2007 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pic_ohare.c,v 1.8 2010/12/20 00:25:37 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic_ohare.c,v 1.9 2011/06/19 07:59:47 matt Exp $");
 
 #include "opt_interrupt.h"
 
@@ -236,7 +236,7 @@
        if (ohare->pending_events == 0)
                return 255;
 
-       bit = 31 - cntlzw(ohare->pending_events);
+       bit = 31 - __builtin_clz(ohare->pending_events);
        mask = 1 << bit;
        if ((ohare->pending_events & ~mask) == 0) {
 
@@ -252,7 +252,7 @@
        evt = ohare->pending_events & ~mask;
        prio = ohare->priority_masks[bit];
        while (evt != 0) {
-               bit = 31 - cntlzw(evt);
+               bit = 31 - __builtin_clz(evt);
                prio |= ohare->priority_masks[bit];
                evt &= ~(1 << bit);
 #ifdef OHARE_DEBUG
@@ -261,7 +261,7 @@
                        panic("hanging in ohare_get_irq");
 #endif
        }
-       lvl = 31 - cntlzw(prio);
+       lvl = 31 - __builtin_clz(prio);
        evt = ohare->pending_events & ohare->irqs[lvl];
 
        if (evt == 0) {
@@ -270,7 +270,7 @@
                evt = ohare->pending_events;
        }
 
-       bit = 31 - cntlzw(evt);
+       bit = 31 - __builtin_clz(evt);
        mask = 1 << bit;
        ohare->pending_events &= ~mask;
        return bit;     
@@ -306,7 +306,7 @@
        for (i = 0; i < OHARE_NIRQ; i++) {
                if (ohare->priority_masks[i] == 0)
                        continue;
-               level = 31 - cntlzw(ohare->priority_masks[i]);
+               level = 31 - __builtin_clz(ohare->priority_masks[i]);
                ohare->irqs[level] |= (1 << i);
        }
 }
diff -r bd17c12737e5 -r fede8d27d661 sys/arch/powerpc/oea/pmap.c
--- a/sys/arch/powerpc/oea/pmap.c       Sun Jun 19 07:34:24 2011 +0000
+++ b/sys/arch/powerpc/oea/pmap.c       Sun Jun 19 07:59:46 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pmap.c,v 1.79 2011/05/02 01:49:23 matt Exp $   */
+/*     $NetBSD: pmap.c,v 1.80 2011/06/19 07:59:47 matt Exp $   */
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -63,7 +63,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.79 2011/05/02 01:49:23 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.80 2011/06/19 07:59:47 matt Exp $");
 
 #define        PMAP_NOOPNAMES
 
@@ -83,10 +83,11 @@
 
 #include <uvm/uvm.h>
 
-#include <machine/pcb.h>
 #include <machine/powerpc.h>
+#include <powerpc/bat.h>
+#include <powerpc/pcb.h>
+#include <powerpc/psl.h>
 #include <powerpc/spr.h>
-#include <powerpc/bat.h>
 #include <powerpc/stdarg.h>
 #include <powerpc/oea/spr.h>
 #include <powerpc/oea/sr_601.h>
@@ -3416,7 +3417,7 @@
                      :: "r"((uintptr_t)pmap_pteg_table | (pmap_pteg_mask >> 10)));
 #elif defined (PMAP_OEA64) || defined (PMAP_OEA64_BRIDGE)
        __asm __volatile ("sync; mtsdr1 %0; isync"
-                     :: "r"((uintptr_t)pmap_pteg_table | (32 - cntlzw(pmap_pteg_mask >> 11))));
+                     :: "r"((uintptr_t)pmap_pteg_table | (32 - __builtin_clz(pmap_pteg_mask >> 11))));
 #endif
        tlbia();
 
diff -r bd17c12737e5 -r fede8d27d661 sys/arch/rs6000/rs6000/pic_iocc.c
--- a/sys/arch/rs6000/rs6000/pic_iocc.c Sun Jun 19 07:34:24 2011 +0000
+++ b/sys/arch/rs6000/rs6000/pic_iocc.c Sun Jun 19 07:59:46 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pic_iocc.c,v 1.2 2008/04/28 20:23:34 martin Exp $      */
+/*     $NetBSD: pic_iocc.c,v 1.3 2011/06/19 07:59:46 matt Exp $        */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pic_iocc.c,v 1.2 2008/04/28 20:23:34 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pic_iocc.c,v 1.3 2011/06/19 07:59:46 matt Exp $");
 
 #include <sys/param.h>
 #include <sys/malloc.h>
@@ -93,7 +93,7 @@
         if (rv == 0)
                 return 255;
 
-        irq = 31 - cntlzw(rv);
+        irq = 31 - __builtin_clz(rv);
         if (irq >= 0 && irq < 16)
                 return irq;
         return 255;



Home | Main Index | Thread Index | Old Index