github.com/cilium/ebpf@v0.15.1-0.20240517100537-8079b37aa138/testdata/kconfig_config.c (about)

     1  #include "common.h"
     2  
     3  char __license[] __section("license") = "GPL-2.0";
     4  
     5  extern int CONFIG_HZ __kconfig;
     6  
     7  struct {
     8  	__uint(type, BPF_MAP_TYPE_ARRAY);
     9  	__uint(max_entries, 1);
    10  	__type(key, uint32_t);
    11  	__type(value, uint64_t);
    12  } array_map __section(".maps");
    13  
    14  static long (*bpf_map_update_elem)(void *map, const void *key, const void *value, uint64_t flags) = (void *)2;
    15  
    16  __section("socket") int kconfig() {
    17  	uint32_t i;
    18  	uint64_t val;
    19  
    20  	i   = 0;
    21  	val = CONFIG_HZ;
    22  	bpf_map_update_elem(&array_map, &i, &val, 0);
    23  
    24  	return 0;
    25  }