Paste: log monotonic counter decreases

Author: j
Mode: c++
Date: Sun, 1 Aug 2010 20:34:40
Plain Text |
diff --git a/vm/os-unix.hpp b/vm/os-unix.hpp
index 54e9d06..3d7a0ac 100644
--- a/vm/os-unix.hpp
+++ b/vm/os-unix.hpp
@@ -28,6 +28,7 @@ typedef char symbol_char;
 #define FSEEK fseeko
 
 #define CELL_HEX_FORMAT "%lx"
+#define U64_HEX_FORMAT "%llx"
 
 #define OPEN_READ(path) fopen(path,"rb")
 #define OPEN_WRITE(path) fopen(path,"wb")
diff --git a/vm/os-windows.hpp b/vm/os-windows.hpp
index ad8a990..2d873d7 100755
--- a/vm/os-windows.hpp
+++ b/vm/os-windows.hpp
@@ -36,6 +36,7 @@ typedef wchar_t vm_char;
 #else
        #define CELL_HEX_FORMAT "%lx"
 #endif
+#define U64_HEX_FORMAT "%I64x"
 
 #define OPEN_READ(path) _wfopen((path),L"rb")
 #define OPEN_WRITE(path) _wfopen((path),L"wb")
diff --git a/vm/run.cpp b/vm/run.cpp
index 605fd9b..b0c9e36 100755
--- a/vm/run.cpp
+++ b/vm/run.cpp
@@ -11,7 +11,14 @@ void factor_vm::primitive_exit()
 void factor_vm::primitive_nano_count()
 {
        u64 nanos = nano_count();
-       if(nanos < last_nano_count) critical_error("Monotonic counter decreased",0);
+       if(nanos < last_nano_count) {
+            char monotonic_error_buf[200];
+            snprintf(monotonic_error_buf, 200,
+                "Monotonic counter decreased from 0x" U64_HEX_FORMAT " to 0x" U64_HEX_FORMAT,
+                last_nano_count, nanos
+            );
+            critical_error(monotonic_error_buf, 0);
+        }

New Annotation

Summary:
Author:
Mode:
Body: