]> gitweb.factorcode.org Git - factor.git/blobdiff - vm/os-windows.hpp
Squashed commit of the following:
[factor.git] / vm / os-windows.hpp
index 03dec4bb0288e38df3ffce11116176922f94a40f..79f3e0d0aab31f71e03a1b76669c1607ae4aad33 100755 (executable)
@@ -5,10 +5,30 @@
        #include <wchar.h>
 #endif
 
+#undef _WIN32_WINNT
+#define _WIN32_WINNT 0x0501  // For AddVectoredExceptionHandler
+
+#ifndef UNICODE
+#define UNICODE
+#endif
+
+#include <windows.h>
+#include <shellapi.h>
+
+#ifdef _MSC_VER
+       #undef min
+       #undef max
+#endif
+
+/* Difference between Jan 1 00:00:00 1601 and Jan 1 00:00:00 1970 */
+#define EPOCH_OFFSET 0x019db1ded53e8000LL
+
 namespace factor
 {
 
 typedef wchar_t vm_char;
+typedef char symbol_char;
+typedef HANDLE THREADHANDLE;
 
 #define STRING_LITERAL(string) L##string
 
@@ -29,17 +49,30 @@ typedef wchar_t vm_char;
        #define SNPRINTF snprintf
 #endif
 
+#define FACTOR_OS_STRING "winnt"
+
+#define FACTOR_DLL NULL
+
+// SSE traps raise these exception codes, which are defined in internal NT headers
+// but not winbase.h
+#ifndef STATUS_FLOAT_MULTIPLE_FAULTS
+#define STATUS_FLOAT_MULTIPLE_FAULTS 0xC00002B4
+#endif
+
+#ifndef STATUS_FLOAT_MULTIPLE_TRAPS
+#define STATUS_FLOAT_MULTIPLE_TRAPS  0xC00002B5
+#endif
+
 #define OPEN_READ(path) _wfopen((path),L"rb")
 #define OPEN_WRITE(path) _wfopen((path),L"wb")
 
-/* Difference between Jan 1 00:00:00 1601 and Jan 1 00:00:00 1970 */
-#define EPOCH_OFFSET 0x019db1ded53e8000LL
-
 inline static void early_init() {}
-
 u64 nano_count();
 void sleep_nanos(u64 nsec);
 long getpagesize();
 void move_file(const vm_char *path1, const vm_char *path2);
+VM_C_API LONG exception_handler(PEXCEPTION_RECORD e, void *frame, PCONTEXT c, void *dispatch);
+THREADHANDLE start_thread(void *(*start_routine)(void *),void *args);
+inline static THREADHANDLE thread_id() { return GetCurrentThread(); }
 
 }