* [PATCH i-g-t v2] igt_core: add igt_constructor
@ 2016-12-21 20:50 Lyude
2016-12-23 13:57 ` Chris Wilson
2017-01-04 17:20 ` Paulo Zanoni
0 siblings, 2 replies; 4+ messages in thread
From: Lyude @ 2016-12-21 20:50 UTC (permalink / raw)
To: intel-gfx; +Cc: Lyude
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 <lyude@redhat.com>
Changes since v1:
- Add the line number into the name of the constructor function so that
multiple constructors may be used per-file.
---
configure.ac | 1 +
lib/igt_core.h | 13 +++++++++++++
2 files changed, 14 insertions(+)
diff --git a/configure.ac b/configure.ac
index fa31a52..411bfab 100644
--- a/configure.ac
+++ b/configure.ac
@@ -65,6 +65,7 @@ AC_CHECK_TYPES([sighandler_t],[],[],[AC_INCLUDES_DEFAULT
#include <signal.h>])
AC_CHECK_FUNCS([swapctl])
AC_CHECK_FUNCS([asprintf])
+AX_GCC_FUNC_ATTRIBUTE([constructor])
dnl Check for POSIX timers
AC_CHECK_FUNCS(timer_create, [], [
diff --git a/lib/igt_core.h b/lib/igt_core.h
index 661a634..b669de3 100644
--- a/lib/igt_core.h
+++ b/lib/igt_core.h
@@ -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)))
--
2.9.3
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH i-g-t v2] igt_core: add igt_constructor
2016-12-21 20:50 [PATCH i-g-t v2] igt_core: add igt_constructor Lyude
@ 2016-12-23 13:57 ` Chris Wilson
2017-01-04 17:20 ` Paulo Zanoni
1 sibling, 0 replies; 4+ messages in thread
From: Chris Wilson @ 2016-12-23 13:57 UTC (permalink / raw)
To: Lyude; +Cc: intel-gfx
On Wed, Dec 21, 2016 at 03:50:18PM -0500, Lyude wrote:
> 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 <lyude@redhat.com>
>
> Changes since v1:
> - Add the line number into the name of the constructor function so that
> multiple constructors may be used per-file.
Works for me,
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH i-g-t v2] igt_core: add igt_constructor
2016-12-21 20:50 [PATCH i-g-t v2] igt_core: add igt_constructor Lyude
2016-12-23 13:57 ` Chris Wilson
@ 2017-01-04 17:20 ` Paulo Zanoni
2017-01-04 17:29 ` Chris Wilson
1 sibling, 1 reply; 4+ messages in thread
From: Paulo Zanoni @ 2017-01-04 17:20 UTC (permalink / raw)
To: Lyude, intel-gfx
Em Qua, 2016-12-21 às 15:50 -0500, Lyude escreveu:
> 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.
IGT doesn't compile anymore here. Reverting this patch fixes it for me.
On a brand new git clone, if I just run autogen.sh, I get this:
./configure: line 6319: syntax error near unexpected token
`constructor'
./configure: line 6319: `AX_GCC_FUNC_ATTRIBUTE(constructor)'
The gcc/autoconf/etc versions are from Fedora 24.
I'm not sure what I'm missing here...
>
> Signed-off-by: Lyude <lyude@redhat.com>
>
> Changes since v1:
> - Add the line number into the name of the constructor function so
> that
> multiple constructors may be used per-file.
> ---
> configure.ac | 1 +
> lib/igt_core.h | 13 +++++++++++++
> 2 files changed, 14 insertions(+)
>
> diff --git a/configure.ac b/configure.ac
> index fa31a52..411bfab 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -65,6 +65,7 @@
> AC_CHECK_TYPES([sighandler_t],[],[],[AC_INCLUDES_DEFAULT
> #include <signal.h>])
> AC_CHECK_FUNCS([swapctl])
> AC_CHECK_FUNCS([asprintf])
> +AX_GCC_FUNC_ATTRIBUTE([constructor])
>
> dnl Check for POSIX timers
> AC_CHECK_FUNCS(timer_create, [], [
> diff --git a/lib/igt_core.h b/lib/igt_core.h
> index 661a634..b669de3 100644
> --- a/lib/igt_core.h
> +++ b/lib/igt_core.h
> @@ -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)))
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH i-g-t v2] igt_core: add igt_constructor
2017-01-04 17:20 ` Paulo Zanoni
@ 2017-01-04 17:29 ` Chris Wilson
0 siblings, 0 replies; 4+ messages in thread
From: Chris Wilson @ 2017-01-04 17:29 UTC (permalink / raw)
To: Paulo Zanoni; +Cc: intel-gfx, Lyude
On Wed, Jan 04, 2017 at 03:20:49PM -0200, Paulo Zanoni wrote:
> Em Qua, 2016-12-21 às 15:50 -0500, Lyude escreveu:
> > 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.
>
> IGT doesn't compile anymore here. Reverting this patch fixes it for me.
>
> On a brand new git clone, if I just run autogen.sh, I get this:
>
> ./configure: line 6319: syntax error near unexpected token
> `constructor'
> ./configure: line 6319: `AX_GCC_FUNC_ATTRIBUTE(constructor)'
>
> The gcc/autoconf/etc versions are from Fedora 24.
>
> I'm not sure what I'm missing here...
m4/ax_gcc_func_attribute.m4
Now supplied for us luddites.
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-01-04 17:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-21 20:50 [PATCH i-g-t v2] igt_core: add igt_constructor Lyude
2016-12-23 13:57 ` Chris Wilson
2017-01-04 17:20 ` Paulo Zanoni
2017-01-04 17:29 ` Chris Wilson
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.