File: procinfo.h

package info (click to toggle)
procinfo 18-1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 188 kB
  • ctags: 134
  • sloc: ansic: 1,226; sh: 419; perl: 81; makefile: 68
file content (120 lines) | stat: -rw-r--r-- 2,580 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*

  procinfo.h

  Date:        1995-04-15 23:54:06
  Last Change: 2001-02-24 23:43:08

  Copyright (C) 1995-2001 Sander van Malssen <svm@kozmix.cistron.nl>

  This software is released under the GNU Public Licence. See the file
  `COPYING' for details. Since you're probably running Linux I'm sure
  your hard disk is already infested with copies of this file, but if
  not, mail me and I'll send you one.

  $Id: procinfo.h,v 1.25 2001/02/24 23:30:35 svm Exp svm $

*/

#ifndef _PROCINFO_H
#define _PROCINFO_H

#define VERSION		"18 (2001-03-02)"

#ifndef PROC_DIR
#define PROC_DIR	"/proc/"	/* Needs the trailing slash. */
#endif

#define ISSTR(s)	(!strcmp(s, type))

#if 0
#define VAL		(strtoul(strtok(NULL, "\t "), NULL, 10))
#else
static inline unsigned long find_val(void)
{
    char *cp;

    cp = strtok(NULL, "\t ");
    if (!cp)
	return 0L;
    return (strtoul (cp, NULL, 10));
}
#define VAL	find_val()
#endif

#define DIFF(x)		(show_diff ? \
			 (unsigned long) (((new.x)-(old.x))/rate) : \
			  new.x)

#define bDIFF(x)	(show_diff ? \
			 (unsigned long) (((new.x)-(old.x))/rate) : \
		 	 (show_from_baseline ? \
			  new.x - base.x : new.x))

#define COPYINFO(to,from)	{ \
    unsigned long *foo; \
    foo = to.intr; \
    memcpy (&to, &from, sizeof (struct info)); \
    to.intr = foo; \
    memcpy (to.intr, from.intr, nr_irqs * sizeof (unsigned long)); \
}



#define IS_ODD(x)	(x & 1)

#undef  MAX
#define MAX(a,b)	((a) > (b) ? (a) : (b))

#define CDRV		0
#define BDRV		1
#ifndef MAX_CHRDEV
#define MAX_CHRDEV	32
#endif
#ifndef MAX_BLKDEV
#define MAX_BLKDEV	32
#endif
#define MAX_DEV		MAX(MAX_CHRDEV, MAX_BLKDEV)

struct info
{
    unsigned long uptime;
    long m_to, m_us, m_fr, m_sh, m_bu, m_ca;
    long s_to, s_us, s_fr;
    unsigned long cpu_user, cpu_nice, cpu_sys, cpu_idle;
    unsigned long disk[5];
    unsigned long disk_r[5];
    unsigned long disk_w[5];
    unsigned long pgin, pgout, swin, swout;
    unsigned long *intr;	/* Phew. That's better. */
    unsigned long old_intr;
    unsigned long ctxt;
    unsigned long syscalls;
};

/* Prototypes. */

void window_init (void);
void tstp (int i);
void cont (int i);
void winsz (int i);
void quit (int i);
void set_echo (int i);

void fatal (const char *s,...);
void *my_xcalloc (size_t n, size_t s);
void init_terminal_data (void);
char *my_tgets (char *te);

char *make_version (FILE *verionfp);
FILE *myfopen (char *name);
char *hms (unsigned long t);
char *perc (unsigned long i, unsigned long t, int cpus);

#endif /* _PROCINFO_H */

/*
   Local variables:
   rm-trailing-spaces: t
   End:
 */