#include "intel_aub.h"
#include "aub_write.h"
+#include "c11/threads.h"
#include "dev/intel_debug.h"
#include "dev/intel_device_info.h"
#include "common/intel_gem.h"
output_filename, device, devinfo.ver);
}
-__attribute__ ((visibility ("default"))) int
-ioctl(int fd, unsigned long request, ...)
+static int
+intercept_ioctl(int fd, unsigned long request, ...)
{
va_list args;
void *argp;
}
}
+__attribute__ ((visibility ("default"))) int
+ioctl(int fd, unsigned long request, ...)
+{
+ static thread_local bool entered = false;
+ va_list args;
+ void *argp;
+ int ret;
+
+ va_start(args, request);
+ argp = va_arg(args, void *);
+ va_end(args);
+
+ /* Some of the functions called by intercept_ioctl call ioctls of their
+ * own. These need to go to the libc ioctl instead of being passed back to
+ * intercept_ioctl to avoid a stack overflow. */
+ if (entered) {
+ return libc_ioctl(fd, request, argp);
+ } else {
+ entered = true;
+ ret = intercept_ioctl(fd, request, argp);
+ entered = false;
+ return ret;
+ }
+}
+
static void
init(void)
{