+/**
+ * fosa_timer_get_remaining_time()
+ *
+ * Get the remaining time for timer expiration
+ *
+ * Returns the relative remaining time for timer expiration. If the
+ * clock is a CPU clock it returns the time as if the thread was
+ * executing constantly.
+ *
+ * If the timer is disarmed it returns 0.
+ *
+ * Returns 0 if successful; otherwise it returns an error code:
+ * EINVAL: the value of timerid or value is invalid
+ *
+ * Alternatively, in case of error the implementation is allowed to
+ * notify it to the system console and then terminate the FRSH
+ * implementation and dependant applications
+ **/
+int fosa_timer_get_remaining_time
+ (fosa_timer_id_t timerid, struct timespec *remaining_time)
+{
+ struct itimerspec timer_value;
+ int error_code;
+
+ if (remaining_time!=NULL) {
+ error_code=timer_gettime(timerid,&timer_value);
+ if (error_code==-1) return errno;
+ *remaining_time=timer_value.it_value;
+ } else {
+ return EINVAL;
+ }
+ return 0;
+}
+