Daniel Hellstrom
Software Section Head
Cobham Gaisler
T : +46 (0) 31 775 8657
F : +46 (0) 31 421407
daniel.hellst...@gaisler.com
Cobham Gaisler AB, Kungsgatan 12, SE-411 19, GÖTEBORG, Sweden.
+46 (0) 31 775 8650, www.cobham.com/gaisler
Please consider the environment before printing this email
This e-mail and any files transmitted with it ("E-mail") is intended solely for
the addressee(s) and may contain confidential and/or legally privileged information. If
you are not the addressee(s), any disclosure,
reproduction, copying, distribution or other use of the E-mail is prohibited.
If you have received this E-mail in error, please delete it and notify the
sender immediately via our switchboard or return e-mail.
Neither the company nor any subsidiary or affiliate or associated company nor
any individual sending this Email accepts any liability in respect of the
content (including errors and omissions) nor shall this e-mail be deemed to
enter the company or any subsidiary or affiliate or associated company into a
contract or to create any legally binding obligations unless expressly agreed
to in writing under separate cover and timeliness of the E-mail which arise as
a result of transmission. If verification is required, please request a hard
copy version from the sender.
On 2018-10-05 09:24, Sebastian Huber wrote:
On 05/10/2018 08:57, Daniel Hellstrom wrote:
From: Jacob Hansen <jacob.han...@gaisler.com>
This commits bypasses a static assert when using the Clang compiler.
This is done as the static assertion does not compile with Clang
("static_assert expression is not an integral constant expression").
I am not sure this static assertion makes sense at all. SEM_FAILED
is used as a return value on failures from running sem_open(). Is
the test supposed to check that SEM_FAILED is defiend as NULL in the
included libraries (newlib) ? It is defiend as "(sem_t *) 0" in newlib.
The draft version of the posix standard, required sem_open to return
-1, so
maybe this is an attempt to ensure that SEM_FAILED is actually defined?
But the compilation would failed if SEM_FAILED is not defined anyway.
I guess the check would make sense if somehow the code depended on
SEM_FAILED to be equal to NULL. But in that case I would think the code
should be updated to remove this dependency.
Looking at the source for sem_open at cpukit/posix/src/semopen.c it
seems that it uses the SEM_FAILED define as a return value, and I do not
see any dependencies on SEM_FAILED==NULL anywhere.
The change that introduces this code is:
"posix: Implement self-contained POSIX semaphores":
c090db7405b72ce6d0b726c0a39fb1c1aebab7ea
This static assertion ensures that POSIX_SEMAPHORE_VALIDATE_OBJECT()
rejects semaphore pointers with a SEM_FAILED value. We could change
this macro to test also for SEM_FAILED, but it would result in code
like this
if (sem == 0 (aka NULL) || sem == 0 (aka SEM_FAILED) || ...)
See also:
https://gcc.gnu.org/ml/gcc-help/2018-10/msg00021.html
Coverity Scan crashes at this line too. GCC issues only a -Wpedantic
warning. In C++ the static assert would be fine. I am not sure how to
fix this.
I just saw that you have pushed the
1d39e96470b27195d35a69cc94551c403b7980bd commit that updated the
RTEMS_STATIC_ASSERT() macro, thanks for updating this. I just wanted to
let you know that the issue I'm seeing with clang is still there:
make[5]: Entering directory
'/home/daniel/git/rtems/rcc-1.3/rtems/build/gr712rc_drvmgr_test_up/sparc-gaisler-rtems5/c/gr712rc/cpukit/posix'
sparc-gaisler-rtems5-clang --pipe -DHAVE_CONFIG_H -I..
-I/home/daniel/git/rtems/rcc-1.3/rtems/build/gr712rc_drvmgr_test_up/sparc-gaisler-rtems5/c/gr712rc/include
-I/home/daniel/git/rtems/rcc-1.3/rtems/kernel/cpukit/include
-I/home/daniel/git/rtems/rcc-1.3/rtems/kernel/cpukit/score/cpu/sparc/include
-I/home/daniel/git/rtems/rcc-1.3/rtems/kernel/cpukit/libnetworking
-mcpu=gr712rc -O2 -g -ffunction-sections -fdata-sections -Wall
-Wmissing-prototypes -Wimplicit-function-declaration -Wstrict-prototypes
-Wnested-externs -MT src/libposix_a-seminit.o -MD -MP -MF
src/.deps/libposix_a-seminit.Tpo -c -o src/libposix_a-seminit.o `test -f
'src/seminit.c' || echo
'/home/daniel/git/rtems/rcc-1.3/rtems/kernel/c/src/../../cpukit/posix/'`src/seminit.c
/home/daniel/git/rtems/rcc-1.3/rtems/kernel/c/src/../../cpukit/posix/src/seminit.c:25:21:
error: static_assert expression is not an integral constant expression
RTEMS_STATIC_ASSERT(NULL == SEM_FAILED, sem_failed);
~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/opt/rcc-1.3-rc6-llvm/lib/clang/8.0.0/include/stddef.h:105:16: note:
expanded from macro 'NULL'
# define NULL ((void*)0)
^
/home/daniel/git/rtems/rcc-1.3/rtems/kernel/cpukit/include/rtems/score/basedefs.h:317:20:
note: expanded from macro 'RTEMS_STATIC_ASSERT'
_Static_assert(cond, # msg)
^~~~
/home/daniel/git/rtems/rcc-1.3/rtems/kernel/c/src/../../cpukit/posix/src/seminit.c:25:21:
note: cast from 'void *' is not allowed in a constant expression
/opt/rcc-1.3-rc6-llvm/lib/clang/8.0.0/include/stddef.h:105:16: note:
expanded from macro 'NULL'
# define NULL ((void*)0)
^
1 error generated.
Makefile:3750: recipe for target 'src/libposix_a-seminit.o' failed
_______________________________________________
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel