-{-# OPTIONS -fno-implicit-prelude -optc-DNON_POSIX_SOURCE #-}
+{-# OPTIONS -fno-implicit-prelude #-}
-- ---------------------------------------------------------------------------
--- $Id: PrelPosix.hsc,v 1.8 2001/06/29 13:41:43 simonmar Exp $
+-- $Id: PrelPosix.hsc,v 1.14 2001/09/26 10:35:41 simonmar Exp $
--
-- POSIX support layer for the standard libraries
--
--- NON_POSIX_SOURCE needed for the following features:
+-- Non-posix compliant in order to support the following features:
-- * S_ISSOCK (no sockets in POSIX)
module PrelPosix where
-#include "cbits/HsStd.h"
+-- See above comment for non-Posixness reasons.
+-- #include "PosixSource.h"
+
+#include "HsStd.h"
import PrelBase
import PrelNum
ioe_unknownfiletype = IOError Nothing UnsupportedOperation "fdType"
"unknown file type" Nothing
-foreign import "s_isreg_wrap" 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" 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" 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" 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 ()