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