clock: Add new type ssystime_t for relative 64-bit ticks, change ticks<->time conversion functions to use ssystime_t

This commit is contained in:
Jussi Kivilinna
2017-04-21 08:51:31 -06:00
committed by Gregory Nutt
parent 325ba1a803
commit c57d49f420
16 changed files with 48 additions and 28 deletions
+4 -3
View File
@@ -98,9 +98,10 @@ void weak_function clock_timer(void);
int clock_abstime2ticks(clockid_t clockid,
FAR const struct timespec *abstime,
FAR int *ticks);
int clock_time2ticks(FAR const struct timespec *reltime, FAR int *ticks);
int clock_ticks2time(int ticks, FAR struct timespec *reltime);
FAR ssystime_t *ticks);
int clock_time2ticks(FAR const struct timespec *reltime,
FAR ssystime_t *ticks);
int clock_ticks2time(ssystime_t ticks, FAR struct timespec *reltime);
void clock_timespec_add(FAR const struct timespec *ts1,
FAR const struct timespec *ts2,
FAR struct timespec *ts3);
+1 -1
View File
@@ -99,7 +99,7 @@ static long compare_timespec(FAR const struct timespec *a,
****************************************************************************/
int clock_abstime2ticks(clockid_t clockid, FAR const struct timespec *abstime,
FAR int *ticks)
FAR ssystime_t *ticks)
{
struct timespec currtime;
struct timespec reltime;
+2 -2
View File
@@ -63,9 +63,9 @@
*
****************************************************************************/
int clock_ticks2time(int ticks, FAR struct timespec *reltime)
int clock_ticks2time(ssystime_t ticks, FAR struct timespec *reltime)
{
int remainder;
ssystime_t remainder;
reltime->tv_sec = ticks / TICK_PER_SEC;
remainder = ticks - TICK_PER_SEC * reltime->tv_sec;
+4 -3
View File
@@ -67,7 +67,8 @@
*
****************************************************************************/
int clock_time2ticks(FAR const struct timespec *reltime, FAR int *ticks)
int clock_time2ticks(FAR const struct timespec *reltime,
FAR ssystime_t *ticks)
{
#ifdef CONFIG_HAVE_LONG_LONG
int64_t relnsec;
@@ -83,7 +84,7 @@ int clock_time2ticks(FAR const struct timespec *reltime, FAR int *ticks)
* that is greater than or equal to the exact number of tick.
*/
*ticks = (int)((relnsec + NSEC_PER_TICK - 1) / NSEC_PER_TICK);
*ticks = (ssystime_t)((relnsec + NSEC_PER_TICK - 1) / NSEC_PER_TICK);
return OK;
#else
int32_t relusec;
@@ -110,7 +111,7 @@ int clock_time2ticks(FAR const struct timespec *reltime, FAR int *ticks)
* that is greater than or equal to the exact number of tick.
*/
*ticks = (int)((relusec + USEC_PER_TICK - 1) / USEC_PER_TICK);
*ticks = (ssystime_t)((relusec + USEC_PER_TICK - 1) / USEC_PER_TICK);
return OK;
#endif
}