1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#ifndef _LINUX_ACCT_H
16#define _LINUX_ACCT_H
17
18#include <uapi/linux/acct.h>
19
20
21
22#ifdef CONFIG_BSD_PROCESS_ACCT
23struct pid_namespace;
24extern int acct_parm[];
25extern void acct_collect(long exitcode, int group_dead);
26extern void acct_process(void);
27extern void acct_exit_ns(struct pid_namespace *);
28#else
29#define acct_collect(x,y) do { } while (0)
30#define acct_process() do { } while (0)
31#define acct_exit_ns(ns) do { } while (0)
32#endif
33
34
35
36
37
38
39
40
41
42
43
44
45#undef ACCT_VERSION
46#undef AHZ
47
48#ifdef CONFIG_BSD_PROCESS_ACCT_V3
49#define ACCT_VERSION 3
50#define AHZ 100
51typedef struct acct_v3 acct_t;
52#else
53#ifdef CONFIG_M68K
54#define ACCT_VERSION 1
55#else
56#define ACCT_VERSION 2
57#endif
58#define AHZ (USER_HZ)
59typedef struct acct acct_t;
60#endif
61
62#include <linux/jiffies.h>
63
64
65
66
67
68static inline u32 jiffies_to_AHZ(unsigned long x)
69{
70#if (TICK_NSEC % (NSEC_PER_SEC / AHZ)) == 0
71# if HZ < AHZ
72 return x * (AHZ / HZ);
73# else
74 return x / (HZ / AHZ);
75# endif
76#else
77 u64 tmp = (u64)x * TICK_NSEC;
78 do_div(tmp, (NSEC_PER_SEC / AHZ));
79 return (long)tmp;
80#endif
81}
82
83static inline u64 nsec_to_AHZ(u64 x)
84{
85#if (NSEC_PER_SEC % AHZ) == 0
86 do_div(x, (NSEC_PER_SEC / AHZ));
87#elif (AHZ % 512) == 0
88 x *= AHZ/512;
89 do_div(x, (NSEC_PER_SEC / 512));
90#else
91
92
93
94
95
96 x *= 9;
97 do_div(x, (unsigned long)((9ull * NSEC_PER_SEC + (AHZ/2))
98 / AHZ));
99#endif
100 return x;
101}
102
103#endif
104