Annotation of src/usr.bin/top/loadavg.h, Revision 1.1
1.1 ! downsj 1: /* $OpenBSD$ */
! 2:
! 3: /*
! 4: * Top - a top users display for Berkeley Unix
! 5: *
! 6: * Defines required to access load average figures.
! 7: *
! 8: * This include file sets up everything we need to access the load average
! 9: * values in the kernel in a machine independent way. First, it sets the
! 10: * typedef "load_avg" to be either double or long (depending on what is
! 11: * needed), then it defines these macros appropriately:
! 12: *
! 13: * loaddouble(la) - convert load_avg to double.
! 14: * intload(i) - convert integer to load_avg.
! 15: */
! 16:
! 17: /*
! 18: * We assume that if FSCALE is defined, then avenrun and ccpu are type long.
! 19: * If your machine is an exception (mips, perhaps?) then make adjustments
! 20: * here.
! 21: *
! 22: * Defined types: load_avg for load averages, pctcpu for cpu percentages.
! 23: */
! 24: #if defined(mips) && !defined(NetBSD)
! 25: # include <sys/fixpoint.h>
! 26: # if defined(FBITS) && !defined(FSCALE)
! 27: # define FSCALE (1 << FBITS) /* mips */
! 28: # endif
! 29: #endif
! 30:
! 31: #ifdef FSCALE
! 32: # define FIXED_LOADAVG FSCALE
! 33: # define FIXED_PCTCPU FSCALE
! 34: #endif
! 35:
! 36: #ifdef ibm032
! 37: # undef FIXED_LOADAVG
! 38: # undef FIXED_PCTCPU
! 39: # define FIXED_PCTCPU PCT_SCALE
! 40: #endif
! 41:
! 42:
! 43: #ifdef FIXED_PCTCPU
! 44: typedef long pctcpu;
! 45: # define pctdouble(p) ((double)(p) / FIXED_PCTCPU)
! 46: #else
! 47: typedef double pctcpu;
! 48: # define pctdouble(p) (p)
! 49: #endif
! 50:
! 51: #ifdef FIXED_LOADAVG
! 52: typedef long load_avg;
! 53: # define loaddouble(la) ((double)(la) / FIXED_LOADAVG)
! 54: # define intload(i) ((int)((i) * FIXED_LOADAVG))
! 55: #else
! 56: typedef double load_avg;
! 57: # define loaddouble(la) (la)
! 58: # define intload(i) ((double)(i))
! 59: #endif