Move timespec calculations from sched into libc/sched
Allow using these functions also outside sched, where systick related calculations are performed Signed-off-by: Jukka Laitinen <jukkax@ssrc.tii.ae>
This commit is contained in:
parent
2d125d33d3
commit
c79d2067c7
@ -394,6 +394,51 @@ void clock_resynchronize(FAR struct timespec *rtc_diff);
|
||||
clock_t clock_systime_ticks(void);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: clock_time2ticks
|
||||
*
|
||||
* Description:
|
||||
* Return the given struct timespec as systime ticks.
|
||||
*
|
||||
* NOTE: This is an internal OS interface and should not be called from
|
||||
* application code.
|
||||
*
|
||||
* Input Parameters:
|
||||
* reltime - Pointer to the time presented as struct timespec
|
||||
*
|
||||
* Output Parameters:
|
||||
* ticks - Pointer to receive the time value presented as systime ticks
|
||||
*
|
||||
* Returned Value:
|
||||
* Always returns OK (0)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int clock_time2ticks(FAR const struct timespec *reltime,
|
||||
FAR sclock_t *ticks);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: clock_ticks2time
|
||||
*
|
||||
* Description:
|
||||
* Return the given systime ticks as a struct timespec.
|
||||
*
|
||||
* NOTE: This is an internal OS interface and should not be called from
|
||||
* application code.
|
||||
*
|
||||
* Input Parameters:
|
||||
* ticks - Time presented as systime ticks
|
||||
*
|
||||
* Output Parameters:
|
||||
* reltime - Pointer to receive the time value presented as struct timespec
|
||||
*
|
||||
* Returned Value:
|
||||
* Always returns OK (0)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int clock_ticks2time(sclock_t ticks, FAR struct timespec *reltime);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: clock_systime_timespec
|
||||
*
|
||||
|
@ -21,6 +21,8 @@
|
||||
# Add the sched C files to the build
|
||||
|
||||
CSRCS += sched_getprioritymax.c sched_getprioritymin.c
|
||||
CSRCS += clock_ticks2time.c clock_time2ticks.c
|
||||
CSRCS += clock_timespec_add.c clock_timespec_subtract.c
|
||||
|
||||
ifneq ($(CONFIG_CANCELLATION_POINTS),y)
|
||||
CSRCS += task_setcanceltype.c task_testcancel.c
|
||||
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* sched/clock/clock_ticks2time.c
|
||||
* libs/libc/sched/clock_ticks2time.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
@ -25,7 +25,7 @@
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <time.h>
|
||||
#include "clock/clock.h"
|
||||
#include <nuttx/clock.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* sched/clock/clock_time2ticks.c
|
||||
* libs/libc/sched/clock_time2ticks.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
@ -28,7 +28,7 @@
|
||||
#include <time.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "clock/clock.h"
|
||||
#include <nuttx/clock.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* sched/clock/clock_timespec_add.c
|
||||
* libs/libc/sched/clock_timespec_add.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
@ -27,7 +27,7 @@
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "clock/clock.h"
|
||||
#include <nuttx/clock.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* sched/clock/clock_timespec_subtract.c
|
||||
* libs/libc/sched/clock_timespec_subtract.c
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
@ -27,7 +27,7 @@
|
||||
#include <stdint.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "clock/clock.h"
|
||||
#include <nuttx/clock.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
@ -19,9 +19,9 @@
|
||||
############################################################################
|
||||
|
||||
CSRCS += clock_initialize.c clock_settime.c clock_gettime.c clock_getres.c
|
||||
CSRCS += clock_time2ticks.c clock_abstime2ticks.c clock_ticks2time.c
|
||||
CSRCS += clock_systime_ticks.c clock_systime_timespec.c clock_timespec_add.c
|
||||
CSRCS += clock_timespec_subtract.c clock.c
|
||||
CSRCS += clock_abstime2ticks.c
|
||||
CSRCS += clock_systime_ticks.c clock_systime_timespec.c
|
||||
CSRCS += clock.c
|
||||
|
||||
ifeq ($(CONFIG_CLOCK_TIMEKEEPING),y)
|
||||
CSRCS += clock_timekeeping.c
|
||||
|
@ -84,8 +84,5 @@ void weak_function clock_timer(void);
|
||||
int clock_abstime2ticks(clockid_t clockid,
|
||||
FAR const struct timespec *abstime,
|
||||
FAR sclock_t *ticks);
|
||||
int clock_time2ticks(FAR const struct timespec *reltime,
|
||||
FAR sclock_t *ticks);
|
||||
int clock_ticks2time(sclock_t ticks, FAR struct timespec *reltime);
|
||||
|
||||
#endif /* __SCHED_CLOCK_CLOCK_H */
|
||||
|
Loading…
Reference in New Issue
Block a user