lib: posix, minlibc: struct itimerspec is defined by sys/timespec.h
Newlib has it defined in sys/timespec.h, and thus per the established conventions, everything else relies on it being there. Specifically, minimal libc acquires sys/timespec.h with a similar definition, and POSIX headers rely on that header. Still with a workaround for old Newlib version as used by Xtensa (but all infrastructure for that is already there; actually, this patch removes duplicate similar-infra, which apparently didn't work as expected by now, so now we have a single workaround, not 2 different once). To emphasize a point, now there 2 headers: sys/_timespec.h, defining struct timespec, and sys/timespec.h, defining struct itimerspec That's how Newlib has it, and what we faithfully embrace and follow, because otherwise, there will be header conflicts depending on various libc and POSIX subsys options. Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
This commit is contained in:
parent
ae5a7bb579
commit
0173d86e6f
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
#ifdef __NEWLIB__
|
#ifdef __NEWLIB__
|
||||||
/* Newever Newlib 3.x+ */
|
/* Newever Newlib 3.x+ */
|
||||||
#include <sys/_timespec.h>
|
#include <sys/timespec.h>
|
||||||
#else /* __NEWLIB__ */
|
#else /* __NEWLIB__ */
|
||||||
/* Workaround for older Newlib 2.x, as used by Xtensa. It lacks sys/_timeval.h,
|
/* Workaround for older Newlib 2.x, as used by Xtensa. It lacks sys/_timeval.h,
|
||||||
* so mimic it here.
|
* so mimic it here.
|
||||||
|
@ -29,6 +29,11 @@ struct timespec {
|
||||||
long tv_nsec;
|
long tv_nsec;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct itimerspec {
|
||||||
|
struct timespec it_interval; /* Timer interval */
|
||||||
|
struct timespec it_value; /* Timer expiration */
|
||||||
|
};
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -38,33 +43,9 @@ struct timespec {
|
||||||
|
|
||||||
#else /* CONFIG_NEWLIB_LIBC */
|
#else /* CONFIG_NEWLIB_LIBC */
|
||||||
/* Not Newlib */
|
/* Not Newlib */
|
||||||
#include <sys/_timespec.h>
|
#include <sys/timespec.h>
|
||||||
#endif /* CONFIG_NEWLIB_LIBC */
|
#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 <kernel.h>
|
#include <kernel.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "posix_types.h"
|
#include "posix_types.h"
|
||||||
|
|
17
lib/libc/minimal/include/sys/timespec.h
Normal file
17
lib/libc/minimal/include/sys/timespec.h
Normal file
|
@ -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 <sys/_timespec.h>
|
||||||
|
|
||||||
|
struct itimerspec {
|
||||||
|
struct timespec it_interval; /* Timer interval */
|
||||||
|
struct timespec it_value; /* Timer expiration */
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* ZEPHYR_LIB_LIBC_MINIMAL_INCLUDE_SYS_TIMESPEC_H_ */
|
Loading…
Reference in a new issue