Add WinCBindings.hsc, not WinCBindings.hs!
authorIan Lynagh <igloo@earth.li>
Sun, 20 Jan 2008 23:20:37 +0000 (23:20 +0000)
committerIan Lynagh <igloo@earth.li>
Sun, 20 Jan 2008 23:20:37 +0000 (23:20 +0000)
testsuite/timeout/WinCBindings.hs [deleted file]
testsuite/timeout/WinCBindings.hsc [new file with mode: 0644]

diff --git a/testsuite/timeout/WinCBindings.hs b/testsuite/timeout/WinCBindings.hs
deleted file mode 100644 (file)
index 1876726..0000000
+++ /dev/null
@@ -1,193 +0,0 @@
-{-# INCLUDE <windows.h> #-}\r
-{-# LINE 1 "WinCBindings.hsc" #-}\r
-{-# OPTIONS -cpp -fffi #-}\r
-{-# LINE 2 "WinCBindings.hsc" #-}\r
-\r
-module WinCBindings where\r
-\r
-\r
-{-# LINE 6 "WinCBindings.hsc" #-}\r
-\r
-import Foreign\r
-import System.Win32.File\r
-import System.Win32.Types\r
-\r
-\r
-{-# LINE 12 "WinCBindings.hsc" #-}\r
-\r
-type LPPROCESS_INFORMATION = Ptr PROCESS_INFORMATION\r
-data PROCESS_INFORMATION = PROCESS_INFORMATION\r
-    { piProcess :: HANDLE\r
-    , piThread :: HANDLE\r
-    , piProcessId :: DWORD\r
-    , piThreadId :: DWORD\r
-    } deriving Show\r
-\r
-instance Storable PROCESS_INFORMATION where\r
-    sizeOf = const (16)\r
-{-# LINE 23 "WinCBindings.hsc" #-}\r
-    alignment = sizeOf\r
-    poke buf pi = do\r
-        ((\hsc_ptr -> pokeByteOff hsc_ptr 0))    buf (piProcess   pi)\r
-{-# LINE 26 "WinCBindings.hsc" #-}\r
-        ((\hsc_ptr -> pokeByteOff hsc_ptr 4))     buf (piThread    pi)\r
-{-# LINE 27 "WinCBindings.hsc" #-}\r
-        ((\hsc_ptr -> pokeByteOff hsc_ptr 8)) buf (piProcessId pi)\r
-{-# LINE 28 "WinCBindings.hsc" #-}\r
-        ((\hsc_ptr -> pokeByteOff hsc_ptr 12))  buf (piThreadId  pi)\r
-{-# LINE 29 "WinCBindings.hsc" #-}\r
-\r
-    peek buf = do\r
-        vhProcess    <- ((\hsc_ptr -> peekByteOff hsc_ptr 0))    buf\r
-{-# LINE 32 "WinCBindings.hsc" #-}\r
-        vhThread     <- ((\hsc_ptr -> peekByteOff hsc_ptr 4))     buf\r
-{-# LINE 33 "WinCBindings.hsc" #-}\r
-        vdwProcessId <- ((\hsc_ptr -> peekByteOff hsc_ptr 8)) buf\r
-{-# LINE 34 "WinCBindings.hsc" #-}\r
-        vdwThreadId  <- ((\hsc_ptr -> peekByteOff hsc_ptr 12))  buf\r
-{-# LINE 35 "WinCBindings.hsc" #-}\r
-        return $ PROCESS_INFORMATION {\r
-            piProcess   = vhProcess,\r
-            piThread    = vhThread,\r
-            piProcessId = vdwProcessId,\r
-            piThreadId  = vdwThreadId}\r
-\r
-type LPSTARTUPINFO = Ptr STARTUPINFO\r
-data STARTUPINFO = STARTUPINFO\r
-    { siCb :: DWORD\r
-    , siDesktop :: LPTSTR\r
-    , siTitle :: LPTSTR\r
-    , siX :: DWORD\r
-    , siY :: DWORD\r
-    , siXSize :: DWORD\r
-    , siYSize :: DWORD\r
-    , siXCountChars :: DWORD\r
-    , siYCountChars :: DWORD\r
-    , siFillAttribute :: DWORD\r
-    , siFlags :: DWORD\r
-    , siShowWindow :: WORD\r
-    , siStdInput :: HANDLE\r
-    , siStdOutput :: HANDLE\r
-    , siStdError :: HANDLE\r
-    } deriving Show\r
-\r
-instance Storable STARTUPINFO where\r
-    sizeOf = const (68)\r
-{-# LINE 62 "WinCBindings.hsc" #-}\r
-    alignment = sizeOf\r
-    poke buf si = do\r
-        ((\hsc_ptr -> pokeByteOff hsc_ptr 0))              buf (siCb si)\r
-{-# LINE 65 "WinCBindings.hsc" #-}\r
-        ((\hsc_ptr -> pokeByteOff hsc_ptr 8))       buf (siDesktop si)\r
-{-# LINE 66 "WinCBindings.hsc" #-}\r
-        ((\hsc_ptr -> pokeByteOff hsc_ptr 12))         buf (siTitle si)\r
-{-# LINE 67 "WinCBindings.hsc" #-}\r
-        ((\hsc_ptr -> pokeByteOff hsc_ptr 16))             buf (siX si)\r
-{-# LINE 68 "WinCBindings.hsc" #-}\r
-        ((\hsc_ptr -> pokeByteOff hsc_ptr 20))             buf (siY si)\r
-{-# LINE 69 "WinCBindings.hsc" #-}\r
-        ((\hsc_ptr -> pokeByteOff hsc_ptr 24))         buf (siXSize si)\r
-{-# LINE 70 "WinCBindings.hsc" #-}\r
-        ((\hsc_ptr -> pokeByteOff hsc_ptr 28))         buf (siYSize si)\r
-{-# LINE 71 "WinCBindings.hsc" #-}\r
-        ((\hsc_ptr -> pokeByteOff hsc_ptr 32))   buf (siXCountChars si)\r
-{-# LINE 72 "WinCBindings.hsc" #-}\r
-        ((\hsc_ptr -> pokeByteOff hsc_ptr 36))   buf (siYCountChars si)\r
-{-# LINE 73 "WinCBindings.hsc" #-}\r
-        ((\hsc_ptr -> pokeByteOff hsc_ptr 40)) buf (siFillAttribute si)\r
-{-# LINE 74 "WinCBindings.hsc" #-}\r
-        ((\hsc_ptr -> pokeByteOff hsc_ptr 44))         buf (siFlags si)\r
-{-# LINE 75 "WinCBindings.hsc" #-}\r
-        ((\hsc_ptr -> pokeByteOff hsc_ptr 48))     buf (siShowWindow si)\r
-{-# LINE 76 "WinCBindings.hsc" #-}\r
-        ((\hsc_ptr -> pokeByteOff hsc_ptr 56))       buf (siStdInput si)\r
-{-# LINE 77 "WinCBindings.hsc" #-}\r
-        ((\hsc_ptr -> pokeByteOff hsc_ptr 60))      buf (siStdOutput si)\r
-{-# LINE 78 "WinCBindings.hsc" #-}\r
-        ((\hsc_ptr -> pokeByteOff hsc_ptr 64))       buf (siStdError si)\r
-{-# LINE 79 "WinCBindings.hsc" #-}\r
-\r
-    peek buf = do\r
-        vcb              <- ((\hsc_ptr -> peekByteOff hsc_ptr 0))              buf\r
-{-# LINE 82 "WinCBindings.hsc" #-}\r
-        vlpDesktop       <- ((\hsc_ptr -> peekByteOff hsc_ptr 8))       buf\r
-{-# LINE 83 "WinCBindings.hsc" #-}\r
-        vlpTitle         <- ((\hsc_ptr -> peekByteOff hsc_ptr 12))         buf\r
-{-# LINE 84 "WinCBindings.hsc" #-}\r
-        vdwX             <- ((\hsc_ptr -> peekByteOff hsc_ptr 16))             buf\r
-{-# LINE 85 "WinCBindings.hsc" #-}\r
-        vdwY             <- ((\hsc_ptr -> peekByteOff hsc_ptr 20))             buf\r
-{-# LINE 86 "WinCBindings.hsc" #-}\r
-        vdwXSize         <- ((\hsc_ptr -> peekByteOff hsc_ptr 24))         buf\r
-{-# LINE 87 "WinCBindings.hsc" #-}\r
-        vdwYSize         <- ((\hsc_ptr -> peekByteOff hsc_ptr 28))         buf\r
-{-# LINE 88 "WinCBindings.hsc" #-}\r
-        vdwXCountChars   <- ((\hsc_ptr -> peekByteOff hsc_ptr 32))   buf\r
-{-# LINE 89 "WinCBindings.hsc" #-}\r
-        vdwYCountChars   <- ((\hsc_ptr -> peekByteOff hsc_ptr 36))   buf\r
-{-# LINE 90 "WinCBindings.hsc" #-}\r
-        vdwFillAttribute <- ((\hsc_ptr -> peekByteOff hsc_ptr 40)) buf\r
-{-# LINE 91 "WinCBindings.hsc" #-}\r
-        vdwFlags         <- ((\hsc_ptr -> peekByteOff hsc_ptr 44))         buf\r
-{-# LINE 92 "WinCBindings.hsc" #-}\r
-        vwShowWindow     <- ((\hsc_ptr -> peekByteOff hsc_ptr 48))     buf\r
-{-# LINE 93 "WinCBindings.hsc" #-}\r
-        vhStdInput       <- ((\hsc_ptr -> peekByteOff hsc_ptr 56))       buf\r
-{-# LINE 94 "WinCBindings.hsc" #-}\r
-        vhStdOutput      <- ((\hsc_ptr -> peekByteOff hsc_ptr 60))      buf\r
-{-# LINE 95 "WinCBindings.hsc" #-}\r
-        vhStdError       <- ((\hsc_ptr -> peekByteOff hsc_ptr 64))       buf\r
-{-# LINE 96 "WinCBindings.hsc" #-}\r
-        return $ STARTUPINFO {\r
-            siCb            =  vcb,\r
-            siDesktop       =  vlpDesktop,\r
-            siTitle         =  vlpTitle,\r
-            siX             =  vdwX,\r
-            siY             =  vdwY,\r
-            siXSize         =  vdwXSize,\r
-            siYSize         =  vdwYSize,\r
-            siXCountChars   =  vdwXCountChars,\r
-            siYCountChars   =  vdwYCountChars,\r
-            siFillAttribute =  vdwFillAttribute,\r
-            siFlags         =  vdwFlags,\r
-            siShowWindow    =  vwShowWindow,\r
-            siStdInput      =  vhStdInput,\r
-            siStdOutput     =  vhStdOutput,\r
-            siStdError      =  vhStdError}\r
-\r
-foreign import stdcall unsafe "windows.h WaitForSingleObject"\r
-    waitForSingleObject :: HANDLE -> DWORD -> IO DWORD\r
-\r
-cWAIT_ABANDONED :: DWORD\r
-cWAIT_ABANDONED = 128\r
-{-# LINE 118 "WinCBindings.hsc" #-}\r
-\r
-cWAIT_OBJECT_0 :: DWORD\r
-cWAIT_OBJECT_0 = 0\r
-{-# LINE 121 "WinCBindings.hsc" #-}\r
-\r
-cWAIT_TIMEOUT :: DWORD\r
-cWAIT_TIMEOUT = 258\r
-{-# LINE 124 "WinCBindings.hsc" #-}\r
-\r
-foreign import stdcall unsafe "windows.h GetExitCodeProcess"\r
-    getExitCodeProcess :: HANDLE -> LPDWORD -> IO BOOL\r
-\r
-foreign import stdcall unsafe "windows.h TerminateJobObject"\r
-    terminateJobObject :: HANDLE -> UINT -> IO BOOL\r
-\r
-foreign import stdcall unsafe "windows.h AssignProcessToJobObject"\r
-    assignProcessToJobObject :: HANDLE -> HANDLE -> IO BOOL\r
-\r
-foreign import stdcall unsafe "windows.h CreateJobObjectW"\r
-    createJobObjectW :: LPSECURITY_ATTRIBUTES -> LPCTSTR -> IO HANDLE\r
-\r
-foreign import stdcall unsafe "windows.h CreateProcessW"\r
-    createProcessW :: LPCTSTR -> LPTSTR\r
-                   -> LPSECURITY_ATTRIBUTES -> LPSECURITY_ATTRIBUTES\r
-                   -> BOOL -> DWORD -> LPVOID -> LPCTSTR -> LPSTARTUPINFO\r
-                   -> LPPROCESS_INFORMATION -> IO BOOL\r
-\r
-\r
-{-# LINE 144 "WinCBindings.hsc" #-}\r
-\r
diff --git a/testsuite/timeout/WinCBindings.hsc b/testsuite/timeout/WinCBindings.hsc
new file mode 100644 (file)
index 0000000..022b84f
--- /dev/null
@@ -0,0 +1,144 @@
+{-# OPTIONS -cpp -fffi #-}
+
+module WinCBindings where
+
+#if defined(mingw32_HOST_OS)
+
+import Foreign
+import System.Win32.File
+import System.Win32.Types
+
+#include <windows.h>
+
+type LPPROCESS_INFORMATION = Ptr PROCESS_INFORMATION
+data PROCESS_INFORMATION = PROCESS_INFORMATION
+    { piProcess :: HANDLE
+    , piThread :: HANDLE
+    , piProcessId :: DWORD
+    , piThreadId :: DWORD
+    } deriving Show
+
+instance Storable PROCESS_INFORMATION where
+    sizeOf = const #size PROCESS_INFORMATION
+    alignment = sizeOf
+    poke buf pi = do
+        (#poke PROCESS_INFORMATION, hProcess)    buf (piProcess   pi)
+        (#poke PROCESS_INFORMATION, hThread)     buf (piThread    pi)
+        (#poke PROCESS_INFORMATION, dwProcessId) buf (piProcessId pi)
+        (#poke PROCESS_INFORMATION, dwThreadId)  buf (piThreadId  pi)
+
+    peek buf = do
+        vhProcess    <- (#peek PROCESS_INFORMATION, hProcess)    buf
+        vhThread     <- (#peek PROCESS_INFORMATION, hThread)     buf
+        vdwProcessId <- (#peek PROCESS_INFORMATION, dwProcessId) buf
+        vdwThreadId  <- (#peek PROCESS_INFORMATION, dwThreadId)  buf
+        return $ PROCESS_INFORMATION {
+            piProcess   = vhProcess,
+            piThread    = vhThread,
+            piProcessId = vdwProcessId,
+            piThreadId  = vdwThreadId}
+
+type LPSTARTUPINFO = Ptr STARTUPINFO
+data STARTUPINFO = STARTUPINFO
+    { siCb :: DWORD
+    , siDesktop :: LPTSTR
+    , siTitle :: LPTSTR
+    , siX :: DWORD
+    , siY :: DWORD
+    , siXSize :: DWORD
+    , siYSize :: DWORD
+    , siXCountChars :: DWORD
+    , siYCountChars :: DWORD
+    , siFillAttribute :: DWORD
+    , siFlags :: DWORD
+    , siShowWindow :: WORD
+    , siStdInput :: HANDLE
+    , siStdOutput :: HANDLE
+    , siStdError :: HANDLE
+    } deriving Show
+
+instance Storable STARTUPINFO where
+    sizeOf = const #size STARTUPINFO
+    alignment = sizeOf
+    poke buf si = do
+        (#poke STARTUPINFO, cb)              buf (siCb si)
+        (#poke STARTUPINFO, lpDesktop)       buf (siDesktop si)
+        (#poke STARTUPINFO, lpTitle)         buf (siTitle si)
+        (#poke STARTUPINFO, dwX)             buf (siX si)
+        (#poke STARTUPINFO, dwY)             buf (siY si)
+        (#poke STARTUPINFO, dwXSize)         buf (siXSize si)
+        (#poke STARTUPINFO, dwYSize)         buf (siYSize si)
+        (#poke STARTUPINFO, dwXCountChars)   buf (siXCountChars si)
+        (#poke STARTUPINFO, dwYCountChars)   buf (siYCountChars si)
+        (#poke STARTUPINFO, dwFillAttribute) buf (siFillAttribute si)
+        (#poke STARTUPINFO, dwFlags)         buf (siFlags si)
+        (#poke STARTUPINFO, wShowWindow)     buf (siShowWindow si)
+        (#poke STARTUPINFO, hStdInput)       buf (siStdInput si)
+        (#poke STARTUPINFO, hStdOutput)      buf (siStdOutput si)
+        (#poke STARTUPINFO, hStdError)       buf (siStdError si)
+
+    peek buf = do
+        vcb              <- (#peek STARTUPINFO, cb)              buf
+        vlpDesktop       <- (#peek STARTUPINFO, lpDesktop)       buf
+        vlpTitle         <- (#peek STARTUPINFO, lpTitle)         buf
+        vdwX             <- (#peek STARTUPINFO, dwX)             buf
+        vdwY             <- (#peek STARTUPINFO, dwY)             buf
+        vdwXSize         <- (#peek STARTUPINFO, dwXSize)         buf
+        vdwYSize         <- (#peek STARTUPINFO, dwYSize)         buf
+        vdwXCountChars   <- (#peek STARTUPINFO, dwXCountChars)   buf
+        vdwYCountChars   <- (#peek STARTUPINFO, dwYCountChars)   buf
+        vdwFillAttribute <- (#peek STARTUPINFO, dwFillAttribute) buf
+        vdwFlags         <- (#peek STARTUPINFO, dwFlags)         buf
+        vwShowWindow     <- (#peek STARTUPINFO, wShowWindow)     buf
+        vhStdInput       <- (#peek STARTUPINFO, hStdInput)       buf
+        vhStdOutput      <- (#peek STARTUPINFO, hStdOutput)      buf
+        vhStdError       <- (#peek STARTUPINFO, hStdError)       buf
+        return $ STARTUPINFO {
+            siCb            =  vcb,
+            siDesktop       =  vlpDesktop,
+            siTitle         =  vlpTitle,
+            siX             =  vdwX,
+            siY             =  vdwY,
+            siXSize         =  vdwXSize,
+            siYSize         =  vdwYSize,
+            siXCountChars   =  vdwXCountChars,
+            siYCountChars   =  vdwYCountChars,
+            siFillAttribute =  vdwFillAttribute,
+            siFlags         =  vdwFlags,
+            siShowWindow    =  vwShowWindow,
+            siStdInput      =  vhStdInput,
+            siStdOutput     =  vhStdOutput,
+            siStdError      =  vhStdError}
+
+foreign import stdcall unsafe "windows.h WaitForSingleObject"
+    waitForSingleObject :: HANDLE -> DWORD -> IO DWORD
+
+cWAIT_ABANDONED :: DWORD
+cWAIT_ABANDONED = #const WAIT_ABANDONED
+
+cWAIT_OBJECT_0 :: DWORD
+cWAIT_OBJECT_0 = #const WAIT_OBJECT_0
+
+cWAIT_TIMEOUT :: DWORD
+cWAIT_TIMEOUT = #const WAIT_TIMEOUT
+
+foreign import stdcall unsafe "windows.h GetExitCodeProcess"
+    getExitCodeProcess :: HANDLE -> LPDWORD -> IO BOOL
+
+foreign import stdcall unsafe "windows.h TerminateJobObject"
+    terminateJobObject :: HANDLE -> UINT -> IO BOOL
+
+foreign import stdcall unsafe "windows.h AssignProcessToJobObject"
+    assignProcessToJobObject :: HANDLE -> HANDLE -> IO BOOL
+
+foreign import stdcall unsafe "windows.h CreateJobObjectW"
+    createJobObjectW :: LPSECURITY_ATTRIBUTES -> LPCTSTR -> IO HANDLE
+
+foreign import stdcall unsafe "windows.h CreateProcessW"
+    createProcessW :: LPCTSTR -> LPTSTR
+                   -> LPSECURITY_ATTRIBUTES -> LPSECURITY_ATTRIBUTES
+                   -> BOOL -> DWORD -> LPVOID -> LPCTSTR -> LPSTARTUPINFO
+                   -> LPPROCESS_INFORMATION -> IO BOOL
+
+#endif
+