{-# OPTIONS -fno-implicit-prelude #-}
-- ---------------------------------------------------------------------------
--- $Id: PrelPosix.hsc,v 1.11 2001/08/14 13:40:08 sewardj Exp $
+-- $Id: PrelPosix.hsc,v 1.14 2001/09/26 10:35:41 simonmar Exp $
--
-- POSIX support layer for the standard libraries
--
ioe_unknownfiletype = IOError Nothing UnsupportedOperation "fdType"
"unknown file type" Nothing
-foreign import "s_isreg_wrap" unsafe s_isreg :: CMode -> Bool
-#def inline int s_isreg_wrap(m) { return S_ISREG(m); }
+foreign import "s_isreg_PrelPosix_wrap" unsafe s_isreg :: CMode -> Bool
+#def inline int s_isreg_PrelPosix_wrap(m) { return S_ISREG(m); }
-foreign import "s_isdir_wrap" unsafe s_isdir :: CMode -> Bool
-#def inline int s_isdir_wrap(m) { return S_ISDIR(m); }
+foreign import "s_isdir_PrelPosix_wrap" unsafe s_isdir :: CMode -> Bool
+#def inline int s_isdir_PrelPosix_wrap(m) { return S_ISDIR(m); }
-foreign import "s_isfifo_wrap" unsafe s_isfifo :: CMode -> Bool
-#def inline int s_isfifo_wrap(m) { return S_ISFIFO(m); }
+foreign import "s_isfifo_PrelPosix_wrap" unsafe s_isfifo :: CMode -> Bool
+#def inline int s_isfifo_PrelPosix_wrap(m) { return S_ISFIFO(m); }
#ifndef mingw32_TARGET_OS
-foreign import "s_issock_wrap" unsafe s_issock :: CMode -> Bool
-#def inline int s_issock_wrap(m) { return S_ISSOCK(m); }
+foreign import "s_issock_PrelPosix_wrap" unsafe s_issock :: CMode -> Bool
+#def inline int s_issock_PrelPosix_wrap(m) { return S_ISSOCK(m); }
#else
s_issock :: CMode -> Bool
s_issock cmode = False
setNonBlockingFD fd = do
flags <- throwErrnoIfMinus1Retry "setNonBlockingFD"
(fcntl_read (fromIntegral fd) (#const F_GETFL))
- throwErrnoIfMinus1Retry "setNonBlockingFD"
- (fcntl_write (fromIntegral fd)
- (#const F_SETFL) (flags .|. #const O_NONBLOCK))
+ -- An error when setting O_NONBLOCK isn't fatal: on some systems
+ -- there are certain file handles on which this will fail (eg. /dev/null
+ -- on FreeBSD) so we throw away the return code from fcntl_write.
+ fcntl_write (fromIntegral fd)
+ (#const F_SETFL) (flags .|. #const O_NONBLOCK)
#else
-- bogus defns for win32
foreign import "fork" unsafe
fork :: IO CPid
-foreign import "sigemptyset" unsafe
+foreign import "sigemptyset_PrelPosix_wrap" unsafe
c_sigemptyset :: Ptr CSigset -> IO ()
+#def inline void sigemptyset_PrelPosix_wrap(sigset_t *set) { sigemptyset(set); }
foreign import "sigaddset" unsafe
c_sigaddset :: Ptr CSigset -> CInt -> IO ()