All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lyude Paul <lyude@redhat.com>
To: Chris Wilson <chris@chris-wilson.co.uk>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH i-g-t] igt_core: add igt_constructor
Date: Wed, 21 Dec 2016 15:43:03 -0500	[thread overview]
Message-ID: <1482352983.19742.7.camel@redhat.com> (raw)
In-Reply-To: <20161221202543.GA11346@nuc-i3427.alporthouse.com>

On Wed, 2016-12-21 at 20:25 +0000, Chris Wilson wrote:
> On Wed, Dec 21, 2016 at 03:17:21PM -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>
> > ---
> >  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..e76fd5f 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 \
> > +	static void __igt_constructor_block(void)
> > __attribute__((constructor)); \
> > +	static void __igt_constructor_block(void)
> 
> #define igt_constructor \
> __attribute__((constructor)) \
> static void igt_tokencat(__igt_constructor, __LINE__)(void)
> 
> Allows for the flexibility to use multiple constructors from the
> file.
> -chris

ooh, clever. will respin in just a sec.
> 
-- 
Cheers,
	Lyude
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

      reply	other threads:[~2016-12-21 20:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-21 20:17 [PATCH i-g-t] igt_core: add igt_constructor Lyude
2016-12-21 20:25 ` Chris Wilson
2016-12-21 20:43   ` Lyude Paul [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1482352983.19742.7.camel@redhat.com \
    --to=lyude@redhat.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.