xref: /OK3568_Linux_fs/kernel/samples/bpf/asm_goto_workaround.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun /* Copyright (c) 2019 Facebook */
3*4882a593Smuzhiyun #ifndef __ASM_GOTO_WORKAROUND_H
4*4882a593Smuzhiyun #define __ASM_GOTO_WORKAROUND_H
5*4882a593Smuzhiyun 
6*4882a593Smuzhiyun /*
7*4882a593Smuzhiyun  * This will bring in asm_volatile_goto and asm_inline macro definitions
8*4882a593Smuzhiyun  * if enabled by compiler and config options.
9*4882a593Smuzhiyun  */
10*4882a593Smuzhiyun #include <linux/types.h>
11*4882a593Smuzhiyun 
12*4882a593Smuzhiyun #ifdef asm_volatile_goto
13*4882a593Smuzhiyun #undef asm_volatile_goto
14*4882a593Smuzhiyun #define asm_volatile_goto(x...) asm volatile("invalid use of asm_volatile_goto")
15*4882a593Smuzhiyun #endif
16*4882a593Smuzhiyun 
17*4882a593Smuzhiyun /*
18*4882a593Smuzhiyun  * asm_inline is defined as asm __inline in "include/linux/compiler_types.h"
19*4882a593Smuzhiyun  * if supported by the kernel's CC (i.e CONFIG_CC_HAS_ASM_INLINE) which is not
20*4882a593Smuzhiyun  * supported by CLANG.
21*4882a593Smuzhiyun  */
22*4882a593Smuzhiyun #ifdef asm_inline
23*4882a593Smuzhiyun #undef asm_inline
24*4882a593Smuzhiyun #define asm_inline asm
25*4882a593Smuzhiyun #endif
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun #define volatile(x...) volatile("")
28*4882a593Smuzhiyun #endif
29