brintos

brintos / linux-shallow public Read only

0
0
Text · 749 B · f756176 Raw
47 lines · c
1/* SPDX-License-Identifier: GPL-2.0 */2#include <signal.h>3#include <stdlib.h>4#include <linux/compiler.h>5#include <unistd.h>6#include "../tests.h"7 8/* We want to check these symbols in perf script */9noinline void leaf(volatile int b);10noinline void parent(volatile int b);11 12static volatile int a;13static volatile sig_atomic_t done;14 15static void sighandler(int sig __maybe_unused)16{17	done = 1;18}19 20noinline void leaf(volatile int b)21{22	while (!done)23		a += b;24}25 26noinline void parent(volatile int b)27{28	leaf(b);29}30 31static int leafloop(int argc, const char **argv)32{33	int sec = 1;34 35	if (argc > 0)36		sec = atoi(argv[0]);37 38	signal(SIGINT, sighandler);39	signal(SIGALRM, sighandler);40	alarm(sec);41 42	parent(sec);43	return 0;44}45 46DEFINE_WORKLOAD(leafloop);47