stdio.h 582 B

12345678910111213141516171819
  1. // SPDX-License-Identifier: GPL-2.0
  2. #include <bpf.h>
  3. struct bpf_map SEC("maps") __bpf_stdout__ = {
  4. .type = BPF_MAP_TYPE_PERF_EVENT_ARRAY,
  5. .key_size = sizeof(int),
  6. .value_size = sizeof(u32),
  7. .max_entries = __NR_CPUS__,
  8. };
  9. static int (*perf_event_output)(void *, struct bpf_map *, int, void *, unsigned long) =
  10. (void *)BPF_FUNC_perf_event_output;
  11. #define puts(from) \
  12. ({ const int __len = sizeof(from); \
  13. char __from[__len] = from; \
  14. perf_event_output(args, &__bpf_stdout__, BPF_F_CURRENT_CPU, \
  15. &__from, __len & (sizeof(from) - 1)); })