linux/tools/testing/selftests/bpf/progs/atomic_bounds.c
<<
>>
Prefs
   1// SPDX-License-Identifier: GPL-2.0
   2#include <linux/bpf.h>
   3#include <bpf/bpf_helpers.h>
   4#include <bpf/bpf_tracing.h>
   5#include <stdbool.h>
   6
   7#ifdef ENABLE_ATOMICS_TESTS
   8bool skip_tests __attribute((__section__(".data"))) = false;
   9#else
  10bool skip_tests = true;
  11#endif
  12
  13SEC("fentry/bpf_fentry_test1")
  14int BPF_PROG(sub, int x)
  15{
  16#ifdef ENABLE_ATOMICS_TESTS
  17        int a = 0;
  18        int b = __sync_fetch_and_add(&a, 1);
  19        /* b is certainly 0 here. Can the verifier tell? */
  20        while (b)
  21                continue;
  22#endif
  23        return 0;
  24}
  25