]> gitweb.factorcode.org Git - factor.git/commitdiff
vm: disable silly nano-count workaround on Win64, fix some indentation issues
authorSlava Pestov <slava@factorcode.org>
Sat, 6 Feb 2010 06:45:06 +0000 (00:45 -0600)
committerSlava Pestov <slava@factorcode.org>
Sat, 6 Feb 2010 06:45:29 +0000 (00:45 -0600)
vm/io.cpp
vm/os-windows-nt.cpp
vm/os-windows.cpp

index ae27b5a3d86298585095c40a07e06b3f8b838f72..8eaaa453b5015be9898222177c3d354621ae1366 100755 (executable)
--- a/vm/io.cpp
+++ b/vm/io.cpp
@@ -154,7 +154,7 @@ void factor_vm::primitive_fopen()
 
        FILE *file;
        file = safe_fopen((char *)(path.untagged() + 1),
-                                               (char *)(mode.untagged() + 1));
+               (char *)(mode.untagged() + 1));
        ctx->push(allot_alien(file));
 }
 
@@ -187,31 +187,24 @@ void factor_vm::primitive_fread()
 
        data_root<byte_array> buf(allot_uninitialized_array<byte_array>(size),this);
 
-       for(;;)
+       int c = safe_fread(buf.untagged() + 1,1,size,file);
+       if(c == 0)
        {
-               int c = safe_fread(buf.untagged() + 1,1,size,file);
-               if(c == 0)
-               {
-                       if(feof(file))
-                       {
-                               ctx->push(false_object);
-                               break;
-                       }
-                       else
-                               io_error();
-               }
+               if(feof(file))
+                       ctx->push(false_object);
                else
+                       io_error();
+       }
+       else
+       {
+               if(feof(file))
                {
-                       if(feof(file))
-                       {
-                               byte_array *new_buf = allot_byte_array(c);
-                               memcpy(new_buf + 1, buf.untagged() + 1,c);
-                               buf = new_buf;
-                       }
-
-                       ctx->push(buf.value());
-                       break;
+                       byte_array *new_buf = allot_byte_array(c);
+                       memcpy(new_buf + 1, buf.untagged() + 1,c);
+                       buf = new_buf;
                }
+
+               ctx->push(buf.value());
        }
 }
 
index cf5878e5bfb27eca79ebc97186259606610b6dbc..644ff83b442653cf3e9dd7216229c2cb7a5a827f 100755 (executable)
@@ -37,8 +37,6 @@ u64 system_micros()
                - EPOCH_OFFSET) / 10;
 }
 
-/* On VirtualBox, QueryPerformanceCounter does not increment
-the high part every time the low part overflows.  Workaround. */
 u64 nano_count()
 {
        LARGE_INTEGER count;
@@ -53,8 +51,14 @@ u64 nano_count()
        if(ret == 0)
                fatal_error("QueryPerformanceFrequency", 0);
 
-       if(count.LowPart < lo)
-               hi += 1;
+#ifdef FACTOR_64
+       hi = count.HighPart;
+#else
+       /* On VirtualBox, QueryPerformanceCounter does not increment
+       the high part every time the low part overflows.  Workaround. */
+       if(lo > count.LowPart)
+               hi++;
+#endif
        lo = count.LowPart;
 
        return (u64)((((u64)hi << 32) | (u64)lo)*(1000000000.0/frequency.QuadPart));
@@ -91,7 +95,7 @@ LONG factor_vm::exception_handler(PEXCEPTION_POINTERS pe)
        case STATUS_FLOAT_UNDERFLOW:
        case STATUS_FLOAT_MULTIPLE_FAULTS:
        case STATUS_FLOAT_MULTIPLE_TRAPS:
-#ifdef FACTOR_AMD64
+#ifdef FACTOR_64
                signal_fpu_status = fpu_status(MXCSR(c));
 #else
                signal_fpu_status = fpu_status(X87SW(c) | MXCSR(c));
index a6914a9f70a97b8e048e274d02ecfb7f2a0b6742..08f59321725f63cb0d1224b16a8d81c051a648d3 100755 (executable)
@@ -128,7 +128,7 @@ segment::~segment()
 long getpagesize()
 {
        static long g_pagesize = 0;
-       if (! g_pagesize)
+       if(!g_pagesize)
        {
                SYSTEM_INFO system_info;
                GetSystemInfo (&system_info);
@@ -139,7 +139,7 @@ long getpagesize()
 
 void factor_vm::move_file(const vm_char *path1, const vm_char *path2)
 {
-    if(MoveFileEx((path1),(path2),MOVEFILE_REPLACE_EXISTING) == false)
+       if(MoveFileEx((path1),(path2),MOVEFILE_REPLACE_EXISTING) == false)
                general_error(ERROR_IO,tag_fixnum(GetLastError()),false_object,NULL);
 }