get rid of roundup of hash bucket hit; add HASHFRACTION
authorKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Fri, 14 Jan 1983 10:59:32 +0000 (02:59 -0800)
committerKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Fri, 14 Jan 1983 10:59:32 +0000 (02:59 -0800)
SCCS-vsn: lib/libc/gmon/gmon.c 4.9

usr/src/lib/libc/gmon/gmon.c

index 2223057..9488c9e 100644 (file)
@@ -1,4 +1,4 @@
-static char *sccsid = "@(#)gmon.c      4.8 (Berkeley) %G%";
+static char *sccsid = "@(#)gmon.c      4.9 (Berkeley) %G%";
 
 #ifdef DEBUG
 #include <stdio.h>
 
 #ifdef DEBUG
 #include <stdio.h>
@@ -48,7 +48,7 @@ monstartup(lowpc, highpc)
        write( 2 , MSG , sizeof(MSG) );
        return;
     }
        write( 2 , MSG , sizeof(MSG) );
        return;
     }
-    froms = (unsigned short *) sbrk( s_textsize );
+    froms = (unsigned short *) sbrk( s_textsize / HASHFRACTION );
     if ( froms == (unsigned short *) -1 ) {
        write( 2 , MSG , sizeof(MSG) );
        froms = 0;
     if ( froms == (unsigned short *) -1 ) {
        write( 2 , MSG , sizeof(MSG) );
        froms = 0;
@@ -82,6 +82,7 @@ _mcleanup()
 {
     int                        fd;
     int                        fromindex;
 {
     int                        fd;
     int                        fromindex;
+    int                        endfrom;
     char               *frompc;
     int                        toindex;
     struct rawarc      rawarc;
     char               *frompc;
     int                        toindex;
     struct rawarc      rawarc;
@@ -95,11 +96,12 @@ _mcleanup()
        fprintf( stderr , "[mcleanup] sbuf 0x%x ssiz %d\n" , sbuf , ssiz );
 #   endif DEBUG
     write( fd , sbuf , ssiz );
        fprintf( stderr , "[mcleanup] sbuf 0x%x ssiz %d\n" , sbuf , ssiz );
 #   endif DEBUG
     write( fd , sbuf , ssiz );
-    for ( fromindex = 0 ; fromindex < s_textsize>>1 ; fromindex++ ) {
+    endfrom = s_textsize / (HASHFRACTION * sizeof(*froms));
+    for ( fromindex = 0 ; fromindex < endfrom ; fromindex++ ) {
        if ( froms[fromindex] == 0 ) {
            continue;
        }
        if ( froms[fromindex] == 0 ) {
            continue;
        }
-       frompc = s_lowpc + (fromindex<<1);
+       frompc = s_lowpc + (fromindex * HASHFRACTION * sizeof(*froms));
        for (toindex=froms[fromindex]; toindex!=0; toindex=tos[toindex].link) {
 #          ifdef DEBUG
                fprintf( stderr ,
        for (toindex=froms[fromindex]; toindex!=0; toindex=tos[toindex].link) {
 #          ifdef DEBUG
                fprintf( stderr ,
@@ -160,7 +162,7 @@ mcount()
                goto done;
        }
        frompcindex =
                goto done;
        }
        frompcindex =
-           &froms[(((long)frompcindex) + sizeof(*froms) - 1) / sizeof(*froms)];
+           &froms[((long)frompcindex) / (HASHFRACTION * sizeof(*froms))];
        toindex = *frompcindex;
        if (toindex == 0) {
                /*
        toindex = *frompcindex;
        if (toindex == 0) {
                /*