1613dad49SYonghong Song // SPDX-License-Identifier: GPL-2.0
2613dad49SYonghong Song 
3613dad49SYonghong Song #include <linux/bpf.h>
4613dad49SYonghong Song #include <bpf/bpf_helpers.h>
5613dad49SYonghong Song #include "bpf_misc.h"
6613dad49SYonghong Song 
7*0209fd51SPu Lehui #if (defined(__TARGET_ARCH_arm64) || defined(__TARGET_ARCH_x86) || \
8*0209fd51SPu Lehui      (defined(__TARGET_ARCH_riscv) && __riscv_xlen == 64)) && __clang_major__ >= 18
9613dad49SYonghong Song 
10613dad49SYonghong Song SEC("socket")
11613dad49SYonghong Song __description("gotol, small_imm")
12613dad49SYonghong Song __success __success_unpriv __retval(1)
gotol_small_imm(void)13613dad49SYonghong Song __naked void gotol_small_imm(void)
14613dad49SYonghong Song {
15613dad49SYonghong Song 	asm volatile ("					\
16613dad49SYonghong Song 	call %[bpf_ktime_get_ns];			\
17613dad49SYonghong Song 	if r0 == 0 goto l0_%=;				\
18613dad49SYonghong Song 	gotol l1_%=;					\
19613dad49SYonghong Song l2_%=:							\
20613dad49SYonghong Song 	gotol l3_%=;					\
21613dad49SYonghong Song l1_%=:							\
22613dad49SYonghong Song 	r0 = 1;						\
23613dad49SYonghong Song 	gotol l2_%=;					\
24613dad49SYonghong Song l0_%=:							\
25613dad49SYonghong Song 	r0 = 2;						\
26613dad49SYonghong Song l3_%=:							\
27613dad49SYonghong Song 	exit;						\
28613dad49SYonghong Song "	:
29613dad49SYonghong Song 	: __imm(bpf_ktime_get_ns)
30613dad49SYonghong Song 	: __clobber_all);
31613dad49SYonghong Song }
32613dad49SYonghong Song 
33613dad49SYonghong Song #else
34613dad49SYonghong Song 
35613dad49SYonghong Song SEC("socket")
36613dad49SYonghong Song __description("cpuv4 is not supported by compiler or jit, use a dummy test")
37613dad49SYonghong Song __success
dummy_test(void)38613dad49SYonghong Song int dummy_test(void)
39613dad49SYonghong Song {
40613dad49SYonghong Song 	return 0;
41613dad49SYonghong Song }
42613dad49SYonghong Song 
43613dad49SYonghong Song #endif
44613dad49SYonghong Song 
45613dad49SYonghong Song char _license[] SEC("license") = "GPL";
46