set hashfraction; enable getting gmonparam
[unix-history] / usr / src / sys / kern / kern_clock.c
index 38c39e6..9180b4f 100644 (file)
@@ -4,7 +4,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)kern_clock.c        7.27 (Berkeley) %G%
+ *     @(#)kern_clock.c        7.31 (Berkeley) %G%
  */
 
 #include <sys/param.h>
  */
 
 #include <sys/param.h>
@@ -19,7 +19,6 @@
 
 #ifdef GPROF
 #include <sys/gmon.h>
 
 #ifdef GPROF
 #include <sys/gmon.h>
-extern u_short *kcount;
 #endif
 
 #define ADJTIME                /* For now... */
 #endif
 
 #define ADJTIME                /* For now... */
@@ -74,7 +73,7 @@ int   profhz;
 int    profprocs;
 int    ticks;
 static int psdiv, pscnt;       /* prof => stat divider */
 int    profprocs;
 int    ticks;
 static int psdiv, pscnt;       /* prof => stat divider */
-int    psratio;                /* ratio: prot / stat */
+int    psratio;                /* ratio: prof / stat */
 
 volatile struct        timeval time;
 volatile struct        timeval mono_time;
 
 volatile struct        timeval time;
 volatile struct        timeval mono_time;
@@ -385,8 +384,10 @@ statclock(frame)
                g = &_gmonparam;
                if (g->state == GMON_PROF_ON) {
                        i = CLKF_PC(frame) - g->lowpc;
                g = &_gmonparam;
                if (g->state == GMON_PROF_ON) {
                        i = CLKF_PC(frame) - g->lowpc;
-                       if (i < g->textsize)
-                               kcount[i / (HISTFRACTION * sizeof(*kcount))]++;
+                       if (i < g->textsize) {
+                               i /= HISTFRACTION * sizeof(*g->kcount);
+                               g->kcount[i]++;
+                       }
                }
 #endif
                if (--pscnt > 0)
                }
 #endif
                if (--pscnt > 0)
@@ -458,35 +459,18 @@ statclock(frame)
 /*
  * Return information about system clocks.
  */
 /*
  * Return information about system clocks.
  */
-/* ARGSUSED */
-kinfo_clockrate(op, where, acopysize, arg, aneeded)
-       int op;
+sysctl_clockrate(where, sizep)
        register char *where;
        register char *where;
-       int *acopysize, arg, *aneeded;
+       size_t *sizep;
 {
 {
-       int buflen, error;
-       struct clockinfo clockinfo;
+       struct clockinfo clkinfo;
 
 
-       *aneeded = sizeof(clockinfo);
-       if (where == NULL)
-               return (0);
        /*
        /*
-        * Check for enough buffering.
+        * Construct clockinfo structure.
         */
         */
-       buflen = *acopysize;
-       if (buflen < sizeof(clockinfo)) {
-               *acopysize = 0;
-               return (0);
-       }
-       /*
-        * Copyout clockinfo structure.
-        */
-       clockinfo.hz = hz;
-       clockinfo.tick = tick;
-       clockinfo.profhz = profhz;
-       clockinfo.stathz = stathz ? stathz : hz;
-       if (error = copyout((caddr_t)&clockinfo, where, sizeof(clockinfo)))
-               return (error);
-       *acopysize = sizeof(clockinfo);
-       return (0);
+       clkinfo.hz = hz;
+       clkinfo.tick = tick;
+       clkinfo.profhz = profhz;
+       clkinfo.stathz = stathz ? stathz : hz;
+       return (sysctl_rdstruct(where, sizep, NULL, &clkinfo, sizeof(clkinfo)));
 }
 }