4 " * bpf-script-example.c\n" 5 " * Test basic LLVM building\n" 7 "#ifndef LINUX_VERSION_CODE\n" 8 "# error Need LINUX_VERSION_CODE\n" 9 "# error Example: for 4.2 kernel, put 'clang-opt=\"-DLINUX_VERSION_CODE=0x40200\" into llvm section of ~/.perfconfig'\n" 12 "#define BPF_MAP_TYPE_ARRAY 2\n" 13 "#define BPF_FUNC_map_lookup_elem 1\n" 14 "#define BPF_FUNC_map_update_elem 2\n" 16 "static void *(*bpf_map_lookup_elem)(void *map, void *key) =\n" 17 " (void *) BPF_FUNC_map_lookup_elem;\n" 18 "static void *(*bpf_map_update_elem)(void *map, void *key, void *value, int flags) =\n" 19 " (void *) BPF_FUNC_map_update_elem;\n" 21 "struct bpf_map_def {\n" 22 " unsigned int type;\n" 23 " unsigned int key_size;\n" 24 " unsigned int value_size;\n" 25 " unsigned int max_entries;\n" 28 "#define SEC(NAME) __attribute__((section(NAME), used))\n" 29 "struct bpf_map_def SEC(\"maps\") flip_table = {\n" 30 " .type = BPF_MAP_TYPE_ARRAY,\n" 31 " .key_size = sizeof(int),\n" 32 " .value_size = sizeof(int),\n" 33 " .max_entries = 1,\n" 36 "SEC(\"func=SyS_epoll_wait\")\n" 37 "int bpf_func__SyS_epoll_wait(void *ctx)\n" 40 " int *flag = bpf_map_lookup_elem(&flip_table, &ind);\n" 44 " /* flip flag and store back */\n" 45 " new_flag = !*flag;\n" 46 " bpf_map_update_elem(&flip_table, &ind, &new_flag, BPF_ANY);\n" 49 "char _license[] SEC(\"license\") = \"GPL\";\n" 50 "int _version SEC(\"version\") = LINUX_VERSION_CODE;\n"
const char test_llvm__bpf_base_prog[]