The POSIX_CLOCK option does not correspond to any standard option. It was used to active features of several distinct POSIX Options and Option Groups, which complicated API and application configuration as a result. POSIX_CLOCK is being deprecated in order to ensure that Zephyr's POSIX Kconfig variables correspond to those defined in the specification, as of IEEE 1003.1-2017. Additionally, CONFIG_TIMER is being deprecated because it does not match the corresponding POSIX Option (_POSIX_TIMERS). With this deprecation, we introduce the following Kconfig options that map directly to standard POSIX Option Groups by simply removing "CONFIG_": * CONFIG_POSIX_TIMERS Similarly, we introduce the following Kconfig options that map directly to standard POSIX Options by simply removing "CONFIG": * CONFIG_POSIX_CLOCK_SELECTION * CONFIG_POSIX_CPUTIME * CONFIG_POSIX_DELAYTIMER_MAX * CONFIG_POSIX_MONOTONIC_CLOCK * CONFIG_POSIX_TIMEOUTS * CONFIG_POSIX_TIMER_MAX In order to maintain parity with the current feature set, we introduce the following Kconfig options that map directly to standard POSIX Option Groups by simply removing "CONFIG_": * CONFIG_POSIX_MULTI_PROCESS - sleep() Similarly, in order to maintain parity with the current feature set, we introduce the following additional Kconfig options that map directly to standard POSIX Options by simply removing "CONFIG": * CONFIG_XSI_SINGLE_PROCESS - gettimeofday() Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
33 lines
853 B
C
33 lines
853 B
C
/*
|
|
* Copyright (c) 2017 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#include <zephyr/kernel.h>
|
|
#include <ksched.h>
|
|
#include <zephyr/posix/time.h>
|
|
|
|
#ifdef CONFIG_POSIX_TIMERS
|
|
int64_t timespec_to_timeoutms(const struct timespec *abstime)
|
|
{
|
|
int64_t milli_secs, secs, nsecs;
|
|
struct timespec curtime;
|
|
|
|
/* FIXME: Zephyr does have CLOCK_REALTIME to get time.
|
|
* As per POSIX standard time should be calculated wrt CLOCK_REALTIME.
|
|
* Zephyr deviates from POSIX 1003.1 standard on this aspect.
|
|
*/
|
|
clock_gettime(CLOCK_MONOTONIC, &curtime);
|
|
secs = abstime->tv_sec - curtime.tv_sec;
|
|
nsecs = abstime->tv_nsec - curtime.tv_nsec;
|
|
|
|
if (secs < 0 || (secs == 0 && nsecs < NSEC_PER_MSEC)) {
|
|
milli_secs = 0;
|
|
} else {
|
|
milli_secs = secs * MSEC_PER_SEC + nsecs / NSEC_PER_MSEC;
|
|
}
|
|
|
|
return milli_secs;
|
|
}
|
|
#endif /* CONFIG_POSIX_TIMERS */
|