[PATCH] dmx: force -fno-strict-aliasing for xinput example
Peter Hutterer
peter.hutterer at who-t.net
Sun Dec 4 19:51:01 PST 2011
On Sun, Dec 04, 2011 at 09:16:41PM -0500, Gaetan Nadon wrote:
> On Mon, 2011-12-05 at 10:37 +1000, Peter Hutterer wrote:
>
> > Compiler warning:
> > xinput.c:272: warning: dereferencing pointer 'e' does break strict-aliasing
> > rules
> >
> > The code itself is the usual XInput client-side code:
> > XEvent event;
> > XDeviceMotionEvent *e = (XDeviceMotionEvent *)&event;
> > XNextEvent(display, &event);
> > printf("%d\n", e->type);
> >
> > Since XDeviceMotionEvent is not guaranteed the same size as XEvent, clients
> > must use pointer aliasing as above when using the XNextEvent API. Disable
> > strict aliasing for this example.
> >
> > Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> > ---
> > If I understand this correctly, this is endemic to virtually any XI
> > application. Point could be made to disable strict aliasing for the whole
> > examples directory here instead of just the xinput example here but none of
> > the others complain as of yet.
> >
> > configure.ac | 1 +
> > 1 files changed, 1 insertions(+), 0 deletions(-)
> >
> > diff --git a/configure.ac b/configure.ac
> > index d2aaeb1..3443583 100644
> > --- a/configure.ac
> > +++ b/configure.ac
> > @@ -1968,6 +1968,7 @@ dnl Linux sources in DMX require <linux/keyboard.h>
> > AC_SUBST(DMXXMUEXAMPLES_DEP_LIBS)
> > PKG_CHECK_MODULES([DMXXIEXAMPLES_DEP], [$LIBDMX $LIBXI $LIBXEXT x11])
> > AC_SUBST(DMXXIEXAMPLES_DEP_LIBS)
> > + DMXXIEXAMPLES_DEP_CFLAGS+="-fno-strict-aliasing"
>
> Shouldn't this be similar to line 93 above?
>
> if test "x$GCC" = xyes ; then
> XSERVER_CFLAGS="$XSERVER_CFLAGS -fno-strict-aliasing"
> fi
>
> One cannot presume that only gcc will ever compile this code, unless I
> missed some equivalent test somewhere.
right, of course. I'll fix that up.
> I don't get any warning in my build output and I don't see any -W option
> (patch not applied):
>
> gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I../../../include
> -I/home/nadon/xorg/src/inst/include -g -O2 -MT xinput-xinput.o -MD -MP
> -MF .deps/xinput-xinput.Tpo -c -o xinput-xinput.o `test -f 'xinput.c' ||
> echo './'`xinput.c
tbh, I'm not 100% what other conditions need to be true here. I can't
reproduce it on my machine but on our build-systems it produces the above
warning without this fix.
Cheers,
Peter
> > PKG_CHECK_MODULES([XTSTEXAMPLES_DEP], [$LIBXTST $LIBXEXT x11])
> > AC_SUBST(XTSTEXAMPLES_DEP_LIBS)
> > PKG_CHECK_MODULES([XRESEXAMPLES_DEP], [xres $LIBXEXT x11])
>
>
More information about the xorg-devel
mailing list