diff --git a/include/posix/time.h b/include/posix/time.h index ca1e262f1f..285d4ae44d 100644 --- a/include/posix/time.h +++ b/include/posix/time.h @@ -12,7 +12,7 @@ #ifdef __NEWLIB__ /* Newever Newlib 3.x+ */ -#include +#include #else /* __NEWLIB__ */ /* Workaround for older Newlib 2.x, as used by Xtensa. It lacks sys/_timeval.h, * so mimic it here. @@ -29,6 +29,11 @@ struct timespec { long tv_nsec; }; +struct itimerspec { + struct timespec it_interval; /* Timer interval */ + struct timespec it_value; /* Timer expiration */ +}; + #ifdef __cplusplus } #endif @@ -38,33 +43,9 @@ struct timespec { #else /* CONFIG_NEWLIB_LIBC */ /* Not Newlib */ -#include +#include #endif /* CONFIG_NEWLIB_LIBC */ -/* Older newlib's like 2.{0-2}.0 don't define any newlib version defines, only - * __NEWLIB_H__ so we use that to decide if itimerspec was defined in - * sys/types.h w/o any protection. It appears sometime in the 2.3.0 version - * of newlib did itimerspec move out of sys/types.h, however version 2.3.0 - * seems to report itself as __NEWLIB_MINOR__ == 2, where as 2.2.0 doesn't - * even define __NEWLIB_MINOR__ or __NEWLIB__ - */ -#if !defined(__NEWLIB_H__) || (__NEWLIB__ >= 3) || \ - (__NEWLIB__ == 2 && __NEWLIB_MINOR__ >= 2) - -#ifdef __cplusplus -extern "C" { -#endif - -struct itimerspec { - struct timespec it_interval; /* Timer interval */ - struct timespec it_value; /* Timer expiration */ -}; -#ifdef __cplusplus -} -#endif - -#endif - #include #include #include "posix_types.h" diff --git a/lib/libc/minimal/include/sys/timespec.h b/lib/libc/minimal/include/sys/timespec.h new file mode 100644 index 0000000000..20e6fdbb5e --- /dev/null +++ b/lib/libc/minimal/include/sys/timespec.h @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2019 Linaro Limited + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_SYS_TIMESPEC_H_ +#define ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_SYS_TIMESPEC_H_ + +#include + +struct itimerspec { + struct timespec it_interval; /* Timer interval */ + struct timespec it_value; /* Timer expiration */ +}; + +#endif /* ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_SYS_TIMESPEC_H_ */