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