Unfortunately, Zephyr SDK 0.10.0 ships with outdated Newlib 2.0.0
(from 2015 or earlier) which lacks sys/_timespec.h header, requiring
ugly workaround of defining struct timespec inline (the whole idea
was to standardize on sys/_timespec.h header for different libc's).
This is similar to earlier workaround for struct timeval definition
introduced in a6aee9b4c8. Zephyr SDK ticket for this issue
is https://github.com/zephyrproject-rtos/sdk-ng/issues/64, and it
will ve possible to remove both workarounds when Xtensa toolchain
will be upgraded to newlib version consistent with other
architectures.
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
POSIX subsys defines struct timespec in <time.h> (as POSIX public
API requires), but newlib defines in in sys/_timespec.h, which
inevitably leads to inclusion order and redifinition conflicts.
Follow newlib way and define it in single place, sys/_timespec.h,
which belongs to libc namespace. Thus, we move current definition
to minimal libc, and will use either minlibc's or newlib's
definition, instead of trying to redefine it.
This is similar to the introduction of sys/_timeval.h done earlier.
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
According to POSIX, that's the header which defines this function.
Similarly, nothing in POSIX indicates that <time.h> should have
access to struct timeval, so it's removed (it's made accessible
to <sys/time.h> via <sys/_timeval.h> introduced earlier).
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
Some older variants of newlib (like what we have on xtensa or riscv in
SDK 0.9.5) define timespec and itimerspec in sys/types.h. The timespec
can be handled by a check of __timespec_defined. However itimerspec
doesn't have anything similar so we have to do it by newlib version
info.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Both SDK 0.10.0-beta2 and the ARM gcc 2018q2 run into a build issue with
newlib and conflict definitions of mode_t type.
First we need to add some ifdef protection if mode_t is already defined
and set _MODE_T_DECLARED if we are the first to define it.
Secondarily, we rename include/posix/sys/types.h to
include/posix/posix_types.h so that we aren't getting a name collusion
with the system sys/types.h and that we can easily and clearily include
it (which we need to do to pull in the info from newlib).
Fixes: #12224
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Some ports, e.g. nios2, have POSIXish headers (e.g. signal.h) in
their toolchains, which get includeded otherwise, and cause
definition conflicts.
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
From-current-dir includes like "sys/types.h" are dangerous - they
turn out to cause #include_next directive to not work as expected -
instead of including next file (which is in our case should be
libc's), it will include the same file once again (apparently
because with #include "", a file is found from the current dir,
so next search will countinue with -Iinclude/posix, and find
sys/types.h there again).
Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
Any word started with underscore followed by and uppercase letter or a
second underscore is a reserved word according with C99.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Provide an implementation of gettimeofday(). This uses clock_gettime()
with the CLOCK_REALTIME parameter, which is currently unimplemented, but
will allow clients to call this function once this functionality has
been implemented.
Signed-off-by: David Brown <david.brown@linaro.org>
Move posix layer from 'kernel' to 'lib' folder as it is not
a core kernel feature.
Fixed posix header file dependencies as part of the move and
also removed NEWLIBC related macros from posix headers.
Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>