staging: rtl8192u: remove redundant assignment to pointer crypt
[linux/fpc-iii.git] / tools / testing / selftests / bpf / bpf_util.h
blobec219f84e0415715c0d572e209f39f706587d0b5
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __BPF_UTIL__
3 #define __BPF_UTIL__
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <string.h>
8 #include <errno.h>
9 #include <libbpf.h> /* libbpf_num_possible_cpus */
11 static inline unsigned int bpf_num_possible_cpus(void)
13 int possible_cpus = libbpf_num_possible_cpus();
15 if (possible_cpus < 0) {
16 printf("Failed to get # of possible cpus: '%s'!\n",
17 strerror(-possible_cpus));
18 exit(1);
20 return possible_cpus;
23 #define __bpf_percpu_val_align __attribute__((__aligned__(8)))
25 #define BPF_DECLARE_PERCPU(type, name) \
26 struct { type v; /* padding */ } __bpf_percpu_val_align \
27 name[bpf_num_possible_cpus()]
28 #define bpf_percpu(name, cpu) name[(cpu)].v
30 #ifndef ARRAY_SIZE
31 # define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
32 #endif
34 #ifndef sizeof_field
35 #define sizeof_field(TYPE, MEMBER) sizeof((((TYPE *)0)->MEMBER))
36 #endif
38 #ifndef offsetofend
39 #define offsetofend(TYPE, MEMBER) \
40 (offsetof(TYPE, MEMBER) + sizeof_field(TYPE, MEMBER))
41 #endif
43 #endif /* __BPF_UTIL__ */