From 3a4553913e8f7abc895a91b1503e95ec38634715 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Wed, 5 Jun 2019 09:06:08 +0300 Subject: [PATCH] posix: struct timespec: Move definition to sys/_timespec.h POSIX subsys defines struct timespec in (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 --- include/posix/time.h | 9 +-------- lib/libc/minimal/include/sys/_timespec.h | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 lib/libc/minimal/include/sys/_timespec.h diff --git a/include/posix/time.h b/include/posix/time.h index 2838399cd64..169bd73d7d8 100644 --- a/include/posix/time.h +++ b/include/posix/time.h @@ -10,14 +10,7 @@ extern "C" { #endif - -#ifndef __timespec_defined -#define __timespec_defined -struct timespec { - signed int tv_sec; - signed int tv_nsec; -}; -#endif +#include /* 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 diff --git a/lib/libc/minimal/include/sys/_timespec.h b/lib/libc/minimal/include/sys/_timespec.h new file mode 100644 index 00000000000..5e8364c7726 --- /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 timespec { + time_t tv_sec; + long tv_nsec; +}; + +#endif /* ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_SYS__TIMESPEC_H_ */