summaryrefslogtreecommitdiff
path: root/tools/aubdump.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/aubdump.c')
-rw-r--r--tools/aubdump.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/tools/aubdump.c b/tools/aubdump.c
index 6327b87e..01ecf0c5 100644
--- a/tools/aubdump.c
+++ b/tools/aubdump.c
@@ -43,8 +43,11 @@
#include "intel_aub.h"
#include "intel_chipset.h"
-static int (*libc_close)(int fd);
-static int (*libc_ioctl)(int fd, unsigned long request, void *argp);
+static int close_init_helper(int fd);
+static int ioctl_init_helper(int fd, unsigned long request, ...);
+
+static int (*libc_close)(int fd) = close_init_helper;
+static int (*libc_ioctl)(int fd, unsigned long request, ...) = ioctl_init_helper;
static int drm_fd = -1;
static char *filename;
@@ -528,7 +531,7 @@ ioctl(int fd, unsigned long request, ...)
}
}
-static void __attribute__ ((constructor))
+static void
init(void)
{
const char *args = getenv("INTEL_AUBDUMP_ARGS");
@@ -553,6 +556,27 @@ init(void)
fail_if(file == NULL, "intel_aubdump: failed to open file '%s'\n", filename);
}
+static int
+close_init_helper(int fd)
+{
+ init();
+ return libc_close(fd);
+}
+
+static int
+ioctl_init_helper(int fd, unsigned long request, ...)
+{
+ va_list args;
+ void *argp;
+
+ va_start(args, request);
+ argp = va_arg(args, void *);
+ va_end(args);
+
+ init();
+ return libc_ioctl(fd, request, argp);
+}
+
static void __attribute__ ((destructor))
fini(void)
{