-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
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 <cfriedt@tenstorrent.com>
6513fbe to
24b2761
Compare
|
In order to avoid multiple definition errors, indicate that struct timespec is declared. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
In order to avoid multiple definition errors, indicate that struct timeval is declared. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
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 <cfriedt@tenstorrent.com>
C11 requires `<time.h>` to define `struct timespec`, so do not define it when C11 is already known. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
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 <cfriedt@tenstorrent.com>
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 <cfriedt@tenstorrent.com>
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_SELECTwest 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;
| ^~~~~~~~~~~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.
Note
You can check out #97152, and then run the command above successfully (POSIX_DEVICE_IO also does not select REQUIRES_FULL_LIBC)
In order to avoid warnings, declare `union sigval` ahead of `struct sigevent` and declare `siginfo_t` ahead of `struct sigaction`. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Previously, the `sigev_notify_function` field was missing from `struct sigevent`. Additionally, `sigev_notify_attributes` were incorrectly named `sigev_thread_attr`. Add it back to ensure that we are able to support realtime signals. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
c148cf3 to
4510cc8
Compare
|
|
@stephanosio - are you able to review? |



This change corrects 2 typos in
posix_signal.handposix_time.hand additionally ensures that libc definitions ofstruct timespecare indicated via macro to avoid redefinition warnings / errors.time_tdefinition from libcstruct timespecwhen >= c11timepsecis a struct not a typedefsigeventis a struct not a typedefsigvalis declaredsigev_notify_functionfield instruct sigeventThe issues do not affect CI or build status at the moment but do block changes slated for v4.3.0