1 /* SPDX-License-Identifier: GPL-2.0 */
6 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
8 #define MB(x) (x << 20)
11 * Checks if two given values differ by less than err% of their sum.
13 static inline int values_close(long a
, long b
, int err
)
15 return abs(a
- b
) <= (a
+ b
) / 100 * err
;
18 extern int cg_find_unified_root(char *root
, size_t len
);
19 extern char *cg_name(const char *root
, const char *name
);
20 extern char *cg_name_indexed(const char *root
, const char *name
, int index
);
21 extern int cg_create(const char *cgroup
);
22 extern int cg_destroy(const char *cgroup
);
23 extern int cg_read(const char *cgroup
, const char *control
,
24 char *buf
, size_t len
);
25 extern int cg_read_strcmp(const char *cgroup
, const char *control
,
26 const char *expected
);
27 extern int cg_read_strstr(const char *cgroup
, const char *control
,
29 extern long cg_read_long(const char *cgroup
, const char *control
);
30 long cg_read_key_long(const char *cgroup
, const char *control
, const char *key
);
31 extern int cg_write(const char *cgroup
, const char *control
, char *buf
);
32 extern int cg_run(const char *cgroup
,
33 int (*fn
)(const char *cgroup
, void *arg
),
35 extern int cg_enter_current(const char *cgroup
);
36 extern int cg_run_nowait(const char *cgroup
,
37 int (*fn
)(const char *cgroup
, void *arg
),
39 extern int get_temp_fd(void);
40 extern int alloc_pagecache(int fd
, size_t size
);
41 extern int alloc_anon(const char *cgroup
, void *arg
);
42 extern int is_swap_enabled(void);