Commit 31811f4b authored by Lyude Paul's avatar Lyude Paul

igt_core: add igt_constructor

This is a simple macro for executing a block of code at the beginning of
intel-gpu-tools, before any tests have been ran. Useful for
initialization of global resources used in IGT libraries.
Signed-off-by: Lyude Paul's avatarLyude <>
Reviewed-by: Chris Wilson's avatarChris Wilson <>

Changes since v1:
 - Add the line number into the name of the constructor function so that
   multiple constructors may be used per-file.
parent c7c581a6
......@@ -65,6 +65,7 @@ AC_CHECK_TYPES([sighandler_t],[],[],[AC_INCLUDES_DEFAULT
#include <signal.h>])
dnl Check for POSIX timers
AC_CHECK_FUNCS(timer_create, [], [
......@@ -281,6 +281,19 @@ void igt_simple_init_parse_opts(int *argc, char **argv,
} \
static void igt_tokencat(__real_main, __LINE__)(void) \
* igt_constructor:
* Convenience macro to run the provided code block when igt first starts,
* before any tests have been run. This should be used for parts of the igt
* library that require initialization of objects with global context.
* This code block will be executed exactly once.
#define igt_constructor \
__attribute__((constructor)) \
static void igt_tokencat(__igt_constructor_l, __LINE__)(void)
__attribute__((format(printf, 1, 2)))
void igt_skip(const char *f, ...) __attribute__((noreturn));
__attribute__((format(printf, 5, 6)))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment