// FOSA(Frescor Operating System Adaptation layer)
//================================================
+#include "fosa_time.h"
#include "fosa_clocks_and_timers.h"
/*************************
* Timing: Clocks
*************************/
+/**
+ * fosa_get_time()
+ *
+ * Get the time from a clock
+ *
+ * This function sets the variable pointed to by current_time to the
+ * current value of the clock specified by clockid, which may be the
+ * FOSA_CLOCK_REALTIME constant or a value obtained with
+ * fosa_get_cputime_clock()
+ *
+ * Returns 0 if successful; otherwise it returns an error code:
+ * EINVAL: the value of clockid is invalid
+ **/
int fosa_clock_get_time(fosa_clock_id_t clockid,
- struct timespec *current_time)
+ fosa_abs_time_t *current_time)
{
- return clock_gettime(clockid, current_time);
+ int error;
+ struct timespec current_time_tspec;
+
+ if ((error = clock_gettime(clockid, ¤t_time_tspec)) != 0)
+ return error;
+
+ *current_time = fosa_timespec_to_abs_time(current_time_tspec);
+
+ return 0;
}
+/**
+ * fosa_get_cputime_clock()
+ *
+ * Get the identifier of a cpu-time clock
+ *
+ * This function stores in the variable pointed to by clockid the
+ * identifier of a cpu-time clock for the thread specified by tid.
+ *
+ * Returns 0 if successful; otherwise it returns an error code:
+ * EINVAL: the value of tid is invalid
+ **/
int fosa_thread_get_cputime_clock(fosa_thread_id_t tid,
fosa_clock_id_t *clockid)
{
return ENOSYS;
}
- /**
- * Delete a timer
- *
- * The function deletes the timer specified by timerid, which becomes
- * unusable. If the timer was armed, it is automatically disarmed before
- * deletion.
- *
- * Returns 0 if successful; otherwise it returns an error code:
- * EINVAL: the value of timerid is not valid
- **/
+/**
+ * Delete a timer
+ *
+ * The function deletes the timer specified by timerid, which becomes
+ * unusable. If the timer was armed, it is automatically disarmed before
+ * deletion.
+ *
+ * Returns 0 if successful; otherwise it returns an error code:
+ * EINVAL: the value of timerid is not valid
+ **/
int fosa_timer_delete(fosa_timer_id_t timerid)
{
return timer_delete(timerid);
**/
int fosa_timer_arm (fosa_timer_id_t timerid,
bool abstime,
- const struct timespec *value)
+ const fosa_abs_time_t *value)
{
struct itimerspec when;
/* non-periodic one shot timer configuration */
- when.it_value = *value;
+ when.it_value = fosa_abs_time_to_timespec(*value);
when.it_interval.tv_sec = 0;
when.it_interval.tv_nsec = 0;
* EINVAL: the value of timerid or value is invalid
**/
int fosa_timer_get_remaining_time(fosa_timer_id_t timerid,
- struct timespec *remaining_time)
+ fosa_rel_time_t *remaining_time)
{
int error;
struct itimerspec time;
if ((error = timer_gettime(timerid, &time)) == -1)
return error;
- *remaining_time = time.it_value;
+ *remaining_time = fosa_timespec_to_rel_time(time.it_value);
} else
return EINVAL;
if ((error = timer_gettime(timerid, &time)) == -1)
return error;
- *remaining_time = time.it_value;
+ *remaining_time = fosa_timespec_to_rel_time(time.it_value);
}
time.it_value.tv_sec = 0;