Commit | Line | Data |
---|---|---|
fd57c467 KB |
1 | /*- |
2 | * Copyright (c) 1990 The Regents of the University of California. | |
3 | * All rights reserved. | |
4 | * | |
5 | * %sccs.include.redist.c% | |
6 | */ | |
7 | ||
8 | #ifndef lint | |
9 | static char sccsid[] = "@(#)nlist.c 5.1 (Berkeley) %G%"; | |
10 | #endif /* not lint */ | |
11 | ||
12 | #include <sys/types.h> | |
13 | #include <nlist.h> | |
14 | #include <errno.h> | |
15 | #include <stdio.h> | |
16 | ||
17 | struct nlist psnl[] = { | |
18 | {"_ecmx"}, | |
19 | #define X_ECMX 0 | |
20 | {"_fscale"}, | |
21 | #define X_FSCALE 1 | |
22 | {"_ccpu"}, | |
23 | #define X_CCPU 2 | |
24 | {NULL} | |
25 | }; | |
26 | ||
27 | fixpt_t ccpu; /* kernel _ccpu variable */ | |
28 | int nlistread; /* if nlist already read. */ | |
29 | int ecmx; /* kernel _ecmx variable */ | |
30 | int fscale; /* kernel _fscale variable */ | |
31 | ||
32 | #define kread(x, v) \ | |
33 | kvm_read(psnl[x].n_value, (char *)&v, sizeof v) != sizeof(v) | |
34 | ||
35 | donlist() | |
36 | { | |
37 | extern int eval; | |
38 | int rval; | |
39 | ||
40 | rval = 0; | |
41 | nlistread = 1; | |
42 | if (kvm_nlist(psnl)) { | |
43 | (void)fprintf(stderr, "ps: kvm_nlist: %s\n", strerror(errno)); | |
44 | eval = 1; | |
45 | return(1); | |
46 | } | |
47 | if (kread(X_FSCALE, fscale)) { | |
48 | (void)fprintf(stderr, "ps: fscale: %s\n", kvm_geterr()); | |
49 | eval = rval = 1; | |
50 | } | |
51 | if (kread(X_ECMX, ecmx)) { | |
52 | (void)fprintf(stderr, "ps: ecmx: %s\n", kvm_geterr()); | |
53 | eval = rval = 1; | |
54 | } | |
55 | if (kread(X_CCPU, ccpu)) { | |
56 | (void)fprintf(stderr, "ps: ccpu: %s\n", kvm_geterr()); | |
57 | eval = rval = 1; | |
58 | } | |
59 | return(rval); | |
60 | } | |
61 |