* [lttng-dev] lttng-ust with --std=c99 -pedantic
@ 2012-06-09 23:37 John Steele Scott
2012-06-12 15:32 ` Mathieu Desnoyers
0 siblings, 1 reply; 9+ messages in thread
From: John Steele Scott @ 2012-06-09 23:37 UTC (permalink / raw)
I want to add lttng-ust tracepoints to a program which builds with "--std=c99 -pedantic". Right now this does not work.
Using the demo program as an example, if you enable --std=c99, the first issue looks like:
jscott at saaz:~/src/lttng-ust/tests/demo$ ccache gcc -std=c99 -DHAVE_CONFIG_H -I. -I../.. -I../../include/lttng -I../../include -Wall -g -O2 -MT demo.o -MD -MP -MF .deps/demo.Tpo -c -o demo.o demo.c
In file included from demo.c:34:0:
ust_tests_demo.h: In function ?__tracepoint_cb_ust_tests_demo___starting?:
ust_tests_demo.h:27:23: warning: implicit declaration of function ?typeof? [-Wimplicit-function-declaration]
ust_tests_demo.h:27:218: error: expected ?;? before ?_________p1?
ust_tests_demo.h:27:395: error: ?_________p1? undeclared (first use in this function)
ust_tests_demo.h:27:395: note: each undeclared identifier is reported only once for each function it appears in
In file included from demo.c:34:0:
ust_tests_demo.h: In function ?__tracepoint_cb_ust_tests_demo___done?:
ust_tests_demo.h:35:214: error: expected ?;? before ?_________p1?
ust_tests_demo.h:35:383: error: ?_________p1? undeclared (first use in this function)
In file included from demo.c:35:0:
ust_tests_demo2.h: In function ?__tracepoint_cb_ust_tests_demo2___loop?:
ust_tests_demo2.h:27:299: error: expected ?;? before ?_________p1?
ust_tests_demo2.h:27:470: error: ?_________p1? undeclared (first use in this function)
In file included from demo.c:36:0:
ust_tests_demo3.h: In function ?__tracepoint_cb_ust_tests_demo3___done?:
ust_tests_demo3.h:27:215: error: expected ?;? before ?_________p1?
ust_tests_demo3.h:27:386: error: ?_________p1? undeclared (first use in this function)
This can be easily resolved by using __typeof__() instead of typeof(). Then I can build with --std=c99. But adding -pedantic still fails:
jscott at saaz:~/src/lttng-ust/tests/demo$ ccache gcc -std=c99 -Dtypeof=__typeof__ -pedantic -DHAVE_CONFIG_H -I. -I../.. -I../../include/lttng -I../../include -Wall -g -O2 -MT demo.o -MD -MP -MF .deps/demo.Tpo -c -o demo.o demo.c
In file included from ust_tests_demo.h:25:0,
from demo.c:34:
../../include/lttng/tracepoint.h: In function ?__tracepoints__init?:
../../include/lttng/tracepoint.h:251:4: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
../../include/lttng/tracepoint.h:255:4: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
../../include/lttng/tracepoint.h:260:4: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
../../include/lttng/tracepoint.h:264:4: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
../../include/lttng/tracepoint.h:268:4: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
In file included from demo.c:34:0:
ust_tests_demo.h: In function ?__tracepoint_cb_ust_tests_demo___starting?:
ust_tests_demo.h:27:161: warning: ISO C forbids braced-groups within expressions [-pedantic]
ust_tests_demo.h:27:549: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
In file included from demo.c:34:0:
ust_tests_demo.h: In function ?__tracepoint_cb_ust_tests_demo___done?:
ust_tests_demo.h:35:161: warning: ISO C forbids braced-groups within expressions [-pedantic]
ust_tests_demo.h:35:537: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
In file included from demo.c:35:0:
ust_tests_demo2.h: In function ?__tracepoint_cb_ust_tests_demo2___loop?:
ust_tests_demo2.h:27:245: warning: ISO C forbids braced-groups within expressions [-pedantic]
ust_tests_demo2.h:27:624: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
In file included from demo.c:36:0:
ust_tests_demo3.h: In function ?__tracepoint_cb_ust_tests_demo3___done?:
ust_tests_demo3.h:27:161: warning: ISO C forbids braced-groups within expressions [-pedantic]
ust_tests_demo3.h:27:540: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
This is with 4.6.1-9ubuntu3 on Ubuntu 11.10, lttng-ust master 5a821c.
Would it be particularly difficult to make the lttng-ust tracepoints compatible with programs built with -pedantic?
cheers,
John
^ permalink raw reply [flat|nested] 9+ messages in thread
* [lttng-dev] lttng-ust with --std=c99 -pedantic
2012-06-09 23:37 [lttng-dev] lttng-ust with --std=c99 -pedantic John Steele Scott
@ 2012-06-12 15:32 ` Mathieu Desnoyers
2012-06-12 15:55 ` Mathieu Desnoyers
0 siblings, 1 reply; 9+ messages in thread
From: Mathieu Desnoyers @ 2012-06-12 15:32 UTC (permalink / raw)
Hi John,
* John Steele Scott (toojays at toojays.net) wrote:
> I want to add lttng-ust tracepoints to a program which builds with "--std=c99 -pedantic". Right now this does not work.
>
> Using the demo program as an example, if you enable --std=c99, the first issue looks like:
>
> jscott at saaz:~/src/lttng-ust/tests/demo$ ccache gcc -std=c99 -DHAVE_CONFIG_H -I. -I../.. -I../../include/lttng -I../../include -Wall -g -O2 -MT demo.o -MD -MP -MF .deps/demo.Tpo -c -o demo.o demo.c
> In file included from demo.c:34:0:
> ust_tests_demo.h: In function ?__tracepoint_cb_ust_tests_demo___starting?:
> ust_tests_demo.h:27:23: warning: implicit declaration of function ?typeof? [-Wimplicit-function-declaration]
> ust_tests_demo.h:27:218: error: expected ?;? before ?_________p1?
> ust_tests_demo.h:27:395: error: ?_________p1? undeclared (first use in this function)
> ust_tests_demo.h:27:395: note: each undeclared identifier is reported only once for each function it appears in
> In file included from demo.c:34:0:
> ust_tests_demo.h: In function ?__tracepoint_cb_ust_tests_demo___done?:
> ust_tests_demo.h:35:214: error: expected ?;? before ?_________p1?
> ust_tests_demo.h:35:383: error: ?_________p1? undeclared (first use in this function)
> In file included from demo.c:35:0:
> ust_tests_demo2.h: In function ?__tracepoint_cb_ust_tests_demo2___loop?:
> ust_tests_demo2.h:27:299: error: expected ?;? before ?_________p1?
> ust_tests_demo2.h:27:470: error: ?_________p1? undeclared (first use in this function)
> In file included from demo.c:36:0:
> ust_tests_demo3.h: In function ?__tracepoint_cb_ust_tests_demo3___done?:
> ust_tests_demo3.h:27:215: error: expected ?;? before ?_________p1?
> ust_tests_demo3.h:27:386: error: ?_________p1? undeclared (first use in this function)
>
> This can be easily resolved by using __typeof__() instead of typeof(). Then I can build with --std=c99. But adding -pedantic still fails:
I pushed a fix for this:
commit 6423c3134bf07d4a7db56f69f2c79b540a79c4f1
Author: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
Date: Mon Jun 11 10:15:25 2012 -0400
Fix c99 compatibility: use __typeof__ instead of typeof in public headers
Reported-by: John Steele Scott <toojays at toojays.net>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
I also had issues with (void) arg parameters with tracepoints, so
pushed:
commit 4495dd39c05739d0fb2bc463b7c093d2459ce2b6
Author: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
Date: Tue Jun 12 11:22:46 2012 -0400
Fix: support -std=c99 in tracepoint macros
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
I had also to fix userspace RCU library, with:
commit e51500edbd9919cee53bc85cbb4b22cd4786fc42
Author: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
Date: Tue Jun 12 11:24:31 2012 -0400
Fix c99 compatibility: use __asm__ and __volatile__ in public headers
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
commit bdffa73aa208ad5f1e5b3a3cb6cbf86ac6996559
Author: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
Date: Mon Jun 11 10:16:35 2012 -0400
Fix c99 compatibility: use __typeof__ instead of typeof in public headers
Reported-by: John Steele Scott <toojays at toojays.net>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
>
> jscott at saaz:~/src/lttng-ust/tests/demo$ ccache gcc -std=c99 -Dtypeof=__typeof__ -pedantic -DHAVE_CONFIG_H -I. -I../.. -I../../include/lttng -I../../include -Wall -g -O2 -MT demo.o -MD -MP -MF .deps/demo.Tpo -c -o demo.o demo.c
> In file included from ust_tests_demo.h:25:0,
> from demo.c:34:
> ../../include/lttng/tracepoint.h: In function ?__tracepoints__init?:
> ../../include/lttng/tracepoint.h:251:4: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> ../../include/lttng/tracepoint.h:255:4: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> ../../include/lttng/tracepoint.h:260:4: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> ../../include/lttng/tracepoint.h:264:4: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> ../../include/lttng/tracepoint.h:268:4: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> In file included from demo.c:34:0:
> ust_tests_demo.h: In function ?__tracepoint_cb_ust_tests_demo___starting?:
> ust_tests_demo.h:27:161: warning: ISO C forbids braced-groups within expressions [-pedantic]
> ust_tests_demo.h:27:549: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> In file included from demo.c:34:0:
> ust_tests_demo.h: In function ?__tracepoint_cb_ust_tests_demo___done?:
> ust_tests_demo.h:35:161: warning: ISO C forbids braced-groups within expressions [-pedantic]
> ust_tests_demo.h:35:537: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> In file included from demo.c:35:0:
> ust_tests_demo2.h: In function ?__tracepoint_cb_ust_tests_demo2___loop?:
> ust_tests_demo2.h:27:245: warning: ISO C forbids braced-groups within expressions [-pedantic]
> ust_tests_demo2.h:27:624: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> In file included from demo.c:36:0:
> ust_tests_demo3.h: In function ?__tracepoint_cb_ust_tests_demo3___done?:
> ust_tests_demo3.h:27:161: warning: ISO C forbids braced-groups within expressions [-pedantic]
> ust_tests_demo3.h:27:540: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
I see these warnings, the only thing that currently fails is due to
BYTE_ORDER and BIG_ENDIAN not being defined. By adding:
-DBYTE_ORDER=__BYTE_ORDER -DBIG_ENDIAN=__BIG_ENDIAN
my tests/hello program, with a Makefile.am modified to do:
hello_CFLAGS = -Werror=old-style-definition --std=c99 -pedantic
prints many pedantic warnings, and fails with:
././ust_tests_hello.h:55:1: error: zero or negative size array ?__event_fields___ust_tests_hello___tptest_sighandler?
which seems to be caused by my event with 0 fields, which try to create
an array of length 0.
I'll look into this one.
Thanks,
Mathieu
>
> This is with 4.6.1-9ubuntu3 on Ubuntu 11.10, lttng-ust master 5a821c.
>
> Would it be particularly difficult to make the lttng-ust tracepoints compatible with programs built with -pedantic?
>
> cheers,
>
> John
>
>
> _______________________________________________
> lttng-dev mailing list
> lttng-dev at lists.lttng.org
> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* [lttng-dev] lttng-ust with --std=c99 -pedantic
2012-06-12 15:32 ` Mathieu Desnoyers
@ 2012-06-12 15:55 ` Mathieu Desnoyers
2012-06-18 12:10 ` John Steele Scott
0 siblings, 1 reply; 9+ messages in thread
From: Mathieu Desnoyers @ 2012-06-12 15:55 UTC (permalink / raw)
* Mathieu Desnoyers (mathieu.desnoyers at efficios.com) wrote:
> Hi John,
>
> * John Steele Scott (toojays at toojays.net) wrote:
> > I want to add lttng-ust tracepoints to a program which builds with "--std=c99 -pedantic". Right now this does not work.
> >
> > Using the demo program as an example, if you enable --std=c99, the first issue looks like:
> >
> > jscott at saaz:~/src/lttng-ust/tests/demo$ ccache gcc -std=c99 -DHAVE_CONFIG_H -I. -I../.. -I../../include/lttng -I../../include -Wall -g -O2 -MT demo.o -MD -MP -MF .deps/demo.Tpo -c -o demo.o demo.c
> > In file included from demo.c:34:0:
> > ust_tests_demo.h: In function ?__tracepoint_cb_ust_tests_demo___starting?:
> > ust_tests_demo.h:27:23: warning: implicit declaration of function ?typeof? [-Wimplicit-function-declaration]
> > ust_tests_demo.h:27:218: error: expected ?;? before ?_________p1?
> > ust_tests_demo.h:27:395: error: ?_________p1? undeclared (first use in this function)
> > ust_tests_demo.h:27:395: note: each undeclared identifier is reported only once for each function it appears in
> > In file included from demo.c:34:0:
> > ust_tests_demo.h: In function ?__tracepoint_cb_ust_tests_demo___done?:
> > ust_tests_demo.h:35:214: error: expected ?;? before ?_________p1?
> > ust_tests_demo.h:35:383: error: ?_________p1? undeclared (first use in this function)
> > In file included from demo.c:35:0:
> > ust_tests_demo2.h: In function ?__tracepoint_cb_ust_tests_demo2___loop?:
> > ust_tests_demo2.h:27:299: error: expected ?;? before ?_________p1?
> > ust_tests_demo2.h:27:470: error: ?_________p1? undeclared (first use in this function)
> > In file included from demo.c:36:0:
> > ust_tests_demo3.h: In function ?__tracepoint_cb_ust_tests_demo3___done?:
> > ust_tests_demo3.h:27:215: error: expected ?;? before ?_________p1?
> > ust_tests_demo3.h:27:386: error: ?_________p1? undeclared (first use in this function)
> >
> > This can be easily resolved by using __typeof__() instead of typeof(). Then I can build with --std=c99. But adding -pedantic still fails:
>
> I pushed a fix for this:
>
> commit 6423c3134bf07d4a7db56f69f2c79b540a79c4f1
> Author: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> Date: Mon Jun 11 10:15:25 2012 -0400
>
> Fix c99 compatibility: use __typeof__ instead of typeof in public headers
>
> Reported-by: John Steele Scott <toojays at toojays.net>
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
>
> I also had issues with (void) arg parameters with tracepoints, so
> pushed:
>
> commit 4495dd39c05739d0fb2bc463b7c093d2459ce2b6
> Author: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> Date: Tue Jun 12 11:22:46 2012 -0400
>
> Fix: support -std=c99 in tracepoint macros
>
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
>
> I had also to fix userspace RCU library, with:
>
>
> commit e51500edbd9919cee53bc85cbb4b22cd4786fc42
> Author: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> Date: Tue Jun 12 11:24:31 2012 -0400
>
> Fix c99 compatibility: use __asm__ and __volatile__ in public headers
>
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
>
> commit bdffa73aa208ad5f1e5b3a3cb6cbf86ac6996559
> Author: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> Date: Mon Jun 11 10:16:35 2012 -0400
>
> Fix c99 compatibility: use __typeof__ instead of typeof in public headers
>
> Reported-by: John Steele Scott <toojays at toojays.net>
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
>
>
> >
> > jscott at saaz:~/src/lttng-ust/tests/demo$ ccache gcc -std=c99 -Dtypeof=__typeof__ -pedantic -DHAVE_CONFIG_H -I. -I../.. -I../../include/lttng -I../../include -Wall -g -O2 -MT demo.o -MD -MP -MF .deps/demo.Tpo -c -o demo.o demo.c
> > In file included from ust_tests_demo.h:25:0,
> > from demo.c:34:
> > ../../include/lttng/tracepoint.h: In function ?__tracepoints__init?:
> > ../../include/lttng/tracepoint.h:251:4: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> > ../../include/lttng/tracepoint.h:255:4: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> > ../../include/lttng/tracepoint.h:260:4: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> > ../../include/lttng/tracepoint.h:264:4: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> > ../../include/lttng/tracepoint.h:268:4: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> > In file included from demo.c:34:0:
> > ust_tests_demo.h: In function ?__tracepoint_cb_ust_tests_demo___starting?:
> > ust_tests_demo.h:27:161: warning: ISO C forbids braced-groups within expressions [-pedantic]
> > ust_tests_demo.h:27:549: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> > In file included from demo.c:34:0:
> > ust_tests_demo.h: In function ?__tracepoint_cb_ust_tests_demo___done?:
> > ust_tests_demo.h:35:161: warning: ISO C forbids braced-groups within expressions [-pedantic]
> > ust_tests_demo.h:35:537: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> > In file included from demo.c:35:0:
> > ust_tests_demo2.h: In function ?__tracepoint_cb_ust_tests_demo2___loop?:
> > ust_tests_demo2.h:27:245: warning: ISO C forbids braced-groups within expressions [-pedantic]
> > ust_tests_demo2.h:27:624: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> > In file included from demo.c:36:0:
> > ust_tests_demo3.h: In function ?__tracepoint_cb_ust_tests_demo3___done?:
> > ust_tests_demo3.h:27:161: warning: ISO C forbids braced-groups within expressions [-pedantic]
> > ust_tests_demo3.h:27:540: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
>
> I see these warnings, the only thing that currently fails is due to
> BYTE_ORDER and BIG_ENDIAN not being defined. By adding:
>
> -DBYTE_ORDER=__BYTE_ORDER -DBIG_ENDIAN=__BIG_ENDIAN
>
> my tests/hello program, with a Makefile.am modified to do:
>
> hello_CFLAGS = -Werror=old-style-definition --std=c99 -pedantic
>
> prints many pedantic warnings, and fails with:
>
> ././ust_tests_hello.h:55:1: error: zero or negative size array ?__event_fields___ust_tests_hello___tptest_sighandler?
>
> which seems to be caused by my event with 0 fields, which try to create
> an array of length 0.
>
> I'll look into this one.
Please try again with lttng-ust master HEAD, userspace-rcu master HEAD,
and let me know if you experience problems compiling your instrumented
application with --std=c99 -pedantic. Please note that the probe object
(e.g. tp.c in the tests/hello program) needs to be compiled with gnu
extensions, so you should not use --std=c99 for this specific object.
Thanks,
Mathieu
>
> Thanks,
>
> Mathieu
>
> >
> > This is with 4.6.1-9ubuntu3 on Ubuntu 11.10, lttng-ust master 5a821c.
> >
> > Would it be particularly difficult to make the lttng-ust tracepoints compatible with programs built with -pedantic?
> >
> > cheers,
> >
> > John
> >
> >
> > _______________________________________________
> > lttng-dev mailing list
> > lttng-dev at lists.lttng.org
> > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
>
> --
> Mathieu Desnoyers
> Operating System Efficiency R&D Consultant
> EfficiOS Inc.
> http://www.efficios.com
>
> _______________________________________________
> lttng-dev mailing list
> lttng-dev at lists.lttng.org
> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* [lttng-dev] lttng-ust with --std=c99 -pedantic
2012-06-12 15:55 ` Mathieu Desnoyers
@ 2012-06-18 12:10 ` John Steele Scott
2012-06-18 14:11 ` Mathieu Desnoyers
0 siblings, 1 reply; 9+ messages in thread
From: John Steele Scott @ 2012-06-18 12:10 UTC (permalink / raw)
On 13/06/12 01:25, Mathieu Desnoyers wrote:
> * Mathieu Desnoyers (mathieu.desnoyers at efficios.com) wrote:
>> Hi John,
>>
>> * John Steele Scott (toojays at toojays.net) wrote:
>>> I want to add lttng-ust tracepoints to a program which builds with "--std=c99 -pedantic". Right now this does not work.
>>>
>>> Using the demo program as an example, if you enable --std=c99, the first issue looks like:
>>>
>>> jscott at saaz:~/src/lttng-ust/tests/demo$ ccache gcc -std=c99 -DHAVE_CONFIG_H -I. -I../.. -I../../include/lttng -I../../include -Wall -g -O2 -MT demo.o -MD -MP -MF .deps/demo.Tpo -c -o demo.o demo.c
>>> In file included from demo.c:34:0:
>>> ust_tests_demo.h: In function ?__tracepoint_cb_ust_tests_demo___starting?:
>>> ust_tests_demo.h:27:23: warning: implicit declaration of function ?typeof? [-Wimplicit-function-declaration]
>>> ust_tests_demo.h:27:218: error: expected ?;? before ?_________p1?
>>> ust_tests_demo.h:27:395: error: ?_________p1? undeclared (first use in this function)
>>> ust_tests_demo.h:27:395: note: each undeclared identifier is reported only once for each function it appears in
>>> In file included from demo.c:34:0:
>>> ust_tests_demo.h: In function ?__tracepoint_cb_ust_tests_demo___done?:
>>> ust_tests_demo.h:35:214: error: expected ?;? before ?_________p1?
>>> ust_tests_demo.h:35:383: error: ?_________p1? undeclared (first use in this function)
>>> In file included from demo.c:35:0:
>>> ust_tests_demo2.h: In function ?__tracepoint_cb_ust_tests_demo2___loop?:
>>> ust_tests_demo2.h:27:299: error: expected ?;? before ?_________p1?
>>> ust_tests_demo2.h:27:470: error: ?_________p1? undeclared (first use in this function)
>>> In file included from demo.c:36:0:
>>> ust_tests_demo3.h: In function ?__tracepoint_cb_ust_tests_demo3___done?:
>>> ust_tests_demo3.h:27:215: error: expected ?;? before ?_________p1?
>>> ust_tests_demo3.h:27:386: error: ?_________p1? undeclared (first use in this function)
>>>
>>> This can be easily resolved by using __typeof__() instead of typeof(). Then I can build with --std=c99. But adding -pedantic still fails:
>> I pushed a fix for this:
>>
>> commit 6423c3134bf07d4a7db56f69f2c79b540a79c4f1
>> Author: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
>> Date: Mon Jun 11 10:15:25 2012 -0400
>>
>> Fix c99 compatibility: use __typeof__ instead of typeof in public headers
>>
>> Reported-by: John Steele Scott <toojays at toojays.net>
>> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
>>
>> I also had issues with (void) arg parameters with tracepoints, so
>> pushed:
>>
>> commit 4495dd39c05739d0fb2bc463b7c093d2459ce2b6
>> Author: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
>> Date: Tue Jun 12 11:22:46 2012 -0400
>>
>> Fix: support -std=c99 in tracepoint macros
>>
>> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
>>
>> I had also to fix userspace RCU library, with:
>>
>>
>> commit e51500edbd9919cee53bc85cbb4b22cd4786fc42
>> Author: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
>> Date: Tue Jun 12 11:24:31 2012 -0400
>>
>> Fix c99 compatibility: use __asm__ and __volatile__ in public headers
>>
>> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
>>
>> commit bdffa73aa208ad5f1e5b3a3cb6cbf86ac6996559
>> Author: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
>> Date: Mon Jun 11 10:16:35 2012 -0400
>>
>> Fix c99 compatibility: use __typeof__ instead of typeof in public headers
>>
>> Reported-by: John Steele Scott <toojays at toojays.net>
>> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
>>
>>
>>> jscott at saaz:~/src/lttng-ust/tests/demo$ ccache gcc -std=c99 -Dtypeof=__typeof__ -pedantic -DHAVE_CONFIG_H -I. -I../.. -I../../include/lttng -I../../include -Wall -g -O2 -MT demo.o -MD -MP -MF .deps/demo.Tpo -c -o demo.o demo.c
>>> In file included from ust_tests_demo.h:25:0,
>>> from demo.c:34:
>>> ../../include/lttng/tracepoint.h: In function ?__tracepoints__init?:
>>> ../../include/lttng/tracepoint.h:251:4: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
>>> ../../include/lttng/tracepoint.h:255:4: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
>>> ../../include/lttng/tracepoint.h:260:4: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
>>> ../../include/lttng/tracepoint.h:264:4: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
>>> ../../include/lttng/tracepoint.h:268:4: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
>>> In file included from demo.c:34:0:
>>> ust_tests_demo.h: In function ?__tracepoint_cb_ust_tests_demo___starting?:
>>> ust_tests_demo.h:27:161: warning: ISO C forbids braced-groups within expressions [-pedantic]
>>> ust_tests_demo.h:27:549: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
>>> In file included from demo.c:34:0:
>>> ust_tests_demo.h: In function ?__tracepoint_cb_ust_tests_demo___done?:
>>> ust_tests_demo.h:35:161: warning: ISO C forbids braced-groups within expressions [-pedantic]
>>> ust_tests_demo.h:35:537: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
>>> In file included from demo.c:35:0:
>>> ust_tests_demo2.h: In function ?__tracepoint_cb_ust_tests_demo2___loop?:
>>> ust_tests_demo2.h:27:245: warning: ISO C forbids braced-groups within expressions [-pedantic]
>>> ust_tests_demo2.h:27:624: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
>>> In file included from demo.c:36:0:
>>> ust_tests_demo3.h: In function ?__tracepoint_cb_ust_tests_demo3___done?:
>>> ust_tests_demo3.h:27:161: warning: ISO C forbids braced-groups within expressions [-pedantic]
>>> ust_tests_demo3.h:27:540: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
>> I see these warnings, the only thing that currently fails is due to
>> BYTE_ORDER and BIG_ENDIAN not being defined. By adding:
>>
>> -DBYTE_ORDER=__BYTE_ORDER -DBIG_ENDIAN=__BIG_ENDIAN
>>
>> my tests/hello program, with a Makefile.am modified to do:
>>
>> hello_CFLAGS = -Werror=old-style-definition --std=c99 -pedantic
>>
>> prints many pedantic warnings, and fails with:
>>
>> ././ust_tests_hello.h:55:1: error: zero or negative size array ?__event_fields___ust_tests_hello___tptest_sighandler?
>>
>> which seems to be caused by my event with 0 fields, which try to create
>> an array of length 0.
>>
>> I'll look into this one.
> Please try again with lttng-ust master HEAD, userspace-rcu master HEAD,
> and let me know if you experience problems compiling your instrumented
> application with --std=c99 -pedantic. Please note that the probe object
> (e.g. tp.c in the tests/hello program) needs to be compiled with gnu
> extensions, so you should not use --std=c99 for this specific object.
Mathieu,
Thanks for your reply, sorry it has taken me so long to respond.
I can now build this application with userspace tracing. I was actually able to compile the probe object with --std=c99 as well (this time on Centos 6.2, didn't try yet on Ubuntu). Would you expect any problems from this? I only have a single tracepoint in this app, but it does seem to work.
The thing I forgot to mention is: okay, I can build now with -pedantic, but I can't build with "-pedantic -Werror". This application builds with "--std=c99 -pedantic -Werror" (among many other flags). I can of course remove -Werror for my tests, but in the longer term I would like to see lttng-ust enabled in our regular build, and disabling -Werror for that is not something we want to do. If I only had to disable it for the trace provider, I could negotiate that, but disabling it for any module which uses tracepoints is undesirable.
I haven't yet looked at how difficult it would be do eliminate these pedantic warnings. Do you have a feel for what is involved? Preprocessor tricks warp my mind. :(
cheers,
John
^ permalink raw reply [flat|nested] 9+ messages in thread
* [lttng-dev] lttng-ust with --std=c99 -pedantic
2012-06-18 12:10 ` John Steele Scott
@ 2012-06-18 14:11 ` Mathieu Desnoyers
2012-06-19 17:45 ` Mathieu Desnoyers
0 siblings, 1 reply; 9+ messages in thread
From: Mathieu Desnoyers @ 2012-06-18 14:11 UTC (permalink / raw)
* John Steele Scott (toojays at toojays.net) wrote:
> On 13/06/12 01:25, Mathieu Desnoyers wrote:
> > * Mathieu Desnoyers (mathieu.desnoyers at efficios.com) wrote:
> >> Hi John,
> >>
> >> * John Steele Scott (toojays at toojays.net) wrote:
> >>> I want to add lttng-ust tracepoints to a program which builds with "--std=c99 -pedantic". Right now this does not work.
> >>>
> >>> Using the demo program as an example, if you enable --std=c99, the first issue looks like:
> >>>
> >>> jscott at saaz:~/src/lttng-ust/tests/demo$ ccache gcc -std=c99 -DHAVE_CONFIG_H -I. -I../.. -I../../include/lttng -I../../include -Wall -g -O2 -MT demo.o -MD -MP -MF .deps/demo.Tpo -c -o demo.o demo.c
> >>> In file included from demo.c:34:0:
> >>> ust_tests_demo.h: In function ?__tracepoint_cb_ust_tests_demo___starting?:
> >>> ust_tests_demo.h:27:23: warning: implicit declaration of function ?typeof? [-Wimplicit-function-declaration]
> >>> ust_tests_demo.h:27:218: error: expected ?;? before ?_________p1?
> >>> ust_tests_demo.h:27:395: error: ?_________p1? undeclared (first use in this function)
> >>> ust_tests_demo.h:27:395: note: each undeclared identifier is reported only once for each function it appears in
> >>> In file included from demo.c:34:0:
> >>> ust_tests_demo.h: In function ?__tracepoint_cb_ust_tests_demo___done?:
> >>> ust_tests_demo.h:35:214: error: expected ?;? before ?_________p1?
> >>> ust_tests_demo.h:35:383: error: ?_________p1? undeclared (first use in this function)
> >>> In file included from demo.c:35:0:
> >>> ust_tests_demo2.h: In function ?__tracepoint_cb_ust_tests_demo2___loop?:
> >>> ust_tests_demo2.h:27:299: error: expected ?;? before ?_________p1?
> >>> ust_tests_demo2.h:27:470: error: ?_________p1? undeclared (first use in this function)
> >>> In file included from demo.c:36:0:
> >>> ust_tests_demo3.h: In function ?__tracepoint_cb_ust_tests_demo3___done?:
> >>> ust_tests_demo3.h:27:215: error: expected ?;? before ?_________p1?
> >>> ust_tests_demo3.h:27:386: error: ?_________p1? undeclared (first use in this function)
> >>>
> >>> This can be easily resolved by using __typeof__() instead of typeof(). Then I can build with --std=c99. But adding -pedantic still fails:
> >> I pushed a fix for this:
> >>
> >> commit 6423c3134bf07d4a7db56f69f2c79b540a79c4f1
> >> Author: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> >> Date: Mon Jun 11 10:15:25 2012 -0400
> >>
> >> Fix c99 compatibility: use __typeof__ instead of typeof in public headers
> >>
> >> Reported-by: John Steele Scott <toojays at toojays.net>
> >> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> >>
> >> I also had issues with (void) arg parameters with tracepoints, so
> >> pushed:
> >>
> >> commit 4495dd39c05739d0fb2bc463b7c093d2459ce2b6
> >> Author: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> >> Date: Tue Jun 12 11:22:46 2012 -0400
> >>
> >> Fix: support -std=c99 in tracepoint macros
> >>
> >> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> >>
> >> I had also to fix userspace RCU library, with:
> >>
> >>
> >> commit e51500edbd9919cee53bc85cbb4b22cd4786fc42
> >> Author: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> >> Date: Tue Jun 12 11:24:31 2012 -0400
> >>
> >> Fix c99 compatibility: use __asm__ and __volatile__ in public headers
> >>
> >> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> >>
> >> commit bdffa73aa208ad5f1e5b3a3cb6cbf86ac6996559
> >> Author: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> >> Date: Mon Jun 11 10:16:35 2012 -0400
> >>
> >> Fix c99 compatibility: use __typeof__ instead of typeof in public headers
> >>
> >> Reported-by: John Steele Scott <toojays at toojays.net>
> >> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> >>
> >>
> >>> jscott at saaz:~/src/lttng-ust/tests/demo$ ccache gcc -std=c99 -Dtypeof=__typeof__ -pedantic -DHAVE_CONFIG_H -I. -I../.. -I../../include/lttng -I../../include -Wall -g -O2 -MT demo.o -MD -MP -MF .deps/demo.Tpo -c -o demo.o demo.c
> >>> In file included from ust_tests_demo.h:25:0,
> >>> from demo.c:34:
> >>> ../../include/lttng/tracepoint.h: In function ?__tracepoints__init?:
> >>> ../../include/lttng/tracepoint.h:251:4: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> >>> ../../include/lttng/tracepoint.h:255:4: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> >>> ../../include/lttng/tracepoint.h:260:4: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> >>> ../../include/lttng/tracepoint.h:264:4: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> >>> ../../include/lttng/tracepoint.h:268:4: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> >>> In file included from demo.c:34:0:
> >>> ust_tests_demo.h: In function ?__tracepoint_cb_ust_tests_demo___starting?:
> >>> ust_tests_demo.h:27:161: warning: ISO C forbids braced-groups within expressions [-pedantic]
> >>> ust_tests_demo.h:27:549: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> >>> In file included from demo.c:34:0:
> >>> ust_tests_demo.h: In function ?__tracepoint_cb_ust_tests_demo___done?:
> >>> ust_tests_demo.h:35:161: warning: ISO C forbids braced-groups within expressions [-pedantic]
> >>> ust_tests_demo.h:35:537: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> >>> In file included from demo.c:35:0:
> >>> ust_tests_demo2.h: In function ?__tracepoint_cb_ust_tests_demo2___loop?:
> >>> ust_tests_demo2.h:27:245: warning: ISO C forbids braced-groups within expressions [-pedantic]
> >>> ust_tests_demo2.h:27:624: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> >>> In file included from demo.c:36:0:
> >>> ust_tests_demo3.h: In function ?__tracepoint_cb_ust_tests_demo3___done?:
> >>> ust_tests_demo3.h:27:161: warning: ISO C forbids braced-groups within expressions [-pedantic]
> >>> ust_tests_demo3.h:27:540: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> >> I see these warnings, the only thing that currently fails is due to
> >> BYTE_ORDER and BIG_ENDIAN not being defined. By adding:
> >>
> >> -DBYTE_ORDER=__BYTE_ORDER -DBIG_ENDIAN=__BIG_ENDIAN
> >>
> >> my tests/hello program, with a Makefile.am modified to do:
> >>
> >> hello_CFLAGS = -Werror=old-style-definition --std=c99 -pedantic
> >>
> >> prints many pedantic warnings, and fails with:
> >>
> >> ././ust_tests_hello.h:55:1: error: zero or negative size array ?__event_fields___ust_tests_hello___tptest_sighandler?
> >>
> >> which seems to be caused by my event with 0 fields, which try to create
> >> an array of length 0.
> >>
> >> I'll look into this one.
> > Please try again with lttng-ust master HEAD, userspace-rcu master HEAD,
> > and let me know if you experience problems compiling your instrumented
> > application with --std=c99 -pedantic. Please note that the probe object
> > (e.g. tp.c in the tests/hello program) needs to be compiled with gnu
> > extensions, so you should not use --std=c99 for this specific object.
>
> Mathieu,
>
> Thanks for your reply, sorry it has taken me so long to respond.
>
> I can now build this application with userspace tracing. I was
> actually able to compile the probe object with --std=c99 as well (this
> time on Centos 6.2, didn't try yet on Ubuntu). Would you expect any
> problems from this? I only have a single tracepoint in this app, but
> it does seem to work.
--std=c99 will not work to compile probes containing tracepoints taking
0 arguments. This is because c99 does not allow 0-sized arrays, and I
don't want to complexify the probe generation to take care of this
issue.
>
> The thing I forgot to mention is: okay, I can build now with
> -pedantic, but I can't build with "-pedantic -Werror". This
> application builds with "--std=c99 -pedantic -Werror" (among many
> other flags). I can of course remove -Werror for my tests, but in the
> longer term I would like to see lttng-ust enabled in our regular
> build, and disabling -Werror for that is not something we want to do.
> If I only had to disable it for the trace provider, I could negotiate
> that, but disabling it for any module which uses tracepoints is
> undesirable.
>
> I haven't yet looked at how difficult it would be do eliminate these
> pedantic warnings. Do you have a feel for what is involved?
> Preprocessor tricks warp my mind. :(
I don't think we'll want to make the lttng probe module build under
--std=c99 -pedandic -Werror, but I think we should focus on making sure
the tracepoint part that is built within the application (with
TRACEPOINT_CREATE_PROBES _not_ defined) builds fine in --std=c99
-pedantic.
Currently, building a simple test program with tracepoints under
--std=c99 -pedantic gets me:
In file included from ust_tests_hello.h:25:0,
from hello.c:34:
../../include/lttng/tracepoint.h: In function ?__tracepoints__init?:
../../include/lttng/tracepoint.h:261:3: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
../../include/lttng/tracepoint.h:265:3: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
../../include/lttng/tracepoint.h:270:3: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
../../include/lttng/tracepoint.h:274:3: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
../../include/lttng/tracepoint.h:278:3: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
---> see include/lttng/tracepoint.h __tracepoints__init():
----> This is caused by use of dlsym() to lookup a function pointer from
a symbol. dlsym() returns "void *", and we cast it into function
pointer type. Ideas on how to make this c99 pedantic compliant are
welcome.
------------------
In file included from hello.c:34:0:
ust_tests_hello.h: In function ?__tracepoint_cb_ust_tests_hello___tptest?:
ust_tests_hello.h:28:1: warning: ISO C forbids braced-groups within expressions [-pedantic]
ust_tests_hello.h:28:1: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
ust_tests_hello.h: In function ?__tracepoint_cb_ust_tests_hello___tptest_sighandler?:
ust_tests_hello.h:52:1: warning: ISO C forbids braced-groups within expressions [-pedantic]
ust_tests_hello.h:52:1: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
---> see include/lttng/tracepoint.h
#define _DECLARE_TRACEPOINT(_provider, _name, ...) \
extern struct tracepoint __tracepoint_##_provider##___##_name; \
static inline void __tracepoint_cb_##_provider##___##_name(_TP_ARGS_PROTO(__VA_ARGS__)) \
[...]
----> this is caused by use of "tp_rcu_dereference_bp()", which is
defined in include/lttng/tracepoint-rcu.h (in the #else clause) :
#define tp_rcu_dereference_bp(p) \
({ \
__typeof__(p) _________p1 = URCU_FORCE_CAST(__typeof__(p), \
tracepoint_dlopen.rcu_dereference_sym_bp(URCU_FORCE_CAST(void *, p))); \
(_________p1); \
})
For this one, we should be able to change it into a single-expression
and remove the braced-groups, since we are just really evaluating a
single expression here. Fixed by the following commit in lttng-ust
master:
commit a4eaf8eabe829be8f7d7432ffaf83291a068b0ed
Author: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
Date: Mon Jun 18 10:10:36 2012 -0400
Fix c99 compatibility: tp_rcu_dereference_bp() should not use braced-groups within expressions
------------------
hello.c: In function ?inthandler?:
hello.c:39:47: warning: ISO C99 requires rest arguments to be used [enabled by default]
---> see include/lttng/tracepoint.h tracepoint() macro.
----> this is caused by not passing any argument to the tracepoint.
Ideas on how to fix this are welcome, as I don't see any way to do it in
C99-pedantic.
Thanks!
Mathieu
>
> cheers,
>
> John
>
> _______________________________________________
> lttng-dev mailing list
> lttng-dev at lists.lttng.org
> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* [lttng-dev] lttng-ust with --std=c99 -pedantic
2012-06-18 14:11 ` Mathieu Desnoyers
@ 2012-06-19 17:45 ` Mathieu Desnoyers
2012-06-20 13:10 ` John Steele Scott
0 siblings, 1 reply; 9+ messages in thread
From: Mathieu Desnoyers @ 2012-06-19 17:45 UTC (permalink / raw)
* Mathieu Desnoyers (mathieu.desnoyers at efficios.com) wrote:
> * John Steele Scott (toojays at toojays.net) wrote:
> > On 13/06/12 01:25, Mathieu Desnoyers wrote:
> > > * Mathieu Desnoyers (mathieu.desnoyers at efficios.com) wrote:
> > >> Hi John,
> > >>
> > >> * John Steele Scott (toojays at toojays.net) wrote:
> > >>> I want to add lttng-ust tracepoints to a program which builds with "--std=c99 -pedantic". Right now this does not work.
> > >>>
> > >>> Using the demo program as an example, if you enable --std=c99, the first issue looks like:
> > >>>
> > >>> jscott at saaz:~/src/lttng-ust/tests/demo$ ccache gcc -std=c99 -DHAVE_CONFIG_H -I. -I../.. -I../../include/lttng -I../../include -Wall -g -O2 -MT demo.o -MD -MP -MF .deps/demo.Tpo -c -o demo.o demo.c
> > >>> In file included from demo.c:34:0:
> > >>> ust_tests_demo.h: In function ?__tracepoint_cb_ust_tests_demo___starting?:
> > >>> ust_tests_demo.h:27:23: warning: implicit declaration of function ?typeof? [-Wimplicit-function-declaration]
> > >>> ust_tests_demo.h:27:218: error: expected ?;? before ?_________p1?
> > >>> ust_tests_demo.h:27:395: error: ?_________p1? undeclared (first use in this function)
> > >>> ust_tests_demo.h:27:395: note: each undeclared identifier is reported only once for each function it appears in
> > >>> In file included from demo.c:34:0:
> > >>> ust_tests_demo.h: In function ?__tracepoint_cb_ust_tests_demo___done?:
> > >>> ust_tests_demo.h:35:214: error: expected ?;? before ?_________p1?
> > >>> ust_tests_demo.h:35:383: error: ?_________p1? undeclared (first use in this function)
> > >>> In file included from demo.c:35:0:
> > >>> ust_tests_demo2.h: In function ?__tracepoint_cb_ust_tests_demo2___loop?:
> > >>> ust_tests_demo2.h:27:299: error: expected ?;? before ?_________p1?
> > >>> ust_tests_demo2.h:27:470: error: ?_________p1? undeclared (first use in this function)
> > >>> In file included from demo.c:36:0:
> > >>> ust_tests_demo3.h: In function ?__tracepoint_cb_ust_tests_demo3___done?:
> > >>> ust_tests_demo3.h:27:215: error: expected ?;? before ?_________p1?
> > >>> ust_tests_demo3.h:27:386: error: ?_________p1? undeclared (first use in this function)
> > >>>
> > >>> This can be easily resolved by using __typeof__() instead of typeof(). Then I can build with --std=c99. But adding -pedantic still fails:
> > >> I pushed a fix for this:
> > >>
> > >> commit 6423c3134bf07d4a7db56f69f2c79b540a79c4f1
> > >> Author: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> > >> Date: Mon Jun 11 10:15:25 2012 -0400
> > >>
> > >> Fix c99 compatibility: use __typeof__ instead of typeof in public headers
> > >>
> > >> Reported-by: John Steele Scott <toojays at toojays.net>
> > >> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> > >>
> > >> I also had issues with (void) arg parameters with tracepoints, so
> > >> pushed:
> > >>
> > >> commit 4495dd39c05739d0fb2bc463b7c093d2459ce2b6
> > >> Author: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> > >> Date: Tue Jun 12 11:22:46 2012 -0400
> > >>
> > >> Fix: support -std=c99 in tracepoint macros
> > >>
> > >> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> > >>
> > >> I had also to fix userspace RCU library, with:
> > >>
> > >>
> > >> commit e51500edbd9919cee53bc85cbb4b22cd4786fc42
> > >> Author: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> > >> Date: Tue Jun 12 11:24:31 2012 -0400
> > >>
> > >> Fix c99 compatibility: use __asm__ and __volatile__ in public headers
> > >>
> > >> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> > >>
> > >> commit bdffa73aa208ad5f1e5b3a3cb6cbf86ac6996559
> > >> Author: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> > >> Date: Mon Jun 11 10:16:35 2012 -0400
> > >>
> > >> Fix c99 compatibility: use __typeof__ instead of typeof in public headers
> > >>
> > >> Reported-by: John Steele Scott <toojays at toojays.net>
> > >> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> > >>
> > >>
> > >>> jscott at saaz:~/src/lttng-ust/tests/demo$ ccache gcc -std=c99 -Dtypeof=__typeof__ -pedantic -DHAVE_CONFIG_H -I. -I../.. -I../../include/lttng -I../../include -Wall -g -O2 -MT demo.o -MD -MP -MF .deps/demo.Tpo -c -o demo.o demo.c
> > >>> In file included from ust_tests_demo.h:25:0,
> > >>> from demo.c:34:
> > >>> ../../include/lttng/tracepoint.h: In function ?__tracepoints__init?:
> > >>> ../../include/lttng/tracepoint.h:251:4: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> > >>> ../../include/lttng/tracepoint.h:255:4: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> > >>> ../../include/lttng/tracepoint.h:260:4: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> > >>> ../../include/lttng/tracepoint.h:264:4: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> > >>> ../../include/lttng/tracepoint.h:268:4: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> > >>> In file included from demo.c:34:0:
> > >>> ust_tests_demo.h: In function ?__tracepoint_cb_ust_tests_demo___starting?:
> > >>> ust_tests_demo.h:27:161: warning: ISO C forbids braced-groups within expressions [-pedantic]
> > >>> ust_tests_demo.h:27:549: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> > >>> In file included from demo.c:34:0:
> > >>> ust_tests_demo.h: In function ?__tracepoint_cb_ust_tests_demo___done?:
> > >>> ust_tests_demo.h:35:161: warning: ISO C forbids braced-groups within expressions [-pedantic]
> > >>> ust_tests_demo.h:35:537: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> > >>> In file included from demo.c:35:0:
> > >>> ust_tests_demo2.h: In function ?__tracepoint_cb_ust_tests_demo2___loop?:
> > >>> ust_tests_demo2.h:27:245: warning: ISO C forbids braced-groups within expressions [-pedantic]
> > >>> ust_tests_demo2.h:27:624: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> > >>> In file included from demo.c:36:0:
> > >>> ust_tests_demo3.h: In function ?__tracepoint_cb_ust_tests_demo3___done?:
> > >>> ust_tests_demo3.h:27:161: warning: ISO C forbids braced-groups within expressions [-pedantic]
> > >>> ust_tests_demo3.h:27:540: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> > >> I see these warnings, the only thing that currently fails is due to
> > >> BYTE_ORDER and BIG_ENDIAN not being defined. By adding:
> > >>
> > >> -DBYTE_ORDER=__BYTE_ORDER -DBIG_ENDIAN=__BIG_ENDIAN
> > >>
> > >> my tests/hello program, with a Makefile.am modified to do:
> > >>
> > >> hello_CFLAGS = -Werror=old-style-definition --std=c99 -pedantic
> > >>
> > >> prints many pedantic warnings, and fails with:
> > >>
> > >> ././ust_tests_hello.h:55:1: error: zero or negative size array ?__event_fields___ust_tests_hello___tptest_sighandler?
> > >>
> > >> which seems to be caused by my event with 0 fields, which try to create
> > >> an array of length 0.
> > >>
> > >> I'll look into this one.
> > > Please try again with lttng-ust master HEAD, userspace-rcu master HEAD,
> > > and let me know if you experience problems compiling your instrumented
> > > application with --std=c99 -pedantic. Please note that the probe object
> > > (e.g. tp.c in the tests/hello program) needs to be compiled with gnu
> > > extensions, so you should not use --std=c99 for this specific object.
> >
> > Mathieu,
> >
> > Thanks for your reply, sorry it has taken me so long to respond.
> >
> > I can now build this application with userspace tracing. I was
> > actually able to compile the probe object with --std=c99 as well (this
> > time on Centos 6.2, didn't try yet on Ubuntu). Would you expect any
> > problems from this? I only have a single tracepoint in this app, but
> > it does seem to work.
>
> --std=c99 will not work to compile probes containing tracepoints taking
> 0 arguments. This is because c99 does not allow 0-sized arrays, and I
> don't want to complexify the probe generation to take care of this
> issue.
>
> >
> > The thing I forgot to mention is: okay, I can build now with
> > -pedantic, but I can't build with "-pedantic -Werror". This
> > application builds with "--std=c99 -pedantic -Werror" (among many
> > other flags). I can of course remove -Werror for my tests, but in the
> > longer term I would like to see lttng-ust enabled in our regular
> > build, and disabling -Werror for that is not something we want to do.
> > If I only had to disable it for the trace provider, I could negotiate
> > that, but disabling it for any module which uses tracepoints is
> > undesirable.
> >
> > I haven't yet looked at how difficult it would be do eliminate these
> > pedantic warnings. Do you have a feel for what is involved?
> > Preprocessor tricks warp my mind. :(
>
> I don't think we'll want to make the lttng probe module build under
> --std=c99 -pedandic -Werror, but I think we should focus on making sure
> the tracepoint part that is built within the application (with
> TRACEPOINT_CREATE_PROBES _not_ defined) builds fine in --std=c99
> -pedantic.
>
> Currently, building a simple test program with tracepoints under
> --std=c99 -pedantic gets me:
>
>
> In file included from ust_tests_hello.h:25:0,
> from hello.c:34:
> ../../include/lttng/tracepoint.h: In function ?__tracepoints__init?:
> ../../include/lttng/tracepoint.h:261:3: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> ../../include/lttng/tracepoint.h:265:3: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> ../../include/lttng/tracepoint.h:270:3: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> ../../include/lttng/tracepoint.h:274:3: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> ../../include/lttng/tracepoint.h:278:3: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
>
> ---> see include/lttng/tracepoint.h __tracepoints__init():
> ----> This is caused by use of dlsym() to lookup a function pointer from
> a symbol. dlsym() returns "void *", and we cast it into function
> pointer type. Ideas on how to make this c99 pedantic compliant are
> welcome.
>
> ------------------
>
> In file included from hello.c:34:0:
> ust_tests_hello.h: In function ?__tracepoint_cb_ust_tests_hello___tptest?:
> ust_tests_hello.h:28:1: warning: ISO C forbids braced-groups within expressions [-pedantic]
> ust_tests_hello.h:28:1: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> ust_tests_hello.h: In function ?__tracepoint_cb_ust_tests_hello___tptest_sighandler?:
> ust_tests_hello.h:52:1: warning: ISO C forbids braced-groups within expressions [-pedantic]
> ust_tests_hello.h:52:1: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
>
> ---> see include/lttng/tracepoint.h
>
> #define _DECLARE_TRACEPOINT(_provider, _name, ...) \
> extern struct tracepoint __tracepoint_##_provider##___##_name; \
> static inline void __tracepoint_cb_##_provider##___##_name(_TP_ARGS_PROTO(__VA_ARGS__)) \
> [...]
>
> ----> this is caused by use of "tp_rcu_dereference_bp()", which is
> defined in include/lttng/tracepoint-rcu.h (in the #else clause) :
>
> #define tp_rcu_dereference_bp(p) \
> ({ \
> __typeof__(p) _________p1 = URCU_FORCE_CAST(__typeof__(p), \
> tracepoint_dlopen.rcu_dereference_sym_bp(URCU_FORCE_CAST(void *, p))); \
> (_________p1); \
> })
>
> For this one, we should be able to change it into a single-expression
> and remove the braced-groups, since we are just really evaluating a
> single expression here. Fixed by the following commit in lttng-ust
> master:
>
> commit a4eaf8eabe829be8f7d7432ffaf83291a068b0ed
> Author: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> Date: Mon Jun 18 10:10:36 2012 -0400
>
> Fix c99 compatibility: tp_rcu_dereference_bp() should not use braced-groups within expressions
>
> ------------------
>
> hello.c: In function ?inthandler?:
> hello.c:39:47: warning: ISO C99 requires rest arguments to be used [enabled by default]
> ---> see include/lttng/tracepoint.h tracepoint() macro.
> ----> this is caused by not passing any argument to the tracepoint.
> Ideas on how to fix this are welcome, as I don't see any way to do it in
> C99-pedantic.
I think I found a way to fix the last pedantic warnings. Can you try
with this master branch commit ?
commit fbdeb5ecb8ff9b7d73a72de9fc66d07f7797d93f
Author: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
Date: Tue Jun 19 13:45:05 2012 -0400
Fix C99 strict compatibility: don't use void * for function pointers
compiling public headers with --std=x99 -pedantic shows:
warning: ISO C forbids conversion of object pointer to function pointer type
Use "void (*func)(void)" to represent a generic function pointer rather
than "void *".
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
>
> Thanks!
>
> Mathieu
>
>
>
> >
> > cheers,
> >
> > John
> >
> > _______________________________________________
> > lttng-dev mailing list
> > lttng-dev at lists.lttng.org
> > http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
>
> --
> Mathieu Desnoyers
> Operating System Efficiency R&D Consultant
> EfficiOS Inc.
> http://www.efficios.com
>
> _______________________________________________
> lttng-dev mailing list
> lttng-dev at lists.lttng.org
> http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* [lttng-dev] lttng-ust with --std=c99 -pedantic
2012-06-19 17:45 ` Mathieu Desnoyers
@ 2012-06-20 13:10 ` John Steele Scott
2012-06-20 13:47 ` Mathieu Desnoyers
0 siblings, 1 reply; 9+ messages in thread
From: John Steele Scott @ 2012-06-20 13:10 UTC (permalink / raw)
On 20/06/12 03:15, Mathieu Desnoyers wrote:
> * Mathieu Desnoyers (mathieu.desnoyers at efficios.com) wrote:
>> * John Steele Scott (toojays at toojays.net) wrote:
>>
snip snip
>>> The thing I forgot to mention is: okay, I can build now with
>>> -pedantic, but I can't build with "-pedantic -Werror". This
>>> application builds with "--std=c99 -pedantic -Werror" (among many
>>> other flags). I can of course remove -Werror for my tests, but in the
>>> longer term I would like to see lttng-ust enabled in our regular
>>> build, and disabling -Werror for that is not something we want to do.
>>> If I only had to disable it for the trace provider, I could negotiate
>>> that, but disabling it for any module which uses tracepoints is
>>> undesirable.
>>>
>>> I haven't yet looked at how difficult it would be do eliminate these
>>> pedantic warnings. Do you have a feel for what is involved?
>>> Preprocessor tricks warp my mind. :(
>> I don't think we'll want to make the lttng probe module build under
>> --std=c99 -pedandic -Werror, but I think we should focus on making sure
>> the tracepoint part that is built within the application (with
>> TRACEPOINT_CREATE_PROBES _not_ defined) builds fine in --std=c99
>> -pedantic.
>>
>> Currently, building a simple test program with tracepoints under
>> --std=c99 -pedantic gets me:
>>
>>
>> In file included from ust_tests_hello.h:25:0,
>> from hello.c:34:
>> ../../include/lttng/tracepoint.h: In function ?__tracepoints__init?:
>> ../../include/lttng/tracepoint.h:261:3: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
>> ../../include/lttng/tracepoint.h:265:3: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
>> ../../include/lttng/tracepoint.h:270:3: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
>> ../../include/lttng/tracepoint.h:274:3: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
>> ../../include/lttng/tracepoint.h:278:3: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
>>
>> ---> see include/lttng/tracepoint.h __tracepoints__init():
>> ----> This is caused by use of dlsym() to lookup a function pointer from
>> a symbol. dlsym() returns "void *", and we cast it into function
>> pointer type. Ideas on how to make this c99 pedantic compliant are
>> welcome.
I found this warning discussed in a GCC bug report. Jakub Jelinek's suggestion at http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45289#c6 (load the result of dlsym into a void *, then memcpy to the function pointer), does make these go away (using GCC 4.4.6 on Centos 6.2).
>>
>> ------------------
>>
>> In file included from hello.c:34:0:
>> ust_tests_hello.h: In function ?__tracepoint_cb_ust_tests_hello___tptest?:
>> ust_tests_hello.h:28:1: warning: ISO C forbids braced-groups within expressions [-pedantic]
>> ust_tests_hello.h:28:1: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
>> ust_tests_hello.h: In function ?__tracepoint_cb_ust_tests_hello___tptest_sighandler?:
>> ust_tests_hello.h:52:1: warning: ISO C forbids braced-groups within expressions [-pedantic]
>> ust_tests_hello.h:52:1: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
>>
>> ---> see include/lttng/tracepoint.h
>>
>> #define _DECLARE_TRACEPOINT(_provider, _name, ...) \
>> extern struct tracepoint __tracepoint_##_provider##___##_name; \
>> static inline void __tracepoint_cb_##_provider##___##_name(_TP_ARGS_PROTO(__VA_ARGS__)) \
>> [...]
>>
>> ----> this is caused by use of "tp_rcu_dereference_bp()", which is
>> defined in include/lttng/tracepoint-rcu.h (in the #else clause) :
>>
>> #define tp_rcu_dereference_bp(p) \
>> ({ \
>> __typeof__(p) _________p1 = URCU_FORCE_CAST(__typeof__(p), \
>> tracepoint_dlopen.rcu_dereference_sym_bp(URCU_FORCE_CAST(void *, p))); \
>> (_________p1); \
>> })
>>
>> For this one, we should be able to change it into a single-expression
>> and remove the braced-groups, since we are just really evaluating a
>> single expression here. Fixed by the following commit in lttng-ust
>> master:
>>
>> commit a4eaf8eabe829be8f7d7432ffaf83291a068b0ed
>> Author: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
>> Date: Mon Jun 18 10:10:36 2012 -0400
>>
>> Fix c99 compatibility: tp_rcu_dereference_bp() should not use braced-groups within expressions
>>
>> ------------------
>>
>> hello.c: In function ?inthandler?:
>> hello.c:39:47: warning: ISO C99 requires rest arguments to be used [enabled by default]
>> ---> see include/lttng/tracepoint.h tracepoint() macro.
>> ----> this is caused by not passing any argument to the tracepoint.
>> Ideas on how to fix this are welcome, as I don't see any way to do it in
>> C99-pedantic.
> I think I found a way to fix the last pedantic warnings. Can you try
> with this master branch commit ?
>
>
> commit fbdeb5ecb8ff9b7d73a72de9fc66d07f7797d93f
> Author: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
> Date: Tue Jun 19 13:45:05 2012 -0400
>
> Fix C99 strict compatibility: don't use void * for function pointers
>
> compiling public headers with --std=x99 -pedantic shows:
>
> warning: ISO C forbids conversion of object pointer to function pointer type
>
> Use "void (*func)(void)" to represent a generic function pointer rather
> than "void *".
>
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers at efficios.com>
>
Unfortunately, this isn't sufficient to fix these warnings on Centos 6.2. However, I can now make the warnings go away by using dlsym+memcpy (instead of dlsym+cast), as mentioned above. I haven't had a chance to actually use the resulting binary yet, but I don't see why it shouldn't work.
Thanks,
John
^ permalink raw reply [flat|nested] 9+ messages in thread
* [lttng-dev] lttng-ust with --std=c99 -pedantic
2012-06-20 13:10 ` John Steele Scott
@ 2012-06-20 13:47 ` Mathieu Desnoyers
2012-06-21 0:51 ` John Steele Scott
0 siblings, 1 reply; 9+ messages in thread
From: Mathieu Desnoyers @ 2012-06-20 13:47 UTC (permalink / raw)
* John Steele Scott (toojays at toojays.net) wrote:
> On 20/06/12 03:15, Mathieu Desnoyers wrote:
> > * Mathieu Desnoyers (mathieu.desnoyers at efficios.com) wrote:
> >> * John Steele Scott (toojays at toojays.net) wrote:
> >>
> snip snip
> >>> The thing I forgot to mention is: okay, I can build now with
> >>> -pedantic, but I can't build with "-pedantic -Werror". This
> >>> application builds with "--std=c99 -pedantic -Werror" (among many
> >>> other flags). I can of course remove -Werror for my tests, but in the
> >>> longer term I would like to see lttng-ust enabled in our regular
> >>> build, and disabling -Werror for that is not something we want to do.
> >>> If I only had to disable it for the trace provider, I could negotiate
> >>> that, but disabling it for any module which uses tracepoints is
> >>> undesirable.
> >>>
> >>> I haven't yet looked at how difficult it would be do eliminate these
> >>> pedantic warnings. Do you have a feel for what is involved?
> >>> Preprocessor tricks warp my mind. :(
> >> I don't think we'll want to make the lttng probe module build under
> >> --std=c99 -pedandic -Werror, but I think we should focus on making sure
> >> the tracepoint part that is built within the application (with
> >> TRACEPOINT_CREATE_PROBES _not_ defined) builds fine in --std=c99
> >> -pedantic.
> >>
> >> Currently, building a simple test program with tracepoints under
> >> --std=c99 -pedantic gets me:
> >>
> >>
> >> In file included from ust_tests_hello.h:25:0,
> >> from hello.c:34:
> >> ../../include/lttng/tracepoint.h: In function ?__tracepoints__init?:
> >> ../../include/lttng/tracepoint.h:261:3: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> >> ../../include/lttng/tracepoint.h:265:3: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> >> ../../include/lttng/tracepoint.h:270:3: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> >> ../../include/lttng/tracepoint.h:274:3: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> >> ../../include/lttng/tracepoint.h:278:3: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
> >>
> >> ---> see include/lttng/tracepoint.h __tracepoints__init():
> >> ----> This is caused by use of dlsym() to lookup a function pointer from
> >> a symbol. dlsym() returns "void *", and we cast it into function
> >> pointer type. Ideas on how to make this c99 pedantic compliant are
> >> welcome.
>
> I found this warning discussed in a GCC bug report. Jakub Jelinek's suggestion at http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45289#c6 (load the result of dlsym into a void *, then memcpy to the function pointer), does make these go away (using GCC 4.4.6 on Centos 6.2).
Can you check if these can be reproduced with gcc 4.5 or 4.6 ? (without
the memcpy trick)
The bugzilla entry seems to imply that the warning went away from
-pedantic mode at some point.
Thanks,
Mathieu
--
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* [lttng-dev] lttng-ust with --std=c99 -pedantic
2012-06-20 13:47 ` Mathieu Desnoyers
@ 2012-06-21 0:51 ` John Steele Scott
0 siblings, 0 replies; 9+ messages in thread
From: John Steele Scott @ 2012-06-21 0:51 UTC (permalink / raw)
Mathieu Desnoyers <mathieu.desnoyers at efficios.com> writes:
> * John Steele Scott (toojays at toojays.net) wrote:
>> On 20/06/12 03:15, Mathieu Desnoyers wrote:
>> > * Mathieu Desnoyers (mathieu.desnoyers at efficios.com) wrote:
>> >> * John Steele Scott (toojays at toojays.net) wrote:
>> >>
>> snip snip
>> >>> The thing I forgot to mention is: okay, I can build now with
>> >>> -pedantic, but I can't build with "-pedantic -Werror". This
>> >>> application builds with "--std=c99 -pedantic -Werror" (among many
>> >>> other flags). I can of course remove -Werror for my tests, but in the
>> >>> longer term I would like to see lttng-ust enabled in our regular
>> >>> build, and disabling -Werror for that is not something we want to do.
>> >>> If I only had to disable it for the trace provider, I could negotiate
>> >>> that, but disabling it for any module which uses tracepoints is
>> >>> undesirable.
>> >>>
>> >>> I haven't yet looked at how difficult it would be do eliminate these
>> >>> pedantic warnings. Do you have a feel for what is involved?
>> >>> Preprocessor tricks warp my mind. :(
>> >> I don't think we'll want to make the lttng probe module build under
>> >> --std=c99 -pedandic -Werror, but I think we should focus on making sure
>> >> the tracepoint part that is built within the application (with
>> >> TRACEPOINT_CREATE_PROBES _not_ defined) builds fine in --std=c99
>> >> -pedantic.
>> >>
>> >> Currently, building a simple test program with tracepoints under
>> >> --std=c99 -pedantic gets me:
>> >>
>> >>
>> >> In file included from ust_tests_hello.h:25:0,
>> >> from hello.c:34:
>> >> ../../include/lttng/tracepoint.h: In function ?__tracepoints__init?:
>> >> ../../include/lttng/tracepoint.h:261:3: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
>> >> ../../include/lttng/tracepoint.h:265:3: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
>> >> ../../include/lttng/tracepoint.h:270:3: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
>> >> ../../include/lttng/tracepoint.h:274:3: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
>> >> ../../include/lttng/tracepoint.h:278:3: warning: ISO C forbids conversion of object pointer to function pointer type [-pedantic]
>> >>
>> >> ---> see include/lttng/tracepoint.h __tracepoints__init():
>> >> ----> This is caused by use of dlsym() to lookup a function pointer from
>> >> a symbol. dlsym() returns "void *", and we cast it into function
>> >> pointer type. Ideas on how to make this c99 pedantic compliant are
>> >> welcome.
>>
>> I found this warning discussed in a GCC bug report. Jakub Jelinek's suggestion at http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45289#c6 (load the result of dlsym into a void *, then memcpy to the function pointer), does make these go away (using GCC 4.4.6 on Centos 6.2).
>
> Can you check if these can be reproduced with gcc 4.5 or 4.6 ? (without
> the memcpy trick)
>
> The bugzilla entry seems to imply that the warning went away from
> -pedantic mode at some point.
That was my reading of the bugzilla entry as well. However, I can still
reproduce those warnings with GCC 4.5.4 and 4.6.1 (both installed on Ubuntu
11.10). I don't have a GCC 4.7 install to test with.
An alternative approach to the memcpy thing is to wrap dlsym in a function
which returns the symbol in an output parameter, rather than a return
value. It looks a little less ugly. Something like:
diff --git a/include/lttng/tracepoint.h b/include/lttng/tracepoint.h
index 5bab476..8d2afc1 100644
--- a/include/lttng/tracepoint.h
+++ b/include/lttng/tracepoint.h
@@ -249,6 +249,14 @@ int __tracepoint_registered
struct tracepoint_dlopen tracepoint_dlopen
__attribute__((weak, visibility("hidden")));
+#ifndef LTTNG_HAVE_PEDANTIC_C99_DLSYM_WORKAROUND
+#define LTTNG_HAVE_PEDANTIC_C99_DLSYM_WORKAROUND
+static void lttng_c99_dlsym(void *handle, const char* symbol, void **addr)
+{
+ *addr = dlsym(handle, symbol);
+}
+#endif
+
static void __attribute__((constructor)) __tracepoints__init(void)
{
if (__tracepoint_registered++)
@@ -258,27 +266,22 @@ static void __attribute__((constructor)) __tracepoints__init(void)
dlopen("liblttng-ust-tracepoint.so.0", RTLD_NOW | RTLD_GLOBAL);
if (!tracepoint_dlopen.liblttngust_handle)
return;
- tracepoint_dlopen.tracepoint_register_lib =
- URCU_FORCE_CAST(int (*)(struct tracepoint * const *, int),
- dlsym(tracepoint_dlopen.liblttngust_handle,
- "tracepoint_register_lib"));
- tracepoint_dlopen.tracepoint_unregister_lib =
- URCU_FORCE_CAST(int (*)(struct tracepoint * const *),
- dlsym(tracepoint_dlopen.liblttngust_handle,
- "tracepoint_unregister_lib"));
+ lttng_c99_dlsym(tracepoint_dlopen.liblttngust_handle,
+ "tracepoint_register_lib",
+ (void **)&tracepoint_dlopen.tracepoint_register_lib);
+ lttng_c99_dlsym(tracepoint_dlopen.liblttngust_handle,
+ "tracepoint_unregister_lib",
+ (void **)&tracepoint_dlopen.tracepoint_unregister_lib);
#ifndef _LGPL_SOURCE
- tracepoint_dlopen.rcu_read_lock_sym_bp =
- URCU_FORCE_CAST(void (*)(void),
- dlsym(tracepoint_dlopen.liblttngust_handle,
- "tp_rcu_read_lock_bp"));
- tracepoint_dlopen.rcu_read_unlock_sym_bp =
- URCU_FORCE_CAST(void (*)(void),
- dlsym(tracepoint_dlopen.liblttngust_handle,
- "tp_rcu_read_unlock_bp"));
- tracepoint_dlopen.rcu_dereference_sym_bp =
- URCU_FORCE_CAST(void *(*)(void *p),
- dlsym(tracepoint_dlopen.liblttngust_handle,
- "tp_rcu_dereference_sym_bp"));
+ lttng_c99_dlsym(tracepoint_dlopen.liblttngust_handle,
+ "tp_rcu_read_lock_bp",
+ (void **)&tracepoint_dlopen.rcu_read_lock_sym_bp);
+ lttng_c99_dlsym(tracepoint_dlopen.liblttngust_handle,
+ "tp_rcu_read_unlock_bp",
+ (void **)&tracepoint_dlopen.rcu_read_unlock_sym_bp);
+ lttng_c99_dlsym(tracepoint_dlopen.liblttngust_handle,
+ "tp_rcu_dereference_sym_bp",
+ (void **)&tracepoint_dlopen.rcu_dereference_sym_bp);
#endif
tracepoint_dlopen.tracepoint_register_lib(__start___tracepoints_ptrs,
__stop___tracepoints_ptrs -
On the system I'm trying to build which has the aggressive GCC warnings
enabled, this gets me down to just one warning, which is due to redundantly
declaring the __tracepoint_provider_##_provider symbol. That one is from
-Wredundant-decls, not -pedantic; and I'll leave it for another day.
cheers,
John
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2012-06-21 0:51 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-09 23:37 [lttng-dev] lttng-ust with --std=c99 -pedantic John Steele Scott
2012-06-12 15:32 ` Mathieu Desnoyers
2012-06-12 15:55 ` Mathieu Desnoyers
2012-06-18 12:10 ` John Steele Scott
2012-06-18 14:11 ` Mathieu Desnoyers
2012-06-19 17:45 ` Mathieu Desnoyers
2012-06-20 13:10 ` John Steele Scott
2012-06-20 13:47 ` Mathieu Desnoyers
2012-06-21 0:51 ` John Steele Scott
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox