linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] perf: perf_event_attr anon unions and static initializer issue
@ 2012-10-05 10:36 Stephane Eranian
  2012-10-05 11:01 ` Peter Zijlstra
  0 siblings, 1 reply; 4+ messages in thread
From: Stephane Eranian @ 2012-10-05 10:36 UTC (permalink / raw)
  To: LKML
  Cc: Peter Zijlstra, mingo, David Ahern, Arnaldo Carvalho de Melo,
	Namhyung Kim

Hi,

I am writing a little test program for the perf_event API which is using
hardcoded events. Some of those events (SNBEP uncore events) require
a value for config1. I was naively assuming, one could simply do:

struct perf_event_attr attr = { .config = 0x1234, .config1 = 0x456 };

However this does not work with gcc version < 4.6 apparently. Don't
know how this even works with other compilers. I looked online and
I could not really find a good way of solving this that would be portable
across compiler versions.

If we name those unions, then this will break lots of existing programs.
We'd have to create a "named" version of perf_event_attr and then
memcpy() at runtime. Or simply initialize the .config1 and such fields at
runtime from a separate table.

Does anyone have a better solution to propose?

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-10-05 12:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-05 10:36 [RFC] perf: perf_event_attr anon unions and static initializer issue Stephane Eranian
2012-10-05 11:01 ` Peter Zijlstra
2012-10-05 11:49   ` Stephane Eranian
2012-10-05 12:43     ` Borislav Petkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).