#include "config.h"
import Control.Monad
+import System.Posix.Types
import Foreign
import Foreign.C
type CUtimbuf = ()
type CUtsname = ()
-type CDev = HTYPE_DEV_T
-type CIno = HTYPE_INO_T
-type CMode = HTYPE_MODE_T
-type COff = HTYPE_OFF_T
-type CPid = HTYPE_PID_T
-
-#ifdef mingw32_TARGET_OS
-type CSsize = HTYPE_SIZE_T
-#else
-type CGid = HTYPE_GID_T
-type CNlink = HTYPE_NLINK_T
-type CSsize = HTYPE_SSIZE_T
-type CUid = HTYPE_UID_T
-type CCc = HTYPE_CC_T
-type CSpeed = HTYPE_SPEED_T
-type CTcflag = HTYPE_TCFLAG_T
-#endif
-
-- ---------------------------------------------------------------------------
-- stat()-related stuff
fdGetMode :: Int -> IO IOMode
fdGetMode fd = do
+#ifdef mingw32_TARGET_OS
+ flags1 <- throwErrnoIfMinus1Retry "fdGetMode"
+ (c__setmode (fromIntegral fd) (fromIntegral o_WRONLY))
+ flags <- throwErrnoIfMinus1Retry "fdGetMode"
+ (c__setmode (fromIntegral fd) (fromIntegral flags1))
+#else
flags <- throwErrnoIfMinus1Retry "fdGetMode"
(c_fcntl_read (fromIntegral fd) const_f_getfl)
-
+#endif
let
wH = (flags .&. o_WRONLY) /= 0
aH = (flags .&. o_APPEND) /= 0
throwErrnoIfMinus1Retry_ "tcSetAttr" $
c_tcsetattr (fromIntegral fd) options p_tios
c_sigprocmask const_sig_setmask p_old_sigset nullPtr
+ return ()
#else
foreign import ccall unsafe "fork"
c_fork :: IO CPid
+foreign import ccall unsafe "getpid"
+ c_getpid :: IO CPid
+
foreign import ccall unsafe "fpathconf"
c_fpathconf :: CInt -> CInt -> IO CLong
-foreign import ccall unsafe "__hscore_sigemptyset"
- c_sigemptyset :: Ptr CSigset -> IO ()
-
foreign import ccall unsafe "link"
c_link :: CString -> CString -> IO CInt
foreign import ccall unsafe "pipe"
c_pipe :: Ptr CInt -> IO CInt
+foreign import ccall unsafe "__hscore_sigemptyset"
+ c_sigemptyset :: Ptr CSigset -> IO CInt
+
foreign import ccall unsafe "__hscore_sigaddset"
c_sigaddset :: Ptr CSigset -> CInt -> IO CInt
foreign import ccall unsafe "sigprocmask"
- c_sigprocmask :: CInt -> Ptr CSigset -> Ptr CSigset -> IO ()
+ c_sigprocmask :: CInt -> Ptr CSigset -> Ptr CSigset -> IO CInt
foreign import ccall unsafe "tcgetattr"
c_tcgetattr :: CInt -> Ptr CTermios -> IO CInt
foreign import ccall unsafe "waitpid"
c_waitpid :: CPid -> Ptr CInt -> CInt -> IO CPid
+#else
+foreign import ccall unsafe "_setmode"
+ c__setmode :: CInt -> CInt -> IO CInt
+
+-- /* Set "stdin" to have binary mode: */
+-- result = _setmode( _fileno( stdin ), _O_BINARY );
+-- if( result == -1 )
+-- perror( "Cannot set mode" );
+-- else
+-- printf( "'stdin' successfully changed to binary mode\n" );
#endif
-- POSIX flags only: