Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | |
| 3 | #include <bpf.h> |
| 4 | |
| 5 | struct bpf_map SEC("maps") __bpf_stdout__ = { |
| 6 | .type = BPF_MAP_TYPE_PERF_EVENT_ARRAY, |
| 7 | .key_size = sizeof(int), |
| 8 | .value_size = sizeof(u32), |
| 9 | .max_entries = __NR_CPUS__, |
| 10 | }; |
| 11 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 12 | #define puts(from) \ |
| 13 | ({ const int __len = sizeof(from); \ |
| 14 | char __from[__len] = from; \ |
| 15 | perf_event_output(args, &__bpf_stdout__, BPF_F_CURRENT_CPU, \ |
| 16 | &__from, __len & (sizeof(from) - 1)); }) |