1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2022 Meta Platforms, Inc. and affiliates. */
3 
4 #include "vmlinux.h"
5 #include <bpf/bpf_helpers.h>
6 #include <bpf/usdt.bpf.h>
7 
8 /* this file is linked together with test_usdt.c to validate that usdt.bpf.h
9  * can be included in multiple .bpf.c files forming single final BPF object
10  * file
11  */
12 
13 extern int my_pid;
14 
15 int usdt_100_called;
16 int usdt_100_sum;
17 
18 SEC("usdt//proc/self/exe:test:usdt_100")
19 int BPF_USDT(usdt_100, int x)
20 {
21 	long tmp;
22 
23 	if (my_pid != (bpf_get_current_pid_tgid() >> 32))
24 		return 0;
25 
26 	__sync_fetch_and_add(&usdt_100_called, 1);
27 	__sync_fetch_and_add(&usdt_100_sum, x);
28 
29 	return 0;
30 }
31 
32 char _license[] SEC("license") = "GPL";
33