Sun Feb 25 22:36:10 1996 David Mosberger-Tang <davidm@azstarnet.com>
authorroland <roland>
Tue, 19 Mar 1996 20:08:45 +0000 (20:08 +0000)
committerroland <roland>
Tue, 19 Mar 1996 20:08:45 +0000 (20:08 +0000)
* gmon/mcount.c: Avoid integer division.

gmon/mcount.c

index ea60afc..4d3097f 100644 (file)
@@ -34,6 +34,7 @@
 #if !defined(lint) && !defined(KERNEL) && defined(LIBC_SCCS)
 static char sccsid[] = "@(#)mcount.c   8.1 (Berkeley) 6/4/93";
 #endif
+       int i;
 
 #include <sys/param.h>
 #include <sys/gmon.h>
@@ -67,6 +68,7 @@ _MCOUNT_DECL(frompc, selfpc)  /* _mcount; may be static, inline, etc */
 #ifdef KERNEL
        register int s;
 #endif
+       int i;
 
        p = &_gmonparam;
        /*
@@ -89,7 +91,13 @@ _MCOUNT_DECL(frompc, selfpc) /* _mcount; may be static, inline, etc */
        if (frompc > p->textsize)
                goto done;
 
-       frompcindex = &p->froms[frompc / (p->hashfraction * sizeof(*p->froms))];
+       /* avoid integer divide if possible: */
+       if (p->log_hashfraction >= 0) {
+           i = frompc >> p->log_hashfraction;
+       } else {
+           i = frompc / (p->hashfraction * sizeof(*p->froms));
+       }
+       frompcindex = &p->froms[i];
        toindex = *frompcindex;
        if (toindex == 0) {
                /*