]> rtime.felk.cvut.cz Git - frescor/frsh-include.git/blobdiff - frsh_debug_and_trace.h
Adding frsh_usec_to_rel_time()
[frescor/frsh-include.git] / frsh_debug_and_trace.h
index ad03ff431c832c4d191679bd689656d12dd35c31..bcb2be375fe5774d7abef1db2b87449a844d7ece 100644 (file)
 #include <stdio.h> // for vprintf
 #include <stdbool.h> // for bool
 #include <stdarg.h> // for va_list, va_start and va_end
+#include "fosa.h"
 #include "frsh_debug_and_trace_types.h"
-#include "timespec_operations.h"
 #include "fosa_configuration_parameters.h" /* FOSA_CLOCK_REALTIME */
 #include "fosa_clocks_and_timers.h"
 
+FRSH_CPP_BEGIN_DECLS
+
 // Tune the following FLAGS to select the debugging messages to be generated
 #define FRSH_TRACE_CALLBACKS false
 #define FRSH_TRACE_SERVICE_TH false
@@ -115,7 +117,7 @@ int frsh_trace_point_insert(frsh_trace_point_id_t ipoint);
 
 /* These variables live defined in frsh_error.c */
 /************************************************/
-extern struct timespec frsh_trace_init_timespec;
+extern fosa_abs_time_t frsh_trace_init_timespec;
 extern long frsh_trace_init_timemsec;
 
 extern int global_error_condition;  /* Used to propagate error
@@ -124,23 +126,23 @@ extern int global_error_condition;  /* Used to propagate error
 static inline long int FRSH_GET_TIMESTAMP_MSECS()
 {
     int terror = -1;
-    struct timespec current_time = {-1, -1};
+    fosa_abs_time_t current_time;
     long int current_time_msec = -1;
     long int result = -1;
 
     PRW(  fosa_clock_get_time(FOSA_CLOCK_REALTIME, &current_time)  );
-    current_time_msec = timespec2msec(&current_time);
+    current_time_msec = fosa_abs_time_to_msec(current_time);
 
     result = current_time_msec - frsh_trace_init_timemsec;
 
     return result;
 }
 
-static inline long int FRSH_TIMESPEC_TO_RELATIVE_MSECS(const struct timespec *tspec)
+static inline long int FRSH_TIMESTAMP_TO_RELATIVE_MSECS(const fosa_abs_time_t *timestamp)
 {
     long int time_msecs = -1;
 
-    time_msecs = timespec2msec(tspec);
+    time_msecs = fosa_abs_time_to_msec(*timestamp);
 
     return time_msecs - frsh_trace_init_timemsec;
 }
@@ -158,4 +160,6 @@ static inline long int FRSH_TIMESPEC_TO_RELATIVE_MSECS(const struct timespec *ts
  **/
 void FRSH_TRACE(bool is_active, const char *format, ...);
 
+FRSH_CPP_END_DECLS
+
 #endif