final revision to GArrow classes
[ghc-base.git] / cbits / Win32Utils.c
index 942b2c4..fd4d1eb 100644 (file)
@@ -61,7 +61,10 @@ static struct errentry errtable[] = {
         {  ERROR_ALREADY_EXISTS,         EEXIST    },  /* 183 */
         {  ERROR_FILENAME_EXCED_RANGE,   ENOENT    },  /* 206 */
         {  ERROR_NESTING_NOT_ALLOWED,    EAGAIN    },  /* 215 */
-        {  ERROR_NOT_ENOUGH_QUOTA,       ENOMEM    }    /* 1816 */
+           /* Windows returns this when the read end of a pipe is
+            * closed (or closing) and we write to it. */
+        {  ERROR_NO_DATA,                EPIPE     },  /* 232 */
+        {  ERROR_NOT_ENOUGH_QUOTA,       ENOMEM    }  /* 1816 */
 };
 
 /* size of the table */
@@ -107,18 +110,16 @@ void maperrno (void)
                        errno = EINVAL;
 }
 
-#define TICKS_PER_SECOND 50
-// must match GHC.Conc.tick_freq
-
-HsInt getTicksOfDay(void)
+HsWord64 getUSecOfDay(void)
 {
-    HsInt64 t;
+    HsWord64 t;
     FILETIME ft;
     GetSystemTimeAsFileTime(&ft);
-    t = ((HsInt64)ft.dwHighDateTime << 32) | ft.dwLowDateTime;
-    t = (t * TICKS_PER_SECOND) / 10000000LL;
-      /* FILETIMES are in units of 100ns */
-    return (HsInt)t;
+    t = ((HsWord64)ft.dwHighDateTime << 32) | ft.dwLowDateTime;
+    t = t / 10LL;
+    /* FILETIMES are in units of 100ns,
+       so we divide by 10 to get microseconds */
+    return t;
 }
 
 #endif