]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.bin/top/machine.h
Merge llvm-project main llvmorg-18-init-18359-g93248729cfae
[FreeBSD/FreeBSD.git] / usr.bin / top / machine.h
1 /*
2  */
3
4 /*
5  *  This file defines the interface between top and the machine-dependent
6  *  module.  It is NOT machine dependent and should not need to be changed
7  *  for any specific machine.
8  */
9 #ifndef MACHINE_H
10 #define MACHINE_H
11
12 #include <sys/time.h>
13 #include <sys/types.h>
14
15 #define NUM_AVERAGES    3
16
17 /* Log base 2 of 1024 is 10 (2^10 == 1024) */
18 #define LOG1024         10
19
20 /*
21  * the statics struct is filled in by machine_init
22  */
23 struct statics
24 {
25     const char * const *procstate_names;
26     const char * const *cpustate_names;
27     const char * const *memory_names;
28     const char * const *arc_names;
29     const char * const *carc_names;
30     const char * const *swap_names;
31     const char * const *order_names;
32     int nbatteries;
33     int ncpus;
34 };
35
36 /*
37  * the system_info struct is filled in by a machine dependent routine.
38  */
39
40 struct system_info
41 {
42     int    last_pid;
43     double load_avg[NUM_AVERAGES];
44     int    p_total;
45     int    p_pactive;     /* number of procs considered "active" */
46     int    *procstates;
47     int    *cpustates;
48     int    *memory;
49     int    *arc;
50     int    *carc;
51     int    *swap;
52     struct timeval boottime;
53     int    battery;
54     int    ncpus;
55 };
56
57 /*
58  * the process_select struct tells get_process_info what processes
59  * and information we are interested in seeing
60  */
61
62 struct process_select
63 {
64     bool idle;          /* show idle processes */
65     bool self;          /* show self */
66     bool system;                /* show system processes */
67     bool thread;                /* show threads */
68     bool thread_id;             /* show thread ids */
69 #define TOP_MAX_UIDS 8
70     int uid[TOP_MAX_UIDS];      /* only these uids (unless uid[0] == -1) */
71     bool wcpu;          /* show weighted cpu */
72     int jid;            /* only this jid (unless jid == -1) */
73     bool jail;          /* show jail ID */
74     bool swap;          /* show swap usage */
75     bool kidle;         /* show per-CPU idle threads */
76     int pid;            /* only this pid (unless pid == -1) */
77     char *command;      /* only this command (unless == NULL) */
78 };
79
80 /* routines defined by the machine dependent module */
81
82 struct handle;
83
84 char    *format_header(const char *uname_field);
85 char    *format_next_process(struct handle* handle, char *(*get_userid)(int),
86             int flags);
87 void     toggle_pcpustats(void);
88 void     get_system_info(struct system_info *si);
89 int      machine_init(struct statics *statics);
90
91 /* non-int routines typically used by the machine dependent module */
92 extern struct process_select ps;
93
94 void *
95 get_process_info(struct system_info *si, struct process_select *sel,
96     int (*compare)(const void *, const void *));
97
98 #endif /* MACHINE_H */