Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1// SPDX-License-Identifier: GPL-2.0
2#include <stdint.h>
3#include <time.h>
4
5/*
6 * '18446744073709551615\0'
7 */
8#define BUFF_U64_STR_SIZE 24
9
10#define container_of(ptr, type, member)({ \
11 const typeof(((type *)0)->member) *__mptr = (ptr); \
12 (type *)((char *)__mptr - offsetof(type, member)) ; })
13
14extern int config_debug;
15void debug_msg(const char *fmt, ...);
16void err_msg(const char *fmt, ...);
17
18long parse_seconds_duration(char *val);
19void get_duration(time_t start_time, char *output, int output_size);
20
21int parse_cpu_list(char *cpu_list, char **monitored_cpus);
22long long get_llong_from_str(char *start);
23
24static inline void
25update_min(unsigned long long *a, unsigned long long *b)
26{
27 if (*a > *b)
28 *a = *b;
29}
30
31static inline void
32update_max(unsigned long long *a, unsigned long long *b)
33{
34 if (*a < *b)
35 *a = *b;
36}
37
38static inline void
39update_sum(unsigned long long *a, unsigned long long *b)
40{
41 *a += *b;
42}
43
44struct sched_attr {
45 uint32_t size;
46 uint32_t sched_policy;
47 uint64_t sched_flags;
48 int32_t sched_nice;
49 uint32_t sched_priority;
50 uint64_t sched_runtime;
51 uint64_t sched_deadline;
52 uint64_t sched_period;
53};
54
55int parse_prio(char *arg, struct sched_attr *sched_param);
56int set_comm_sched_attr(const char *comm, struct sched_attr *attr);