Catch up with updates to platform #defines.
Generally: use _HOST_ rather than _TARGET_ (except in Cabal where we
have to retain compatibility with previous GHC versions).
-- ** Tracers
-- | The tracer is a function that monitors the trace messages.
fileTracer, -- :: Handle -> String -> IO ()
-#ifdef mingw32_TARGET_OS
+#ifdef mingw32_HOST_OS
winDebugTracer, -- :: String -> IO ()
#endif
addTracer, -- :: String -> (String -> IO ()) -> IO ()
import System.IO.Unsafe
import System.IO
-#ifdef mingw32_TARGET_OS
+#ifdef mingw32_HOST_OS
import Foreign.C.String
#endif
hPutStr handle msg
hPutChar handle '\n'
-#ifdef mingw32_TARGET_OS
+#ifdef mingw32_HOST_OS
-- | A tracer function that outputs the message to the debuger (Windows only)
winDebugTracer :: String -- ^ trace message
-> IO ()
cWcharsToChars :: [CWchar] -> [Char]
charsToCWchars :: [Char] -> [CWchar]
-#ifdef mingw32_TARGET_OS
+#ifdef mingw32_HOST_OS
-- On Windows, wchar_t is 16 bits wide and CWString uses the UTF-16 encoding.
fromIntegral (c' `div` 0x400 + 0xd800) :
fromIntegral (c' `mod` 0x400 + 0xdc00) : wcs
-#else /* !mingw32_TARGET_OS */
+#else /* !mingw32_HOST_OS */
cWcharsToChars xs = map castCWcharToChar xs
charsToCWchars xs = map castCharToCWchar xs
castCharToCWchar :: Char -> CWchar
castCharToCWchar ch = fromIntegral (ord ch)
-#endif /* !mingw32_TARGET_OS */
+#endif /* !mingw32_HOST_OS */
, writeTVar -- :: a -> TVar a -> STM ()
, unsafeIOToSTM -- :: IO a -> STM a
-#ifdef mingw32_TARGET_OS
+#ifdef mingw32_HOST_OS
, asyncRead -- :: Int -> Int -> Int -> Ptr a -> IO (Int, Int)
, asyncWrite -- :: Int -> Int -> Int -> Ptr a -> IO (Int, Int)
, asyncDoProc -- :: FunPtr (Ptr a -> IO Int) -> Ptr a -> IO Int
%************************************************************************
\begin{code}
-#ifdef mingw32_TARGET_OS
+#ifdef mingw32_HOST_OS
-- Note: threadDelay, threadWaitRead and threadWaitWrite aren't really functional
-- on Win32, but left in there because lib code (still) uses them (the manner
-- given file descriptor (GHC only).
threadWaitRead :: Fd -> IO ()
threadWaitRead fd
-#ifndef mingw32_TARGET_OS
+#ifndef mingw32_HOST_OS
| threaded = waitForReadEvent fd
#endif
| otherwise = IO $ \s ->
-- given file descriptor (GHC only).
threadWaitWrite :: Fd -> IO ()
threadWaitWrite fd
-#ifndef mingw32_TARGET_OS
+#ifndef mingw32_HOST_OS
| threaded = waitForWriteEvent fd
#endif
| otherwise = IO $ \s ->
--
threadDelay :: Int -> IO ()
threadDelay time
-#ifndef mingw32_TARGET_OS
+#ifndef mingw32_HOST_OS
| threaded = waitForDelayEvent time
#else
| threaded = c_Sleep (fromIntegral (time `quot` 1000))
}}
-- On Windows, we just make a safe call to 'Sleep' to implement threadDelay.
-#ifdef mingw32_TARGET_OS
+#ifdef mingw32_HOST_OS
foreign import ccall safe "Sleep" c_Sleep :: CInt -> IO ()
#endif
-- - forkProcess will kill the IO manager thread. Let's just
-- hope we don't need to do any blocking IO between fork & exec.
-#ifndef mingw32_TARGET_OS
+#ifndef mingw32_HOST_OS
data IOReq
= Read {-# UNPACK #-} !Fd {-# UNPACK #-} !(MVar ())
--
-----------------------------------------------------------------------------
module GHC.ConsoleHandler
-#ifndef mingw32_TARGET_OS
+#ifndef mingw32_HOST_OS
where
import Prelude -- necessary to get dependencies right
#else /* whole file */
foreign import ccall unsafe "Signals.h stg_InstallConsoleEvent"
rts_installHandler :: CInt -> Ptr (StablePtr (CInt -> IO ())) -> IO CInt
-#endif /* mingw32_TARGET_OS */
+#endif /* mingw32_HOST_OS */
readRawBuffer, readRawBufferPtr,
writeRawBuffer, writeRawBufferPtr,
-#ifndef mingw32_TARGET_OS
+#ifndef mingw32_HOST_OS
unlockFile,
#endif
allocateBuffer :: Int -> BufferState -> IO Buffer
allocateBuffer sz@(I# size) state = IO $ \s ->
-#ifdef mingw32_TARGET_OS
+#ifdef mingw32_HOST_OS
-- To implement asynchronous I/O under Win32, we have to pass
-- buffer references to external threads that handles the
-- filling/emptying of their contents. Hence, the buffer cannot
-- Low level routines for reading/writing to (raw)buffers:
-#ifndef mingw32_TARGET_OS
+#ifndef mingw32_HOST_OS
readRawBuffer :: String -> FD -> Bool -> RawBuffer -> Int -> CInt -> IO CInt
readRawBuffer loc fd is_stream buf off len =
throwErrnoIfMinus1RetryMayBlock loc
foreign import ccall unsafe "__hscore_PrelHandle_write"
write_off :: CInt -> Ptr CChar -> Int -> CInt -> IO CInt
-#else /* mingw32_TARGET_OS.... */
+#else /* mingw32_HOST_OS.... */
readRawBuffer :: String -> FD -> Bool -> RawBuffer -> Int -> CInt -> IO CInt
readRawBuffer loc fd is_stream buf off len
let
oflags1 = case mode of
ReadMode -> read_flags
-#ifdef mingw32_TARGET_OS
+#ifdef mingw32_HOST_OS
WriteMode -> write_flags .|. o_TRUNC
#else
WriteMode -> write_flags
-- ASSERT: if we just created the file, then openFd won't fail
-- (so we don't need to worry about removing the newly created file
-- in the event of an error).
-#ifndef mingw32_TARGET_OS
+#ifndef mingw32_HOST_OS
if mode == WriteMode
then throwErrnoIf (/=0) "openFile"
(c_ftruncate (fromIntegral fd) 0)
-- regular files need to be locked
RegularFile -> do
-#ifndef mingw32_TARGET_OS
+#ifndef mingw32_HOST_OS
r <- lockFile (fromIntegral fd) (fromBool write) 1{-exclusive-}
when (r == -1) $
ioException (IOError Nothing ResourceBusy "openFile"
openFd fd Nothing False{-XXX!-} fd_str mode True{-bin mode-}
-#ifndef mingw32_TARGET_OS
+#ifndef mingw32_HOST_OS
foreign import ccall unsafe "lockFile"
lockFile :: CInt -> CInt -> CInt -> IO CInt
case haOtherSide handle_ of
Nothing ->
throwErrnoIfMinus1Retry_ "hClose"
-#ifdef mingw32_TARGET_OS
+#ifdef mingw32_HOST_OS
(closeFd (haIsStream handle_) c_fd)
#else
(c_close c_fd)
-- free the spare buffers
writeIORef (haBuffers handle_) BufferListNil
-#ifndef mingw32_TARGET_OS
+#ifndef mingw32_HOST_OS
-- unlock it
unlockFile c_fd
#endif
is_tty <- fdIsTTY (haFD handle_)
when (is_tty && isReadableHandleType (haType handle_)) $
case mode of
-#ifndef mingw32_TARGET_OS
+#ifndef mingw32_HOST_OS
-- 'raw' mode under win32 is a bit too specialised (and troublesome
-- for most common uses), so simply disable its use here.
NoBuffering -> setCooked (haFD handle_) False
hTell handle =
wantSeekableHandle "hGetPosn" handle $ \ handle_ -> do
-#if defined(mingw32_TARGET_OS)
+#if defined(mingw32_HOST_OS)
-- urgh, on Windows we have to worry about \n -> \r\n translation,
-- so we can't easily calculate the file position using the
-- current buffer size. Just flush instead.
import GHC.List
import GHC.Exception ( ioError, catch )
-#ifdef mingw32_TARGET_OS
+#ifdef mingw32_HOST_OS
import GHC.Conc
#endif
loop :: Int -> Int -> IO Int
loop off bytes | bytes <= 0 = return off
loop off bytes = do
-#ifndef mingw32_TARGET_OS
+#ifndef mingw32_HOST_OS
ssize <- c_write (fromIntegral fd) (ptr `plusPtr` off) (fromIntegral bytes)
let r = fromIntegral ssize :: Int
if (r == -1)
readChunkNonBlocking :: FD -> Bool -> Ptr a -> Int -> IO Int
readChunkNonBlocking fd is_stream ptr bytes = do
-#ifndef mingw32_TARGET_OS
+#ifndef mingw32_HOST_OS
ssize <- c_read (fromIntegral fd) (castPtr ptr) (fromIntegral bytes)
let r = fromIntegral ssize :: Int
if (r == -1)
-- -----------------------------------------------------------------------------
-- Win32 implementation
-#if (defined(HAVE_WCTYPE_H) && HAVE_ISWSPACE && defined(HTYPE_WINT_T)) || mingw32_TARGET_OS
+#if (defined(HAVE_WCTYPE_H) && HAVE_ISWSPACE && defined(HTYPE_WINT_T)) || mingw32_HOST_OS
-- Use the wide-char classification functions if available. Glibc
-- seems to implement these properly, even for chars > 0xffff, as long
getCPUTime :: IO Integer
getCPUTime = do
-#if !defined(mingw32_TARGET_OS) && !defined(cygwin32_TARGET_OS)
+#if !defined(mingw32_HOST_OS) && !defined(cygwin32_HOST_OS)
-- getrusage() is right royal pain to deal with when targetting multiple
-- versions of Solaris, since some versions supply it in libc (2.3 and 2.5),
-- while 2.4 has got it in libucb (I wouldn't be too surprised if it was back
--
-- Avoid the problem by resorting to times() instead.
--
-#if defined(HAVE_GETRUSAGE) && ! irix_TARGET_OS && ! solaris2_TARGET_OS
+#if defined(HAVE_GETRUSAGE) && ! irix_HOST_OS && ! solaris2_HOST_OS
allocaBytes (#const sizeof(struct rusage)) $ \ p_rusage -> do
getrusage (#const RUSAGE_SELF) p_rusage
rawSystem cmd args = system (unwords (map translate (cmd:args)))
translate :: String -> String
-#if defined(mingw32_TARGET_OS)
+#if defined(mingw32_HOST_OS)
-- copied from System.Process (qv)
translate str = '"' : snd (foldr escape (True,"\"") str)
where escape '"' (b, str) = (True, '\\' : '"' : str)
escape '\\' (True, str) = (True, '\\' : '\\' : str)
escape '\\' (False, str) = (False, '\\' : str)
escape c (b, str) = (False, c : str)
-#else /* ! mingw32_TARGET_OS */
+#else /* ! mingw32_HOST_OS */
translate str = '\'' : foldr escape "'" str
where escape '\'' cs = '\'' : '\\' : '\'' : '\'' : cs
escape c cs = c : cs
-#endif /* ! mingw32_TARGET_OS */
+#endif /* ! mingw32_HOST_OS */
#endif /* ! __GLASGOW_HASKELL__ */
canonicalizePath fpath =
withCString fpath $ \pInPath ->
allocaBytes long_path_size $ \pOutPath ->
-#if defined(mingw32_TARGET_OS)
+#if defined(mingw32_HOST_OS)
alloca $ \ppFilePart ->
do c_GetFullPathName pInPath (fromIntegral long_path_size) pOutPath ppFilePart
#else
#endif
peekCString pOutPath
-#if defined(mingw32_TARGET_OS)
+#if defined(mingw32_HOST_OS)
foreign import stdcall unsafe "GetFullPathName"
c_GetFullPathName :: CString
-> CInt
-}
getHomeDirectory :: IO FilePath
getHomeDirectory =
-#if __GLASGOW_HASKELL__ && defined(mingw32_TARGET_OS)
+#if __GLASGOW_HASKELL__ && defined(mingw32_HOST_OS)
allocaBytes long_path_size $ \pPath -> do
r <- c_SHGetFolderPath nullPtr csidl_PROFILE nullPtr 0 pPath
if (r < 0)
-}
getAppUserDataDirectory :: String -> IO FilePath
getAppUserDataDirectory appName = do
-#if __GLASGOW_HASKELL__ && defined(mingw32_TARGET_OS)
+#if __GLASGOW_HASKELL__ && defined(mingw32_HOST_OS)
allocaBytes long_path_size $ \pPath -> do
r <- c_SHGetFolderPath nullPtr csidl_APPDATA nullPtr 0 pPath
s <- peekCString pPath
-}
getUserDocumentsDirectory :: IO FilePath
getUserDocumentsDirectory = do
-#if __GLASGOW_HASKELL__ && defined(mingw32_TARGET_OS)
+#if __GLASGOW_HASKELL__ && defined(mingw32_HOST_OS)
allocaBytes long_path_size $ \pPath -> do
r <- c_SHGetFolderPath nullPtr csidl_PERSONAL nullPtr 0 pPath
peekCString pPath
-}
getTemporaryDirectory :: IO FilePath
getTemporaryDirectory = do
-#if __GLASGOW_HASKELL__ && defined(mingw32_TARGET_OS)
+#if __GLASGOW_HASKELL__ && defined(mingw32_HOST_OS)
allocaBytes long_path_size $ \pPath -> do
r <- c_GetTempPath (fromIntegral long_path_size) pPath
peekCString pPath
catch (getEnv "TMPDIR") (\ex -> return "/tmp")
#endif
-#if __GLASGOW_HASKELL__ && defined(mingw32_TARGET_OS)
+#if __GLASGOW_HASKELL__ && defined(mingw32_HOST_OS)
foreign import stdcall unsafe "SHGetFolderPath"
c_SHGetFolderPath :: Ptr ()
-> CInt
pathParents p =
root'' : map ((++) root') (dropEmptyPath $ inits path')
where
-#ifdef mingw32_TARGET_OS
+#ifdef mingw32_HOST_OS
(root,path) = case break (== ':') p of
(path, "") -> ("",path)
(root,_:path) -> (root++":",path)
-- separator is a slash (@\"\/\"@) on Unix and Macintosh, and a backslash
-- (@\"\\\"@) on the Windows operating system.
pathSeparator :: Char
-#ifdef mingw32_TARGET_OS
+#ifdef mingw32_HOST_OS
pathSeparator = '\\'
#else
pathSeparator = '/'
-- environment variables. The separator is a colon (@\":\"@) on Unix and
-- Macintosh, and a semicolon (@\";\"@) on the Windows operating system.
searchPathSeparator :: Char
-#ifdef mingw32_TARGET_OS
+#ifdef mingw32_HOST_OS
searchPathSeparator = ';'
#else
searchPathSeparator = ':'
-- | Extension for executable files
-- (typically @\"\"@ on Unix and @\"exe\"@ on Windows or OS\/2)
exeExtension :: String
-#ifdef mingw32_TARGET_OS
+#ifdef mingw32_HOST_OS
exeExtension = "exe"
#else
exeExtension = ""
isPathSeparator :: Char -> Bool
isPathSeparator '/' = True
-#ifdef mingw32_TARGET_OS
+#ifdef mingw32_HOST_OS
isPathSeparator '\\' = True
#endif
isPathSeparator _ = False
--
-----------------------------------------------------------------------------
-#ifndef __NHC__
-#include "MachDeps.h"
-#endif
-
module System.Info
(
os, -- :: String
- arch -- :: String
+ arch, -- :: String
+ compilerName, -- :: String
+ compilerVersion -- :: Version
) where
import Prelude
+import Data.Version
#ifndef __NHC__
+#include "ghcplatform.h"
+
arch :: String
arch = HOST_ARCH
os,arch ::String
#include "OSInfo.hs"
#endif
+
+compilerName :: String
+#if defined(__NHC__)
+compilerName = "nhc98"
+#elif defined(__GLASGOW_HASKELL__)
+compilerName = "ghc"
+#elif defined(__HUGS__)
+compilerName = "hugs"
+#else
+#error Unknown compiler name
+#endif
+
+compilerVersion :: Version
+#ifdef __GLASGOW_HASKELL__
+compilerVersion = Version {versionBranch=[maj,min], versionTags=[]}
+ where (maj,min) = __GLASGOW_HASKELL__ `divMod` 100
+#endif
ioe_unknownfiletype = IOError Nothing UnsupportedOperation "fdType"
"unknown file type" Nothing
-#if defined(mingw32_TARGET_OS) || defined(__MINGW32__)
+#if defined(mingw32_HOST_OS) || defined(__MINGW32__)
closeFd :: Bool -> CInt -> IO CInt
closeFd isStream fd
| isStream = c_closesocket fd
fdGetMode :: Int -> IO IOMode
fdGetMode fd = do
-#if defined(mingw32_TARGET_OS) || defined(__MINGW32__)
+#if defined(mingw32_HOST_OS) || defined(__MINGW32__)
-- XXX: this code is *BROKEN*, _setmode only deals with O_TEXT/O_BINARY
flags1 <- throwErrnoIfMinus1Retry "fdGetMode"
(c__setmode (fromIntegral fd) (fromIntegral o_WRONLY))
-- ---------------------------------------------------------------------------
-- Turning on non-blocking for a file descriptor
-#if !defined(mingw32_TARGET_OS) && !defined(__MINGW32__)
+#if !defined(mingw32_HOST_OS) && !defined(__MINGW32__)
setNonBlockingFD fd = do
flags <- throwErrnoIfMinus1Retry "setNonBlockingFD"
foreign import ccall unsafe "HsBase.h getpid"
c_getpid :: IO CPid
-#if !defined(mingw32_TARGET_OS) && !defined(__MINGW32__)
+#if !defined(mingw32_HOST_OS) && !defined(__MINGW32__)
foreign import ccall unsafe "HsBase.h fcntl"
c_fcntl_read :: CInt -> CInt -> IO CInt
foreign import ccall unsafe "HsBase.h __hscore_ptr_c_cc" ptr_c_cc :: Ptr CTermios -> IO (Ptr Word8)
#endif
-#if !defined(mingw32_TARGET_OS) && !defined(__MINGW32__)
+#if !defined(mingw32_HOST_OS) && !defined(__MINGW32__)
foreign import ccall unsafe "HsBase.h __hscore_s_issock" s_issock :: CMode -> Bool
#else
s_issock :: CMode -> Bool
#include "ghcconfig.h"
module System.Posix.Signals (
-#ifndef mingw32_TARGET_OS
+#ifndef mingw32_HOST_OS
-- * The Signal type
Signal,
-- * Waiting for signals
getPendingSignals,
-#ifndef cygwin32_TARGET_OS
+#ifndef cygwin32_HOST_OS
awaitSignal,
#endif
import System.Posix.Types
import System.Posix.Internals
-#ifndef mingw32_TARGET_OS
+#ifndef mingw32_HOST_OS
-- WHOLE FILE...
-- -----------------------------------------------------------------------------
raiseSignal :: Signal -> IO ()
raiseSignal sig = throwErrnoIfMinus1_ "raiseSignal" (c_raise sig)
-#if defined(__GLASGOW_HASKELL__) && (defined(openbsd_TARGET_OS) || defined(freebsd_TARGET_OS))
+#if defined(__GLASGOW_HASKELL__) && (defined(openbsd_HOST_OS) || defined(freebsd_HOST_OS))
foreign import ccall unsafe "genericRaise"
c_raise :: CInt -> IO CInt
#else
throwErrnoIfMinus1_ "getPendingSignals" (c_sigpending p)
return (SignalSet fp)
-#ifndef cygwin32_TARGET_OS
+#ifndef cygwin32_HOST_OS
awaitSignal :: Maybe SignalSet -> IO ()
awaitSignal maybe_sigset = do
fp <- case maybe_sigset of
foreign import ccall unsafe "__hsposix_SIG_UNBLOCK" c_SIG_UNBLOCK :: CInt
#endif /* __HUGS__ */
-#endif /* mingw32_TARGET_OS */
+#endif /* mingw32_HOST_OS */
runCommand string = do
(cmd,args) <- commandToProcess string
-#if !defined(mingw32_TARGET_OS) && !defined(__MINGW32__)
+#if !defined(mingw32_HOST_OS) && !defined(__MINGW32__)
runProcess1 "runCommand" cmd args Nothing Nothing Nothing Nothing Nothing
#else
runProcess1 "runCommand" cmd [] Nothing Nothing Nothing Nothing Nothing args
-> Maybe Handle -- ^ Handle to use for @stderr@
-> IO ProcessHandle
-#if !defined(mingw32_TARGET_OS) && !defined(__MINGW32__)
+#if !defined(mingw32_HOST_OS) && !defined(__MINGW32__)
runProcess cmd args mb_cwd mb_env mb_stdin mb_stdout mb_stderr
= runProcess1 "runProcess" cmd args mb_cwd mb_env mb_stdin mb_stdout mb_stderr
runInteractiveCommand string = do
(cmd,args) <- commandToProcess string
-#if !defined(mingw32_TARGET_OS) && !defined(__MINGW32__)
+#if !defined(mingw32_HOST_OS) && !defined(__MINGW32__)
runInteractiveProcess1 "runInteractiveCommand" cmd args Nothing Nothing
#else
runInteractiveProcess1 "runInteractiveCommand" cmd [] Nothing Nothing args
-> Maybe [(String,String)] -- ^ Optional environment (otherwise inherit)
-> IO (Handle,Handle,Handle,ProcessHandle)
-#if !defined(mingw32_TARGET_OS) && !defined(__MINGW32__)
+#if !defined(mingw32_HOST_OS) && !defined(__MINGW32__)
runInteractiveProcess cmd args mb_cwd mb_env =
runInteractiveProcess1 "runInteractiveProcess" cmd args mb_cwd mb_env
Windows isn't required (or desirable) here.
-}
-#if !defined(mingw32_TARGET_OS) && !defined(__MINGW32__)
+#if !defined(mingw32_HOST_OS) && !defined(__MINGW32__)
commandToProcess
:: String
mapEx (IOException (IOError h iot fun str _)) = ioError (IOError h iot fun str (Just fpath))
mapEx e = throwIO e
-#if !defined(mingw32_TARGET_OS) && !defined(__MINGW32__)
+#if !defined(mingw32_HOST_OS) && !defined(__MINGW32__)
withCEnvironment :: [(String,String)] -> (Ptr CString -> IO a) -> IO a
withCEnvironment env act =
let env' = map (\(name, val) -> name ++ ('=':val)) env
use lpCommandLine alone, which CreateProcess supports.
-}
-#if defined(mingw32_TARGET_OS)
+#if defined(mingw32_HOST_OS)
-- Translate command-line arguments for passing to CreateProcess().
translate :: String -> String
-- #hide
module System.Process.Internals (
ProcessHandle(..), PHANDLE,
-#if !defined(mingw32_TARGET_OS) && !defined(__MINGW32__)
+#if !defined(mingw32_HOST_OS) && !defined(__MINGW32__)
pPrPr_disableITimers, c_execvpe
#endif
) where
import Prelude -- necessary to get dependencies right
-#if !defined(mingw32_TARGET_OS) && !defined(__MINGW32__)
+#if !defined(mingw32_HOST_OS) && !defined(__MINGW32__)
import System.Posix.Types ( CPid )
#else
import Data.Word ( Word32 )
termination: they all return a 'ProcessHandle' which may be used
to wait for the process later.
-}
-#if !defined(mingw32_TARGET_OS) && !defined(__MINGW32__)
+#if !defined(mingw32_HOST_OS) && !defined(__MINGW32__)
type PHANDLE = CPid
#else
type PHANDLE = Word32
-- ----------------------------------------------------------------------------
-#if !defined(mingw32_TARGET_OS) && !defined(__MINGW32__)
+#if !defined(mingw32_HOST_OS) && !defined(__MINGW32__)
-- this function disables the itimer, which would otherwise cause confusing
-- signals to be sent to the new process.
#else /* ! HAVE_TM_ZONE */
# if HAVE_TZNAME || defined(_WIN32)
-# if cygwin32_TARGET_OS
+# if cygwin32_HOST_OS
# define tzname _tzname
# endif
-# ifndef mingw32_TARGET_OS
+# ifndef mingw32_HOST_OS
foreign import ccall unsafe "time.h &tzname" tzname :: Ptr (Ptr CChar)
# else
foreign import ccall unsafe "__hscore_timezone" timezone :: Ptr CLong
return (-fromIntegral (realToInteger tz))
# else /* ! HAVE_DECL_ALTZONE */
-#if !defined(mingw32_TARGET_OS)
+#if !defined(mingw32_HOST_OS)
foreign import ccall "time.h &timezone" timezone :: Ptr CLong
#endif
#if HAVE_FTIME
type CTimeB = ()
-#ifndef mingw32_TARGET_OS
+#ifndef mingw32_HOST_OS
foreign import ccall unsafe "time.h ftime" ftime :: Ptr CTimeB -> IO CInt
#else
foreign import ccall unsafe "time.h ftime" ftime :: Ptr CTimeB -> IO ()
* Win32 Console API support
*/
#include "ghcconfig.h"
-#if defined(mingw32_TARGET_OS) || defined(cygwin32_TARGET_OS) || defined(__MINGW32__) || defined(_MSC_VER)
+#if defined(mingw32_HOST_OS) || defined(cygwin32_HOST_OS) || defined(__MINGW32__) || defined(_MSC_VER)
/* to the end */
#include "consUtils.h"
#include <windows.h>
#include <io.h>
-#if defined(cygwin32_TARGET_OS)
+#if defined(cygwin32_HOST_OS)
#define _get_osfhandle get_osfhandle
#endif
return -1;
}
-#endif /* defined(mingw32_TARGET_OS) || ... */
+#endif /* defined(mingw32_HOST_OS) || ... */
// The following is required on Solaris to force the POSIX versions of
// the various _r functions instead of the Solaris versions.
-#ifdef solaris2_TARGET_OS
+#ifdef solaris2_HOST_OS
#define _POSIX_PTHREAD_SEMANTICS
#endif
#include "HsBase.h"
-#if defined(mingw32_TARGET_OS) || defined(__MINGW32__) || defined(_MSC_VER)
+#if defined(mingw32_HOST_OS) || defined(__MINGW32__) || defined(_MSC_VER)
#include <windows.h>
static
__hscore_renameFile( HsAddr src,
HsAddr dest)
{
-#if defined(mingw32_TARGET_OS) || defined(__MINGW32__) || defined(_MSC_VER)
+#if defined(mingw32_HOST_OS) || defined(__MINGW32__) || defined(_MSC_VER)
static int forNT = -1;
/* ToDo: propagate error codes back */
-------------------------------------------------------------------------- */
#include "HsBase.h"
-#if !defined(mingw32_TARGET_OS) /* to the end */
+#if !defined(mingw32_HOST_OS) /* to the end */
/* Evidently non-Posix. */
/* #include "PosixSource.h" */
inputReady(int fd, int msecs, int isSock)
{
if
-#ifndef mingw32_TARGET_OS
+#ifndef mingw32_HOST_OS
( 1 ) {
#else
( isSock ) {
/* 1 => Input ready, 0 => not ready, -1 => error */
return (ready);
}
-#ifdef mingw32_TARGET_OS
+#ifdef mingw32_HOST_OS
else {
DWORD rc;
HANDLE hFile = (HANDLE)_get_osfhandle(fd);
/*
* (c) The GRASP/AQUA Project, Glasgow University, 1994-2004
*
- * $Id: lockFile.c,v 1.4 2005/01/01 23:59:59 krasimir Exp $
+ * $Id: lockFile.c,v 1.5 2005/01/28 13:36:32 simonmar Exp $
*
* stdin/stout/stderr Runtime Support
*/
-#ifndef mingw32_TARGET_OS
+#ifndef mingw32_HOST_OS
#include "HsBase.h"
#include "Rts.h"
\r
#include "HsBase.h"\r
\r
-#if defined(mingw32_TARGET_OS)\r
+#if defined(mingw32_HOST_OS)\r
#include <windows.h>\r
#include <stdlib.h>\r
#endif\r
#include <signal.h>\r
#endif\r
\r
-#if !defined(mingw32_TARGET_OS) && !defined(__MINGW32__)\r
+#if !defined(mingw32_HOST_OS) && !defined(__MINGW32__)\r
/* ----------------------------------------------------------------------------\r
UNIX versions\r
------------------------------------------------------------------------- */\r
*/
#include "HsBase.h"
-#if defined(mingw32_TARGET_OS) /* to the end */
+#if defined(mingw32_HOST_OS) /* to the end */
HsAddr __hscore_timezone( void )
{ return (HsAddr)&_timezone; }
#if HAVE_SYS_TIMES_H
#include <sys/times.h>
#endif
-#if HAVE_WINSOCK_H && defined(mingw32_TARGET_OS)
+#if HAVE_WINSOCK_H && defined(mingw32_HOST_OS)
#include <winsock.h>
#endif
#if HAVE_LIMITS_H
#include <wctype.h>
#endif
-#if !defined(mingw32_TARGET_OS) && !defined(irix_TARGET_OS)
+#if !defined(mingw32_HOST_OS) && !defined(irix_HOST_OS)
# if HAVE_SYS_RESOURCE_H
# include <sys/resource.h>
# endif
#endif
-#ifdef hpux_TARGET_OS
+#ifdef hpux_HOST_OS
#include <sys/syscall.h>
#define getrusage(a, b) syscall(SYS_GETRUSAGE, a, b)
#define HAVE_GETRUSAGE
#include "runProcess.h"
-#if defined(mingw32_TARGET_OS)
+#if defined(mingw32_HOST_OS)
#include <io.h>
#include <fcntl.h>
#include "timeUtils.h"
/* in Signals.c */
extern HsInt nocldstop;
-#if !defined(mingw32_TARGET_OS)
+#if !defined(mingw32_HOST_OS)
/* in execvpe.c */
extern int execvpe(char *name, char *const argv[], char **envp);
extern void pPrPr_disableITimers (void);
#endif
#endif
-#if !defined(mingw32_TARGET_OS) && !defined(_MSC_VER)
+#if !defined(mingw32_HOST_OS) && !defined(_MSC_VER)
INLINE int
__hscore_sigemptyset( sigset_t *set )
{ return sigemptyset(set); }
INLINE HsBool
__hscore_supportsTextMode()
{
-#if defined(mingw32_TARGET_OS)
+#if defined(mingw32_HOST_OS)
return HS_BOOL_FALSE;
#else
return HS_BOOL_TRUE;
INLINE HsInt
__hscore_setmode( HsInt fd, HsBool toBin )
{
-#if defined(mingw32_TARGET_OS) || defined(_MSC_VER)
+#if defined(mingw32_HOST_OS) || defined(_MSC_VER)
return setmode(fd,(toBin == HS_BOOL_TRUE) ? _O_BINARY : _O_TEXT);
#else
return 0;
}
-#if defined(mingw32_TARGET_OS) || defined(_MSC_VER)
+#if defined(mingw32_HOST_OS) || defined(_MSC_VER)
INLINE HsInt
__hscore_PrelHandle_send( HsInt fd, HsAddr ptr, HsInt off, int sz )
{
}
#endif
-#if defined(mingw32_TARGET_OS) || defined(_MSC_VER)
+#if defined(mingw32_HOST_OS) || defined(_MSC_VER)
INLINE long *
__hscore_Time_ghcTimezone( void ) { return &_timezone; }
INLINE HsInt
__hscore_mkdir( HsAddr pathName, HsInt mode )
{
-#if defined(mingw32_TARGET_OS) || defined(_MSC_VER)
+#if defined(mingw32_HOST_OS) || defined(_MSC_VER)
return mkdir(pathName);
#else
return mkdir(pathName,mode);
INLINE HsInt
__hscore_sizeof_termios( void )
{
-#ifndef mingw32_TARGET_OS
+#ifndef mingw32_HOST_OS
return sizeof(struct termios);
#else
return 0;
}
#endif
-#if !defined(mingw32_TARGET_OS) && !defined(_MSC_VER)
+#if !defined(mingw32_HOST_OS) && !defined(_MSC_VER)
INLINE HsInt
__hscore_sizeof_sigset_t( void )
{
INLINE int __hscore_hs_fileno (FILE *f) { return fileno (f); }
-#if !defined(mingw32_TARGET_OS) && !defined(_MSC_VER)
+#if !defined(mingw32_HOST_OS) && !defined(_MSC_VER)
INLINE int __hsposix_SIGABRT() { return SIGABRT; }
INLINE int __hsposix_SIGALRM() { return SIGALRM; }
INLINE int __hsposix_SIGBUS() { return SIGBUS; }
INLINE int __hsposix_SIG_UNBLOCK() { return SIG_UNBLOCK; }
INLINE int __hsposix_SIG_SETMASK() { return SIG_SETMASK; }
-#endif /* mingw32_TARGET_OS */
+#endif /* mingw32_HOST_OS */
INLINE int __hscore_open(char *file, int how, mode_t mode) {
-#ifdef mingw32_TARGET_OS
+#ifdef mingw32_HOST_OS
if ((how & O_WRONLY) || (how & O_RDWR) || (how & O_APPEND))
return _sopen(file,how,_SH_DENYRW,mode);
else
// select-related stuff
-#if !defined(mingw32_TARGET_OS)
+#if !defined(mingw32_HOST_OS)
INLINE void hsFD_CLR(int fd, fd_set *fds) { FD_CLR(fd, fds); }
INLINE int hsFD_ISSET(int fd, fd_set *fds) { return FD_ISSET(fd, fds); }
INLINE void hsFD_SET(int fd, fd_set *fds) { FD_SET(fd, fds); }
// gettimeofday()-related
-#if !defined(mingw32_TARGET_OS)
+#if !defined(mingw32_HOST_OS)
#define TICK_FREQ 50
INLINE HsInt sizeofTimeVal(void) { return sizeof(struct timeval); }
p->tv_sec = ticks / TICK_FREQ;
p->tv_usec = (ticks % TICK_FREQ) * (1000000 / TICK_FREQ);
}
-#endif // !defined(mingw32_TARGET_OS)
+#endif // !defined(mingw32_HOST_OS)
// Directory-related
-#if defined(mingw32_TARGET_OS)
+#if defined(mingw32_HOST_OS)
/* Make sure we've got the reqd CSIDL_ constants in scope;
* w32api header files are lagging a bit in defining the full set.
/*
* (c) The University of Glasgow 2001
*
- * $Id: lockFile.h,v 1.2 2005/01/02 00:00:00 krasimir Exp $
+ * $Id: lockFile.h,v 1.3 2005/01/28 13:36:34 simonmar Exp $
*
* lockFile header
*/
-#ifndef mingw32_TARGET_OS
+#ifndef mingw32_HOST_OS
int lockFile(int fd, int for_writing, int exclusive);
int unlockFile(int fd);
Interface for code in runProcess.c (providing support for System.Process)
------------------------------------------------------------------------- */
-#if !defined(mingw32_TARGET_OS) && !defined(__MINGW32__)
+#if !defined(mingw32_HOST_OS) && !defined(__MINGW32__)
typedef pid_t ProcHandle;
#else
// Should really be intptr_t, but we don't have that type on the Haskell side
typedef long ProcHandle;
#endif
-#if !defined(mingw32_TARGET_OS) && !defined(__MINGW32__)
+#if !defined(mingw32_HOST_OS) && !defined(__MINGW32__)
extern ProcHandle runProcess( char *const args[],
char *workingDirectory, char **environment,
, LIB_DIR"/cbits"
#endif
-#if !defined(mingw32_TARGET_OS) && !defined(cygwin32_TARGET_OS)
+#if !defined(mingw32_HOST_OS) && !defined(cygwin32_HOST_OS)
hs-libraries: "HSbase"
#else
/*
#endif
extra-libs: "HSbase_cbits"
-#if defined(mingw32_TARGET_OS) || defined(__MINGW32__) || defined(_MSC_VER)
+#if defined(mingw32_HOST_OS) || defined(__MINGW32__) || defined(_MSC_VER)
, "wsock32", "msvcrt", "kernel32", "user32", "shell32"
#endif