-
Notifications
You must be signed in to change notification settings - Fork 7.4k
minimal-libc: Add define guard around struct timespec #17768
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
minimal-libc: Add define guard around struct timespec #17768
Conversation
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.
As I noted in slack the definition in <posix/time.h>
is wrong:
The <time.h> header shall declare the structure timespec, which has at least the following members:
time_t tv_sec Seconds.
long tv_nsec Nanoseconds.
where Zephyr's POSIX header has:
#ifndef __timespec_defined
#define __timespec_defined
struct timespec {
signed int tv_sec;
signed int tv_nsec;
};
#endif
time_t
in Zephyr minimal libc and most libcs is int64_t
.
The approach in this PR will create inconsistencies depending on which header is included first.
The proper fix at this time appears to be to remove the conflicting definition from <posix/time.h>
, and have that header include <time.h>
before the definition of itimerspec
. Why is that not satisfactory?
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.
As I noted in slack the definition in <posix/time.h>
is wrong:
The <time.h> header shall declare the structure timespec, which has at least the following members:
time_t tv_sec Seconds.
long tv_nsec Nanoseconds.
where Zephyr's POSIX header has:
#ifndef __timespec_defined
#define __timespec_defined
struct timespec {
signed int tv_sec;
signed int tv_nsec;
};
#endif
time_t
in Zephyr minimal libc and most libcs is int64_t
.
The approach in this PR will create inconsistencies depending on which header is included first.
The proper fix at this time appears to be to remove the conflicting definition from <posix/time.h>
, and have that header include <time.h>
before the definition of itimerspec
. Why is that not satisfactory?
That was my first try, just as you suggested - but I had some troubles verifying it with newlib. As the newlib definition is identical to the one you added to minimal libc I assumed it will be easier to justify the change when it's limited to a single part of code. I will introduce the change as you suggest and verify it with shippable then. |
It collides both with newlib and minimal libc. Signed-off-by: Piotr Zierhoffer <[email protected]>
37b3d3b
to
b2246d0
Compare
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.
This conflicts with #16626
signed int tv_nsec; | ||
}; | ||
#endif | ||
#include <time.h> |
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.
Is this maybe including itself because . is in the include search path?
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.
Actually the shippable shows -I../../../../../../include/posix
is in the search path, which is flat out wrong, unless that's how the posix subsystem was designed to be used, in which case there's good reason to step back and rethink it.
As this PR does not make sense in the light of #16626, I will close it |
This allows compilation with the CONFIG_POSIX_API=y.
There was a regression introduced in
#17468
that caused
struct timespec
to be redefined.I reused the same mechanism that was there to prevent
redefinition with NEWLIB.
Signed-off-by: Piotr Zierhoffer [email protected]