xref: /linux/tools/sched_ext/include/scx/enums.h (revision bc8198dc7ebc492ec3e9fa1617dcdfbe98e73b17)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Define struct scx_enums that stores the load-time values of enums
4  * used by the BPF program.
5  *
6  * Copyright (c) 2024 Meta Platforms, Inc. and affiliates.
7  */
8 
9 #ifndef __SCX_ENUMS_H
10 #define __SCX_ENUMS_H
11 
12 static inline void __ENUM_set(u64 *val, char *type, char *name)
13 {
14 	bool res;
15 
16 	res = __COMPAT_read_enum(type, name, val);
17 	SCX_BUG_ON(!res, "enum not found(%s)", name);
18 }
19 
20 #define SCX_ENUM_SET(skel, type, name) do {			\
21 	__ENUM_set(&skel->rodata->__##name, #type, #name);	\
22 	} while (0)
23 
24 
25 #include "enums.autogen.h"
26 
27 #endif /* __SCX_ENUMS_H */
28