1/* 2 * Copyright (c) 1984 through 2008, William LeFebvre 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * 8 * * Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 11 * * Redistributions in binary form must reproduce the above 12 * copyright notice, this list of conditions and the following disclaimer 13 * in the documentation and/or other materials provided with the 14 * distribution. 15 * 16 * * Neither the name of William LeFebvre nor the names of other 17 * contributors may be used to endorse or promote products derived from 18 * this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33/* 34 * Top - a top users display for Berkeley Unix 35 * 36 * Defines required to access load average figures. 37 * 38 * This include file sets up everything we need to access the load average 39 * values in the kernel in a machine independent way. First, it sets the 40 * typedef "load_avg" to be either double or long (depending on what is 41 * needed), then it defines these macros appropriately: 42 * 43 * loaddouble(la) - convert load_avg to double. 44 * intload(i) - convert integer to load_avg. 45 */ 46 47/* 48 * We assume that if FSCALE is defined, then avenrun and ccpu are type long. 49 * If your machine is an exception (mips, perhaps?) then make adjustments 50 * here. 51 * 52 * Defined types: load_avg for load averages, pctcpu for cpu percentages. 53 */ 54#if defined(mips) && !defined(NetBSD) 55# include <sys/fixpoint.h> 56# if defined(FBITS) && !defined(FSCALE) 57# define FSCALE (1 << FBITS) /* mips */ 58# endif 59#endif 60 61#ifdef FSCALE 62# define FIXED_LOADAVG FSCALE 63# define FIXED_PCTCPU FSCALE 64#endif 65 66#ifdef ibm032 67# undef FIXED_LOADAVG 68# undef FIXED_PCTCPU 69# define FIXED_PCTCPU PCT_SCALE 70#endif 71 72 73#ifdef FIXED_PCTCPU 74 typedef long pctcpu; 75# define pctdouble(p) ((double)(p) / FIXED_PCTCPU) 76#else 77typedef double pctcpu; 78# define pctdouble(p) (p) 79#endif 80 81#ifdef FIXED_LOADAVG 82 typedef long load_avg; 83# define loaddouble(la) ((double)(la) / FIXED_LOADAVG) 84# define intload(i) ((int)((i) * FIXED_LOADAVG)) 85#else 86 typedef double load_avg; 87# define loaddouble(la) (la) 88# define intload(i) ((double)(i)) 89#endif 90