From 9750c3461c345d084c7a61ea2ba3015e4c9b8f77 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fredrik=20H=C3=BCbinette=20=28Hubbe=29?= <hubbe@hubbe.net>
Date: Fri, 20 Nov 1998 10:38:46 -0800
Subject: [PATCH] more debug

Rev: src/interpret.c:1.108
Rev: src/threads.h:1.57
---
 src/interpret.c |  8 +++++++-
 src/threads.h   | 12 +++++++++++-
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/src/interpret.c b/src/interpret.c
index 09b9cfc198..148dac6a21 100644
--- a/src/interpret.c
+++ b/src/interpret.c
@@ -4,7 +4,7 @@
 ||| See the files COPYING and DISCLAIMER for more information.
 \*/
 #include "global.h"
-RCSID("$Id: interpret.c,v 1.107 1998/11/20 08:38:12 hubbe Exp $");
+RCSID("$Id: interpret.c,v 1.108 1998/11/20 18:38:44 hubbe Exp $");
 #include "interpret.h"
 #include "object.h"
 #include "program.h"
@@ -1808,6 +1808,12 @@ void mega_apply(enum apply_type type, INT32 args, void *arg1, void *arg2)
   long long children_base = accounted_time;
   long long start_time = gethrtime() - time_base;
   unsigned INT32 self_time_base;
+  if(start_time < 0)
+  {
+    fatal("gethrtime() shrunk\n start_time=%ld\n time_base=%ld\n",
+	  (long)(start_time/100000), 
+	  (long)(time_base/100000));
+  }
 #endif
 #endif
 
diff --git a/src/threads.h b/src/threads.h
index 098c5a6512..89af21e376 100644
--- a/src/threads.h
+++ b/src/threads.h
@@ -1,5 +1,5 @@
 /*
- * $Id: threads.h,v 1.56 1998/11/20 08:18:54 hubbe Exp $
+ * $Id: threads.h,v 1.57 1998/11/20 18:38:46 hubbe Exp $
  */
 #ifndef THREADS_H
 #define THREADS_H
@@ -350,6 +350,12 @@ struct thread_state {
 #define DO_IF_PROFILING(X)
 #endif
 
+#ifdef DEBUG
+#define DO_IF_DEBUG(X) X
+#else
+#define DO_IF_DEBUG(X)
+#endif
+
 #define SWAP_OUT_THREAD(_tmp) do { \
        (_tmp)->swapped=1; \
        (_tmp)->evaluator_stack=evaluator_stack;\
@@ -364,6 +370,8 @@ struct thread_state {
        (_tmp)->thread_id=thread_id;\
        DO_IF_PROFILING( (_tmp)->accounted_time=accounted_time; ) \
        DO_IF_PROFILING( (_tmp)->time_base = gethrtime() - time_base; ) \
+       DO_IF_DEBUG( DO_IF_PROFILING( if(accounted_time<0) fatal("Accounted time out of whack!\n");)) \
+       DO_IF_DEBUG( DO_IF_PROFILING( if((_tmp)->time_base<0) fatal("time base out of whack!\n");)) \
        SWAP_OUT_TRACE(_tmp); \
       } while(0)
 
@@ -381,6 +389,8 @@ struct thread_state {
        thread_id=(_tmp)->thread_id;\
        DO_IF_PROFILING( accounted_time=(_tmp)->accounted_time; ) \
        DO_IF_PROFILING(  time_base = (_tmp)->time_base + gethrtime(); ) \
+       DO_IF_DEBUG( DO_IF_PROFILING( if(accounted_time<0) fatal("Accounted time out of whack!\n");)) \
+       DO_IF_DEBUG( DO_IF_PROFILING( if(time_base<0) fatal("time base out of whack!\n");)) \
        SWAP_IN_TRACE(_tmp); \
      } while(0)
 
-- 
GitLab