1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * Copyright (c) 2024 Meta Platforms, Inc. and affiliates. 4 * Copyright (c) 2024 Tejun Heo <tj@kernel.org> 5 * Copyright (c) 2024 David Vernet <dvernet@meta.com> 6 */ 7 #ifndef __SCX_COMPAT_BPF_H 8 #define __SCX_COMPAT_BPF_H 9 10 #define __COMPAT_ENUM_OR_ZERO(__type, __ent) \ 11 ({ \ 12 __type __ret = 0; \ 13 if (bpf_core_enum_value_exists(__type, __ent)) \ 14 __ret = __ent; \ 15 __ret; \ 16 }) 17 18 /* 19 * Define sched_ext_ops. This may be expanded to define multiple variants for 20 * backward compatibility. See compat.h::SCX_OPS_LOAD/ATTACH(). 21 */ 22 #define SCX_OPS_DEFINE(__name, ...) \ 23 SEC(".struct_ops.link") \ 24 struct sched_ext_ops __name = { \ 25 __VA_ARGS__, \ 26 }; 27 28 #endif /* __SCX_COMPAT_BPF_H */ 29