-
Notifications
You must be signed in to change notification settings - Fork 8k
libc + posix: signal.h + time.h: fix typos and avoid redeclaration warnings / errors #97472
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
libc + posix: signal.h + time.h: fix typos and avoid redeclaration warnings / errors #97472
Conversation
34c10f3
to
1006361
Compare
fb423c7
to
6513fbe
Compare
Indicate that C library headers have declared `struct sigevent` and `struct sigval` to avoid redefinition warnings / errors. Signed-off-by: Chris Friedt <[email protected]>
6513fbe
to
24b2761
Compare
|
In order to avoid multiple definition errors, indicate that struct timespec is declared. Signed-off-by: Chris Friedt <[email protected]>
In order to avoid multiple definition errors, indicate that struct timeval is declared. Signed-off-by: Chris Friedt <[email protected]>
Avoid redefining `time_t` by always including the definition from `<time.h>`, since the C library may use something other than `long`. This is still safe according to the specification, since it explicitly states: > Inclusion of the <signal.h> header may make visible all symbols from > the <time.h> header. For more information, please see https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/signal.h.html Signed-off-by: Chris Friedt <[email protected]>
C11 requires `<time.h>` to define `struct timespec`, so do not define it when C11 is already known. Signed-off-by: Chris Friedt <[email protected]>
A previous typo went undetected that declared a type-defined `timespec_t`, which is obviously incorrect, since it is only specified as `struct timespec`. Signed-off-by: Chris Friedt <[email protected]>
A previous typo went undetected that declared a type-defined `sigevent_t`, which is obviously incorrect, since it is only specified as `struct sigevent`. Signed-off-by: Chris Friedt <[email protected]>
In order to avoid warnings, declare `union sigval` ahead of `struct sigevent`. Signed-off-by: Chris Friedt <[email protected]>
Previously, the `sigev_notify_function` field was missing from `struct sigevent`. Add it back to ensure that we are able to support realtime signals. Signed-off-by: Chris Friedt <[email protected]>
24b2761
to
c148cf3
Compare
|
|
||
#if defined(_POSIX_REALTIME_SIGNALS) || defined(__DOXYGEN__) | ||
|
||
union sigval; /* forward declaration (to preserve spec order) */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wondering - can't we keep it as-is?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't.
diff --git a/lib/posix/options/Kconfig.device_io b/lib/posix/options/Kconfig.device_io
index 416ccf74a62..71ff6b7b81c 100644
--- a/lib/posix/options/Kconfig.device_io
+++ b/lib/posix/options/Kconfig.device_io
@@ -6,7 +6,7 @@ menu "POSIX device I/O"
config POSIX_DEVICE_IO
bool "POSIX device I/O"
- select REQUIRES_FULL_LIBC
+ #select REQUIRES_FULL_LIBC
select ZVFS
select ZVFS_POLL
select ZVFS_SELECT
west build -p -b qemu_riscv64 -t run tests/posix/signals/ -- -DCONFIG_MINIMAL_LIBC=y -DCONFIG_COMPILER_WARNINGS_AS_ERRORS=y
...
/home/cfriedt/zephyrproject/zephyr/include/zephyr/posix/posix_signal.h:109:22: error: field 'sigev_value' has incomplete type
109 | union sigval sigev_value;
| ^~~~~~~~~~~
This change corrects 2 typos in
posix_signal.h
andposix_time.h
and additionally ensures that libc definitions ofstruct timespec
are indicated via macro to avoid redefinition warnings / errors.time_t
definition from libcstruct timespec
when >= c11timepsec
is a struct not a typedefsigevent
is a struct not a typedefsigval
is declaredsigev_notify_function
field instruct sigevent
The issues do not affect CI or build status at the moment but do block changes slated for v4.3.0