Add weak versions of die, malloc_or_die and some others

The trace-cmd code defines die, malloc_or_die, warning and
big_endian. There are currently used by pevent code. This patch adds
them to the tracecmd library as weak functions.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
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 @@
 
 #define PLUGIN_DIR ".trace-cmd/plugins"
 
+#define __weak __attribute__((weak))
+
+void __weak die(char *fmt, ...)
+{
+	va_list ap;
+	int ret = errno;
+
+	if (errno)
+		perror("trace-cmd");
+	else
+		ret = -1;
+
+	va_start(ap, fmt);
+	fprintf(stderr, "  ");
+	vfprintf(stderr, fmt, ap);
+	va_end(ap);
+
+	fprintf(stderr, "\n");
+	exit(ret);
+}
+
+void __weak warning(char *fmt, ...)
+{
+	va_list ap;
+
+	if (errno)
+		perror("trace-cmd");
+	errno = 0;
+
+	va_start(ap, fmt);
+	fprintf(stderr, "  ");
+	vfprintf(stderr, fmt, ap);
+	va_end(ap);
+
+	fprintf(stderr, "\n");
+}
+
+void __weak *malloc_or_die(unsigned int size)
+{
+	void *data;
+
+	data = malloc(size);
+	if (!data)
+		die("malloc");
+	return data;
+}
+
+int __weak bigendian(void)
+{
+	unsigned char str[] = { 0x1, 0x2, 0x3, 0x4 };
+	unsigned int *ptr;
+
+	ptr = (unsigned int *)str;
+	return *ptr == 0x01020304;
+}
+
 void parse_cmdlines(char *file, int size __unused)
 {
 	char *comm;