Annotation of src/usr.bin/top/machine.h, Revision 1.26
1.26 ! kn 1: /* $OpenBSD: machine.h,v 1.25 2018/11/17 23:10:08 cheloha Exp $ */
1.6 deraadt 2:
3: /*
4: * Top users/processes display for Unix
5: * Version 3
6: *
7: * Copyright (c) 1984, 1989, William LeFebvre, Rice University
8: * Copyright (c) 1989, 1990, 1992, William LeFebvre, Northwestern University
9: *
10: * Redistribution and use in source and binary forms, with or without
11: * modification, are permitted provided that the following conditions
12: * are met:
13: * 1. Redistributions of source code must retain the above copyright
14: * notice, this list of conditions and the following disclaimer.
15: * 2. Redistributions in binary form must reproduce the above copyright
16: * notice, this list of conditions and the following disclaimer in the
17: * documentation and/or other materials provided with the distribution.
18: *
19: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22: * IN NO EVENT SHALL THE AUTHOR OR HIS EMPLOYER BE LIABLE FOR ANY DIRECT, INDIRECT,
23: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29: */
1.1 downsj 30:
31: /*
32: * This file defines the interface between top and the machine-dependent
33: * module. It is NOT machine dependent and should not need to be changed
34: * for any specific machine.
35: */
36:
37: /*
38: * the statics struct is filled in by machine_init
39: */
1.7 deraadt 40: struct statics {
41: char **procstate_names;
42: char **cpustate_names;
43: char **memory_names;
44: char **order_names;
1.1 downsj 45: };
46:
47: /*
48: * the system_info struct is filled in by a machine dependent routine.
49: */
50:
1.7 deraadt 51: struct system_info {
52: pid_t last_pid;
53: double load_avg[NUM_AVERAGES];
54: int p_total;
55: int p_active; /* number of procs considered
56: * "active" */
57: int *procstates;
1.13 millert 58: int64_t *cpustates;
1.25 cheloha 59: int *cpuonline;
1.7 deraadt 60: int *memory;
1.1 downsj 61: };
62:
1.7 deraadt 63: /*
64: * cpu_states is an array of percentages * 10. For example, the (integer)
65: * value 105 is 10.5% (or .105).
1.1 downsj 66: */
67:
68: /*
69: * the process_select struct tells get_process_info what processes we
70: * are interested in seeing
71: */
72:
1.7 deraadt 73: struct process_select {
74: int idle; /* show idle processes */
75: int system; /* show system processes */
1.14 tedu 76: int threads; /* show threads */
1.8 millert 77: uid_t uid; /* only this uid (unless uid == -1) */
1.17 brynet 78: uid_t huid; /* hide this uid (unless huid == -1) */
1.12 otto 79: pid_t pid; /* only this pid (unless pid == -1) */
1.7 deraadt 80: char *command;/* only this command (unless == NULL) */
1.1 downsj 81: };
82:
1.2 downsj 83: /* prototypes */
1.7 deraadt 84: extern int display_init(struct statics *);
1.1 downsj 85:
1.2 downsj 86: /* machine.c */
1.7 deraadt 87: extern int machine_init(struct statics *);
1.20 mpi 88: extern char *format_header(char *, int);
1.7 deraadt 89: extern void get_system_info(struct system_info *);
1.26 ! kn 90: extern struct handle
! 91: *get_process_info(struct system_info *, struct process_select *,
1.7 deraadt 92: int (*) (const void *, const void *));
1.26 ! kn 93: extern char *format_next_process(struct handle *,
! 94: const char *(*)(uid_t, int), pid_t *, int);
1.8 millert 95: extern uid_t proc_owner(pid_t);
1.12 otto 96:
1.16 guenther 97: extern struct kinfo_proc *getprocs(int, int, int *);
1.18 dlg 98:
99: int getncpu(void);
1.25 cheloha 100: int getncpuonline(void);
1.19 deraadt 101: int getfscale(void);