aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--trace-util.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/trace-util.c b/trace-util.c
index 542e712..fbdb071 100644
--- a/trace-util.c
+++ b/trace-util.c
@@ -13,6 +13,62 @@
13 13
14#define PLUGIN_DIR ".trace-cmd/plugins" 14#define PLUGIN_DIR ".trace-cmd/plugins"
15 15
16#define __weak __attribute__((weak))
17
18void __weak die(char *fmt, ...)
19{
20 va_list ap;
21 int ret = errno;
22
23 if (errno)
24 perror("trace-cmd");
25 else
26 ret = -1;
27
28 va_start(ap, fmt);
29 fprintf(stderr, " ");
30 vfprintf(stderr, fmt, ap);
31 va_end(ap);
32
33 fprintf(stderr, "\n");
34 exit(ret);
35}
36
37void __weak warning(char *fmt, ...)
38{
39 va_list ap;
40
41 if (errno)
42 perror("trace-cmd");
43 errno = 0;
44
45 va_start(ap, fmt);
46 fprintf(stderr, " ");
47 vfprintf(stderr, fmt, ap);
48 va_end(ap);
49
50 fprintf(stderr, "\n");
51}
52
53void __weak *malloc_or_die(unsigned int size)
54{
55 void *data;
56
57 data = malloc(size);
58 if (!data)
59 die("malloc");
60 return data;
61}
62
63int __weak bigendian(void)
64{
65 unsigned char str[] = { 0x1, 0x2, 0x3, 0x4 };
66 unsigned int *ptr;
67
68 ptr = (unsigned int *)str;
69 return *ptr == 0x01020304;
70}
71
16void parse_cmdlines(char *file, int size __unused) 72void parse_cmdlines(char *file, int size __unused)
17{ 73{
18 char *comm; 74 char *comm;