9 static inline unsigned int bpf_num_possible_cpus(void)
11 static const char *fcpu = "/sys/devices/system/cpu/possible";
12 unsigned int start, end, possible_cpus = 0;
16 fp = fopen(fcpu, "r");
18 printf("Failed to open %s: '%s'!\n", fcpu, strerror(errno));
22 while (fgets(buff, sizeof(buff), fp)) {
23 if (sscanf(buff, "%u-%u", &start, &end) == 2) {
24 possible_cpus = start == 0 ? end + 1 : 0;
31 printf("Failed to retrieve # possible CPUs!\n");
38 #define __bpf_percpu_val_align __attribute__((__aligned__(8)))
40 #define BPF_DECLARE_PERCPU(type, name) \
41 struct { type v; /* padding */ } __bpf_percpu_val_align \
42 name[bpf_num_possible_cpus()]
43 #define bpf_percpu(name, cpu) name[(cpu)].v
45 #endif /* __BPF_UTIL__ */