]> rtime.felk.cvut.cz Git - frescor/frsh-include.git/blobdiff - frsh_debug.h
flags moved
[frescor/frsh-include.git] / frsh_debug.h
index 0b909a3b43ec488d2daea36f2035c036d1c2b112..8de63720c1607a4ef27873ec01dc766e5093b7d9 100644 (file)
 // 23-Jul-2007 SANGORRIN: create this file for debugging functions
 // 31-Jul-2007 TELLERIA:  Change "debug" for "trace"
 // -----------------------------------------------------------------------
+#ifndef FRSH_DEBUG_H
+#define FRSH_DEBUG_H
+
 #include <stdio.h> // for vprintf
 #include <stdbool.h> // for bool
 #include <stdarg.h> // for va_list, va_start and va_end
+#include "timespec_operations.h"
+#include "fosa_configuration_parameters.h" /* FOSA_CLOCK_REALTIME */
 
 // Tune the following FLAGS to select the debugging messages to be generated
 #define FRSH_TRACE_CALLBACKS false
+#define FRSH_TRACE_SERVICE_TH false
 #define FRSH_TRACE_WATCHDOG false
 #define FRSH_TRACE_TIMEDWAIT false
-#define FRSH_TRACE_SERVICE_TH false
 #define FRSH_TRACE_SPORADIC_SERVER false
 #define FRSH_TRACE_ROUND_ROBIN false
 
 #define FRSH_TRACE_THREAD_INDEX false
 #define FRSH_TRACE_VRES_INDEX false
 
+#define FRSH_TRACE_DISTRIBUTED false
+
+#define FRSH_TRACE_TS_MSECS
+
+/* These variables live defined in frsh_error.c */
+/************************************************/
+extern struct timespec frsh_trace_init_timespec;
+extern long frsh_trace_init_timemsec;
+
+static inline long int FRSH_GET_TIMESTAMP_MSECS()
+{
+    int terror = -1;
+    struct timespec current_time = {-1, -1};
+    long int current_time_msec = -1;
+    long int result = -1;
+
+    PRW(  fosa_clock_get_time(FOSA_CLOCK_REALTIME, &current_time)  );
+    timespec2msec(&current_time, &current_time_msec);
+
+    result = current_time_msec - frsh_trace_init_timemsec;
+
+    return result;
+}
+
 static void inline FRSH_TRACE(bool is_active, const char *format, ...)
 {
     va_list args;
 
+#ifdef FRSH_TRACE_TS_MSECS
+    const int TS_LENGTH_MSECS = 10; /* Room for LONG_MAX 2147483648 */
+#endif
+
     if (is_active) {
+
         va_start(args, format);
+
+#ifdef FRSH_TRACE_TS_MSECS
+        printf("%*ld: ", TS_LENGTH_MSECS, FRSH_GET_TIMESTAMP_MSECS());
+#endif
         vprintf(format, args);
         va_end(args);
     }
 }
+
+#endif