nlist.c revision 37317
1255570Strasz/*-
2255570Strasz * Copyright (c) 1990, 1993, 1994
3255570Strasz *	The Regents of the University of California.  All rights reserved.
4255570Strasz *
5255570Strasz * Redistribution and use in source and binary forms, with or without
6255570Strasz * modification, are permitted provided that the following conditions
7255570Strasz * are met:
8255570Strasz * 1. Redistributions of source code must retain the above copyright
9255570Strasz *    notice, this list of conditions and the following disclaimer.
10255570Strasz * 2. Redistributions in binary form must reproduce the above copyright
11255570Strasz *    notice, this list of conditions and the following disclaimer in the
12255570Strasz *    documentation and/or other materials provided with the distribution.
13255570Strasz * 3. All advertising materials mentioning features or use of this software
14255570Strasz *    must display the following acknowledgement:
15255570Strasz *	This product includes software developed by the University of
16255570Strasz *	California, Berkeley and its contributors.
17255570Strasz * 4. Neither the name of the University nor the names of its contributors
18255570Strasz *    may be used to endorse or promote products derived from this software
19255570Strasz *    without specific prior written permission.
20255570Strasz *
21255570Strasz * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22255570Strasz * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23255570Strasz * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24255570Strasz * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25255570Strasz * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26255570Strasz * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27255570Strasz * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28255570Strasz * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29255570Strasz * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30255570Strasz * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31255570Strasz * SUCH DAMAGE.
32255570Strasz */
33255570Strasz
34255570Strasz#include <sys/time.h>
35255570Strasz#include <sys/resource.h>
36255570Strasz
37255570Straszfixpt_t	ccpu;				/* kernel _ccpu variable */
38255570Straszint	nlistread;			/* if nlist already read. */
39255570Straszint	mempages;			/* number of pages of phys. memory */
40255570Straszint	fscale;				/* kernel _fscale variable */
41255570Strasz
42255570Straszint
43255570Straszdonlist()
44255570Strasz{
45255570Strasz
46255570Strasz	if (sysctlbyname("kern.ccpu", &ccpu, sizeof ccpu, 0, 0) < 0)
47255570Strasz		return (1);
48255570Strasz	if (sysctlbyname("kern.fscale", &fscale, sizeof fscale, 0, 0) < 0)
49255570Strasz		return (1);
50255570Strasz	if (sysctlbyname("hw.availpages", &mempages, sizeof mempages, 0, 0) < 0)
51255570Strasz		return (1);
52255570Strasz	nlistread = 1;
53255570Strasz	return (0);
54255570Strasz}
55255570Strasz