xref: /openbmc/linux/tools/perf/util/usage.c (revision 215a0d30)
1b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
286470930SIngo Molnar /*
35f9273d6SNamhyung Kim  * usage.c
45f9273d6SNamhyung Kim  *
55f9273d6SNamhyung Kim  * Various reporting routines.
65f9273d6SNamhyung Kim  * Originally copied from GIT source.
786470930SIngo Molnar  *
886470930SIngo Molnar  * Copyright (C) Linus Torvalds, 2005
986470930SIngo Molnar  */
1086470930SIngo Molnar #include "util.h"
110d37aa34SArnaldo Carvalho de Melo #include "debug.h"
12215a0d30SArnaldo Carvalho de Melo #include <stdio.h>
13215a0d30SArnaldo Carvalho de Melo #include <stdlib.h>
14215a0d30SArnaldo Carvalho de Melo #include <linux/compiler.h>
1586470930SIngo Molnar 
166c346643SArnaldo Carvalho de Melo static __noreturn void usage_builtin(const char *err)
1786470930SIngo Molnar {
18716c69feSIngo Molnar 	fprintf(stderr, "\n Usage: %s\n", err);
1986470930SIngo Molnar 	exit(129);
2086470930SIngo Molnar }
2186470930SIngo Molnar 
2286470930SIngo Molnar /* If we are in a dlopen()ed .so write to a global variable would segfault
2386470930SIngo Molnar  * (ugh), so keep things static. */
246c346643SArnaldo Carvalho de Melo static void (*usage_routine)(const char *err) __noreturn = usage_builtin;
252690c730SNamhyung Kim 
2686470930SIngo Molnar void usage(const char *err)
2786470930SIngo Molnar {
2886470930SIngo Molnar 	usage_routine(err);
2986470930SIngo Molnar }
30