~ubuntu-branches/ubuntu/edgy/sysstat/edgy

« back to all changes in this revision

Viewing changes to common.h

  • Committer: Bazaar Package Importer
  • Author(s): Robert Luberda
  • Date: 2004-06-15 18:47:50 UTC
  • Revision ID: james.westby@ubuntu.com-20040615184750-y9zskvg3k6tf9j15
Tags: upstream-5.0.5
ImportĀ upstreamĀ versionĀ 5.0.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * sysstat: System performance tools for Linux
 
3
 * (C) 1999-2004 by Sebastien Godard (sysstat <at> wanadoo.fr)
 
4
 */
 
5
 
 
6
#ifndef _COMMON_H
 
7
#define _COMMON_H
 
8
 
 
9
#include <time.h>
 
10
 
 
11
#define FALSE   0
 
12
#define TRUE    1
 
13
 
 
14
#define MINIMUM(a,b)    ((a) < (b) ? (a) : (b))
 
15
 
 
16
#define NR_CPUS         1024
 
17
 
 
18
/*
 
19
 * Size of /proc/interrupts line (at NR_CPUS # of cpus)
 
20
 * 4 spaces for interrupt # field ; 11 spaces for each interrupt field.
 
21
 */
 
22
#define INTERRUPTS_LINE (4 + 11 * NR_CPUS)
 
23
 
 
24
/* Keywords */
 
25
#define K_ISO   "ISO"
 
26
#define K_ALL   "ALL"
 
27
 
 
28
/* Files */
 
29
#define STAT            "/proc/stat"
 
30
#define PPARTITIONS     "/proc/partitions"
 
31
#define DISKSTATS       "/proc/diskstats"
 
32
#define INTERRUPTS      "/proc/interrupts"
 
33
#define SYSFS_BLOCK     "/sys/block"
 
34
#define S_STAT          "stat"
 
35
 
 
36
#define MAX_FILE_LEN    256
 
37
#define MAX_PF_NAME     1024
 
38
 
 
39
#define NR_DEV_PREALLOC         4
 
40
#define NR_DISK_PREALLOC        3
 
41
 
 
42
/* Define flags */
 
43
#define F_BOOT_STATS            0x100000
 
44
#define D_PARTITIONS            0x200000
 
45
#define F_HAS_DISKSTATS         0x400000
 
46
#define F_HAS_PPARTITIONS       0x800000
 
47
 
 
48
#define WANT_BOOT_STATS(m)      (((m) & F_BOOT_STATS) == F_BOOT_STATS)
 
49
#define DISPLAY_PARTITIONS(m)   (((m) & D_PARTITIONS) == D_PARTITIONS)
 
50
#define HAS_DISKSTATS(m)        (((m) & F_HAS_DISKSTATS) == F_HAS_DISKSTATS)
 
51
#define HAS_PPARTITIONS(m)      (((m) & F_HAS_PPARTITIONS) == F_HAS_PPARTITIONS)
 
52
 
 
53
 
 
54
#define CNT_DEV         0
 
55
#define CNT_PART        1
 
56
 
 
57
#define S_VALUE(m,n,p)  (((double) ((n) - (m))) / (p) * HZ)
 
58
 
 
59
/* new define to normalize to %; HZ is 1024 on IA64 and % should be normalized to 100 */
 
60
#define SP_VALUE(m,n,p) (((double) ((n) - (m))) / (p) * 100)
 
61
 
 
62
/*
 
63
 * 0: stats at t,
 
64
 * 1: stats at t' (t+T or t-T),
 
65
 * 2: average.
 
66
 */
 
67
#define DIM     3
 
68
 
 
69
/* Environment variable */
 
70
#define TM_FMT_VAR      "S_TIME_FORMAT"
 
71
 
 
72
#define DIGITS          "0123456789"
 
73
 
 
74
#define UTSNAME_LEN     65
 
75
 
 
76
#define NR_DISKS        4
 
77
 
 
78
#define DISP_HDR        1
 
79
 
 
80
/* Functions */
 
81
extern char        *device_name(char *);
 
82
extern unsigned int get_disk_io_nr(void);
 
83
extern int          get_kb_shift(void);
 
84
extern time_t       get_localtime(struct tm *);
 
85
extern int          get_cpu_nr(int *, unsigned int);
 
86
extern int          get_sysfs_dev_nr(int);
 
87
extern int          get_diskstats_dev_nr(int);
 
88
extern int          get_ppartitions_dev_nr(void);
 
89
extern int          get_win_height(void);
 
90
extern void         init_nls(void);
 
91
extern double       ll_s_value(unsigned long long, unsigned long long,
 
92
                               unsigned long long);
 
93
extern double       ll_sp_value(unsigned long long, unsigned long long,
 
94
                                unsigned long long);
 
95
extern void         print_gal_header(struct tm *, char *, char *, char *);
 
96
 
 
97
#endif  /* _COMMON_H */