[PATCH] dvb: saa7134-dvb must select tda1004x
[linux-ginger.git] / include / linux / acct.h
blob1993a36917688effd6623dd4756e5b059d04b565
1 /*
2 * BSD Process Accounting for Linux - Definitions
4 * Author: Marco van Wieringen (mvw@planets.elm.net)
6 * This header file contains the definitions needed to implement
7 * BSD-style process accounting. The kernel accounting code and all
8 * user-level programs that try to do something useful with the
9 * process accounting log must include this file.
11 * Copyright (C) 1995 - 1997 Marco van Wieringen - ELM Consultancy B.V.
15 #ifndef _LINUX_ACCT_H
16 #define _LINUX_ACCT_H
18 #include <linux/types.h>
19 #include <asm/param.h>
20 #include <asm/byteorder.h>
22 /*
23 * comp_t is a 16-bit "floating" point number with a 3-bit base 8
24 * exponent and a 13-bit fraction.
25 * comp2_t is 24-bit with 5-bit base 2 exponent and 20 bit fraction
26 * (leading 1 not stored).
27 * See linux/kernel/acct.c for the specific encoding systems used.
30 typedef __u16 comp_t;
31 typedef __u32 comp2_t;
34 * accounting file record
36 * This structure contains all of the information written out to the
37 * process accounting file whenever a process exits.
40 #define ACCT_COMM 16
42 struct acct
44 char ac_flag; /* Flags */
45 char ac_version; /* Always set to ACCT_VERSION */
46 /* for binary compatibility back until 2.0 */
47 __u16 ac_uid16; /* LSB of Real User ID */
48 __u16 ac_gid16; /* LSB of Real Group ID */
49 __u16 ac_tty; /* Control Terminal */
50 __u32 ac_btime; /* Process Creation Time */
51 comp_t ac_utime; /* User Time */
52 comp_t ac_stime; /* System Time */
53 comp_t ac_etime; /* Elapsed Time */
54 comp_t ac_mem; /* Average Memory Usage */
55 comp_t ac_io; /* Chars Transferred */
56 comp_t ac_rw; /* Blocks Read or Written */
57 comp_t ac_minflt; /* Minor Pagefaults */
58 comp_t ac_majflt; /* Major Pagefaults */
59 comp_t ac_swaps; /* Number of Swaps */
60 /* m68k had no padding here. */
61 #if !defined(CONFIG_M68K) || !defined(__KERNEL__)
62 __u16 ac_ahz; /* AHZ */
63 #endif
64 __u32 ac_exitcode; /* Exitcode */
65 char ac_comm[ACCT_COMM + 1]; /* Command Name */
66 __u8 ac_etime_hi; /* Elapsed Time MSB */
67 __u16 ac_etime_lo; /* Elapsed Time LSB */
68 __u32 ac_uid; /* Real User ID */
69 __u32 ac_gid; /* Real Group ID */
72 struct acct_v3
74 char ac_flag; /* Flags */
75 char ac_version; /* Always set to ACCT_VERSION */
76 __u16 ac_tty; /* Control Terminal */
77 __u32 ac_exitcode; /* Exitcode */
78 __u32 ac_uid; /* Real User ID */
79 __u32 ac_gid; /* Real Group ID */
80 __u32 ac_pid; /* Process ID */
81 __u32 ac_ppid; /* Parent Process ID */
82 __u32 ac_btime; /* Process Creation Time */
83 #ifdef __KERNEL__
84 __u32 ac_etime; /* Elapsed Time */
85 #else
86 float ac_etime; /* Elapsed Time */
87 #endif
88 comp_t ac_utime; /* User Time */
89 comp_t ac_stime; /* System Time */
90 comp_t ac_mem; /* Average Memory Usage */
91 comp_t ac_io; /* Chars Transferred */
92 comp_t ac_rw; /* Blocks Read or Written */
93 comp_t ac_minflt; /* Minor Pagefaults */
94 comp_t ac_majflt; /* Major Pagefaults */
95 comp_t ac_swaps; /* Number of Swaps */
96 char ac_comm[ACCT_COMM]; /* Command Name */
100 * accounting flags
102 /* bit set when the process ... */
103 #define AFORK 0x01 /* ... executed fork, but did not exec */
104 #define ASU 0x02 /* ... used super-user privileges */
105 #define ACOMPAT 0x04 /* ... used compatibility mode (VAX only not used) */
106 #define ACORE 0x08 /* ... dumped core */
107 #define AXSIG 0x10 /* ... was killed by a signal */
109 #ifdef __BIG_ENDIAN
110 #define ACCT_BYTEORDER 0x80 /* accounting file is big endian */
111 #else
112 #define ACCT_BYTEORDER 0x00 /* accounting file is little endian */
113 #endif
115 #ifdef __KERNEL__
117 #include <linux/config.h>
119 #ifdef CONFIG_BSD_PROCESS_ACCT
120 struct super_block;
121 extern void acct_auto_close(struct super_block *sb);
122 extern void acct_process(long exitcode);
123 extern void acct_update_integrals(struct task_struct *tsk);
124 extern void acct_clear_integrals(struct task_struct *tsk);
125 #else
126 #define acct_auto_close(x) do { } while (0)
127 #define acct_process(x) do { } while (0)
128 #define acct_update_integrals(x) do { } while (0)
129 #define acct_clear_integrals(task) do { } while (0)
130 #endif
133 * ACCT_VERSION numbers as yet defined:
134 * 0: old format (until 2.6.7) with 16 bit uid/gid
135 * 1: extended variant (binary compatible on M68K)
136 * 2: extended variant (binary compatible on everything except M68K)
137 * 3: new binary incompatible format (64 bytes)
138 * 4: new binary incompatible format (128 bytes)
139 * 5: new binary incompatible format (128 bytes, second half)
143 #ifdef CONFIG_BSD_PROCESS_ACCT_V3
144 #define ACCT_VERSION 3
145 #define AHZ 100
146 typedef struct acct_v3 acct_t;
147 #else
148 #ifdef CONFIG_M68K
149 #define ACCT_VERSION 1
150 #else
151 #define ACCT_VERSION 2
152 #endif
153 #define AHZ (USER_HZ)
154 typedef struct acct acct_t;
155 #endif
157 #else
158 #define ACCT_VERSION 2
159 #define AHZ (HZ)
160 #endif /* __KERNEL */
162 #ifdef __KERNEL__
164 * Yet another set of HZ to *HZ helper functions.
165 * See <linux/times.h> for the original.
168 static inline u32 jiffies_to_AHZ(unsigned long x)
170 #if (TICK_NSEC % (NSEC_PER_SEC / AHZ)) == 0
171 return x / (HZ / USER_HZ);
172 #else
173 u64 tmp = (u64)x * TICK_NSEC;
174 do_div(tmp, (NSEC_PER_SEC / AHZ));
175 return (long)tmp;
176 #endif
179 static inline u64 nsec_to_AHZ(u64 x)
181 #if (NSEC_PER_SEC % AHZ) == 0
182 do_div(x, (NSEC_PER_SEC / AHZ));
183 #elif (AHZ % 512) == 0
184 x *= AHZ/512;
185 do_div(x, (NSEC_PER_SEC / 512));
186 #else
188 * max relative error 5.7e-8 (1.8s per year) for AHZ <= 1024,
189 * overflow after 64.99 years.
190 * exact for AHZ=60, 72, 90, 120, 144, 180, 300, 600, 900, ...
192 x *= 9;
193 do_div(x, (unsigned long)((9ull * NSEC_PER_SEC + (AHZ/2))
194 / AHZ));
195 #endif
196 return x;
199 #endif /* __KERNEL */
201 #endif /* _LINUX_ACCT_H */