unix 2.7.0.1 → 2.7.1.0
raw patch · 48 files changed
+937/−880 lines, 48 filesdep ~basedep ~timesetup-changedPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: base, time
API changes (from Hackage documentation)
- System.Posix.DynamicLinker.Prim: instance Read RTLDFlags
- System.Posix.DynamicLinker.Prim: instance Show DL
- System.Posix.DynamicLinker.Prim: instance Show RTLDFlags
- System.Posix.IO: append :: OpenFileFlags -> Bool
- System.Posix.IO: exclusive :: OpenFileFlags -> Bool
- System.Posix.IO: noctty :: OpenFileFlags -> Bool
- System.Posix.IO: nonBlock :: OpenFileFlags -> Bool
- System.Posix.IO: trunc :: OpenFileFlags -> Bool
- System.Posix.IO.ByteString: append :: OpenFileFlags -> Bool
- System.Posix.IO.ByteString: exclusive :: OpenFileFlags -> Bool
- System.Posix.IO.ByteString: noctty :: OpenFileFlags -> Bool
- System.Posix.IO.ByteString: nonBlock :: OpenFileFlags -> Bool
- System.Posix.IO.ByteString: trunc :: OpenFileFlags -> Bool
- System.Posix.Process: childSystemTime :: ProcessTimes -> ClockTick
- System.Posix.Process: childUserTime :: ProcessTimes -> ClockTick
- System.Posix.Process: elapsedTime :: ProcessTimes -> ClockTick
- System.Posix.Process: systemTime :: ProcessTimes -> ClockTick
- System.Posix.Process: userTime :: ProcessTimes -> ClockTick
- System.Posix.Process.ByteString: childSystemTime :: ProcessTimes -> ClockTick
- System.Posix.Process.ByteString: childUserTime :: ProcessTimes -> ClockTick
- System.Posix.Process.ByteString: elapsedTime :: ProcessTimes -> ClockTick
- System.Posix.Process.ByteString: systemTime :: ProcessTimes -> ClockTick
- System.Posix.Process.ByteString: userTime :: ProcessTimes -> ClockTick
- System.Posix.Process.Internals: instance Eq ProcessStatus
- System.Posix.Process.Internals: instance Ord ProcessStatus
- System.Posix.Process.Internals: instance Show ProcessStatus
- System.Posix.Resource: hardLimit :: ResourceLimits -> ResourceLimit
- System.Posix.Resource: instance Eq Resource
- System.Posix.Resource: instance Eq ResourceLimit
- System.Posix.Resource: instance Eq ResourceLimits
- System.Posix.Resource: softLimit :: ResourceLimits -> ResourceLimit
- System.Posix.Semaphore: semCreate :: OpenSemFlags -> Bool
- System.Posix.Semaphore: semExclusive :: OpenSemFlags -> Bool
- System.Posix.SharedMem: shmCreate :: ShmOpenFlags -> Bool
- System.Posix.SharedMem: shmExclusive :: ShmOpenFlags -> Bool
- System.Posix.SharedMem: shmReadWrite :: ShmOpenFlags -> Bool
- System.Posix.SharedMem: shmTrunc :: ShmOpenFlags -> Bool
- System.Posix.Signals: instance Typeable Handler
- System.Posix.Signals: siginfoError :: SignalInfo -> Errno
- System.Posix.Signals: siginfoPid :: SignalSpecificInfo -> ProcessID
- System.Posix.Signals: siginfoSignal :: SignalInfo -> Signal
- System.Posix.Signals: siginfoSpecific :: SignalInfo -> SignalSpecificInfo
- System.Posix.Signals: siginfoStatus :: SignalSpecificInfo -> ProcessStatus
- System.Posix.Signals: siginfoUid :: SignalSpecificInfo -> UserID
- System.Posix.Unistd: machine :: SystemID -> String
- System.Posix.Unistd: nodeName :: SystemID -> String
- System.Posix.Unistd: release :: SystemID -> String
- System.Posix.Unistd: systemName :: SystemID -> String
- System.Posix.Unistd: version :: SystemID -> String
- System.Posix.User: groupID :: GroupEntry -> GroupID
- System.Posix.User: groupMembers :: GroupEntry -> [String]
- System.Posix.User: groupName :: GroupEntry -> String
- System.Posix.User: groupPassword :: GroupEntry -> String
- System.Posix.User: homeDirectory :: UserEntry -> String
- System.Posix.User: instance Eq GroupEntry
- System.Posix.User: instance Eq UserEntry
- System.Posix.User: instance Read GroupEntry
- System.Posix.User: instance Read UserEntry
- System.Posix.User: instance Show GroupEntry
- System.Posix.User: instance Show UserEntry
- System.Posix.User: userGecos :: UserEntry -> String
- System.Posix.User: userGroupID :: UserEntry -> GroupID
- System.Posix.User: userID :: UserEntry -> UserID
- System.Posix.User: userName :: UserEntry -> String
- System.Posix.User: userPassword :: UserEntry -> String
- System.Posix.User: userShell :: UserEntry -> String
+ System.Posix.DynamicLinker.Prim: instance GHC.Read.Read System.Posix.DynamicLinker.Prim.RTLDFlags
+ System.Posix.DynamicLinker.Prim: instance GHC.Show.Show System.Posix.DynamicLinker.Prim.DL
+ System.Posix.DynamicLinker.Prim: instance GHC.Show.Show System.Posix.DynamicLinker.Prim.RTLDFlags
+ System.Posix.Fcntl: AdviceDontNeed :: Advice
+ System.Posix.Fcntl: AdviceNoReuse :: Advice
+ System.Posix.Fcntl: AdviceNormal :: Advice
+ System.Posix.Fcntl: AdviceRandom :: Advice
+ System.Posix.Fcntl: AdviceSequential :: Advice
+ System.Posix.Fcntl: AdviceWillNeed :: Advice
+ System.Posix.Fcntl: data Advice
+ System.Posix.Fcntl: fileAdvise :: Fd -> FileOffset -> FileOffset -> Advice -> IO ()
+ System.Posix.Fcntl: fileAllocate :: Fd -> FileOffset -> FileOffset -> IO ()
+ System.Posix.Fcntl: instance GHC.Classes.Eq System.Posix.Fcntl.Advice
+ System.Posix.IO: [append] :: OpenFileFlags -> Bool
+ System.Posix.IO: [exclusive] :: OpenFileFlags -> Bool
+ System.Posix.IO: [noctty] :: OpenFileFlags -> Bool
+ System.Posix.IO: [nonBlock] :: OpenFileFlags -> Bool
+ System.Posix.IO: [trunc] :: OpenFileFlags -> Bool
+ System.Posix.IO.ByteString: [append] :: OpenFileFlags -> Bool
+ System.Posix.IO.ByteString: [exclusive] :: OpenFileFlags -> Bool
+ System.Posix.IO.ByteString: [noctty] :: OpenFileFlags -> Bool
+ System.Posix.IO.ByteString: [nonBlock] :: OpenFileFlags -> Bool
+ System.Posix.IO.ByteString: [trunc] :: OpenFileFlags -> Bool
+ System.Posix.Process: [childSystemTime] :: ProcessTimes -> ClockTick
+ System.Posix.Process: [childUserTime] :: ProcessTimes -> ClockTick
+ System.Posix.Process: [elapsedTime] :: ProcessTimes -> ClockTick
+ System.Posix.Process: [systemTime] :: ProcessTimes -> ClockTick
+ System.Posix.Process: [userTime] :: ProcessTimes -> ClockTick
+ System.Posix.Process.ByteString: [childSystemTime] :: ProcessTimes -> ClockTick
+ System.Posix.Process.ByteString: [childUserTime] :: ProcessTimes -> ClockTick
+ System.Posix.Process.ByteString: [elapsedTime] :: ProcessTimes -> ClockTick
+ System.Posix.Process.ByteString: [systemTime] :: ProcessTimes -> ClockTick
+ System.Posix.Process.ByteString: [userTime] :: ProcessTimes -> ClockTick
+ System.Posix.Process.Internals: instance GHC.Classes.Eq System.Posix.Process.Internals.ProcessStatus
+ System.Posix.Process.Internals: instance GHC.Classes.Ord System.Posix.Process.Internals.ProcessStatus
+ System.Posix.Process.Internals: instance GHC.Show.Show System.Posix.Process.Internals.ProcessStatus
+ System.Posix.Resource: [softLimit, hardLimit] :: ResourceLimits -> ResourceLimit
+ System.Posix.Resource: instance GHC.Classes.Eq System.Posix.Resource.Resource
+ System.Posix.Resource: instance GHC.Classes.Eq System.Posix.Resource.ResourceLimit
+ System.Posix.Resource: instance GHC.Classes.Eq System.Posix.Resource.ResourceLimits
+ System.Posix.Semaphore: [semCreate] :: OpenSemFlags -> Bool
+ System.Posix.Semaphore: [semExclusive] :: OpenSemFlags -> Bool
+ System.Posix.SharedMem: [shmCreate] :: ShmOpenFlags -> Bool
+ System.Posix.SharedMem: [shmExclusive] :: ShmOpenFlags -> Bool
+ System.Posix.SharedMem: [shmReadWrite] :: ShmOpenFlags -> Bool
+ System.Posix.SharedMem: [shmTrunc] :: ShmOpenFlags -> Bool
+ System.Posix.Signals: [siginfoError] :: SignalInfo -> Errno
+ System.Posix.Signals: [siginfoPid] :: SignalSpecificInfo -> ProcessID
+ System.Posix.Signals: [siginfoSignal] :: SignalInfo -> Signal
+ System.Posix.Signals: [siginfoSpecific] :: SignalInfo -> SignalSpecificInfo
+ System.Posix.Signals: [siginfoStatus] :: SignalSpecificInfo -> ProcessStatus
+ System.Posix.Signals: [siginfoUid] :: SignalSpecificInfo -> UserID
+ System.Posix.Signals.Exts: infoEvent :: Signal
+ System.Posix.Signals.Exts: sigINFO :: CInt
+ System.Posix.Unistd: [machine] :: SystemID -> String
+ System.Posix.Unistd: [nodeName] :: SystemID -> String
+ System.Posix.Unistd: [release] :: SystemID -> String
+ System.Posix.Unistd: [systemName] :: SystemID -> String
+ System.Posix.Unistd: [version] :: SystemID -> String
+ System.Posix.Unistd: fileSynchronise :: Fd -> IO ()
+ System.Posix.Unistd: fileSynchroniseDataOnly :: Fd -> IO ()
+ System.Posix.User: [groupID] :: GroupEntry -> GroupID
+ System.Posix.User: [groupMembers] :: GroupEntry -> [String]
+ System.Posix.User: [groupName] :: GroupEntry -> String
+ System.Posix.User: [groupPassword] :: GroupEntry -> String
+ System.Posix.User: [homeDirectory] :: UserEntry -> String
+ System.Posix.User: [userGecos] :: UserEntry -> String
+ System.Posix.User: [userGroupID] :: UserEntry -> GroupID
+ System.Posix.User: [userID] :: UserEntry -> UserID
+ System.Posix.User: [userName] :: UserEntry -> String
+ System.Posix.User: [userPassword] :: UserEntry -> String
+ System.Posix.User: [userShell] :: UserEntry -> String
+ System.Posix.User: instance GHC.Classes.Eq System.Posix.User.GroupEntry
+ System.Posix.User: instance GHC.Classes.Eq System.Posix.User.UserEntry
+ System.Posix.User: instance GHC.Read.Read System.Posix.User.GroupEntry
+ System.Posix.User: instance GHC.Read.Read System.Posix.User.UserEntry
+ System.Posix.User: instance GHC.Show.Show System.Posix.User.GroupEntry
+ System.Posix.User: instance GHC.Show.Show System.Posix.User.UserEntry
- System.Posix.Resource: ResourceLimits :: ResourceLimit -> ResourceLimit -> ResourceLimits
+ System.Posix.Resource: ResourceLimits :: ResourceLimit -> ResourceLimits
Files
- Setup.hs +1/−1
- System/Posix/ByteString/FilePath.hsc +5/−2
- System/Posix/Directory.hsc +30/−30
- System/Posix/Directory/ByteString.hsc +27/−27
- System/Posix/Directory/Common.hsc +9/−7
- System/Posix/DynamicLinker.hsc +10/−8
- System/Posix/DynamicLinker/ByteString.hsc +11/−8
- System/Posix/DynamicLinker/Common.hsc +10/−8
- System/Posix/DynamicLinker/Module.hsc +32/−30
- System/Posix/DynamicLinker/Module/ByteString.hsc +18/−15
- System/Posix/DynamicLinker/Prim.hsc +32/−40
- System/Posix/Env.hsc +4/−2
- System/Posix/Env/ByteString.hsc +11/−7
- System/Posix/Error.hs +11/−9
- System/Posix/Fcntl.hsc +104/−0
- System/Posix/Files.hsc +9/−4
- System/Posix/Files/ByteString.hsc +35/−30
- System/Posix/Files/Common.hsc +34/−34
- System/Posix/IO.hsc +3/−1
- System/Posix/IO/ByteString.hsc +3/−1
- System/Posix/IO/Common.hsc +4/−1
- System/Posix/Process.hsc +20/−18
- System/Posix/Process/ByteString.hsc +4/−1
- System/Posix/Process/Internals.hs +13/−13
- System/Posix/Resource.hsc +16/−14
- System/Posix/Semaphore.hsc +10/−8
- System/Posix/SharedMem.hsc +5/−3
- System/Posix/Signals/Exts.hsc +20/−30
- System/Posix/Temp.hsc +3/−1
- System/Posix/Temp/ByteString.hsc +3/−1
- System/Posix/Terminal.hsc +3/−1
- System/Posix/Terminal/ByteString.hsc +4/−2
- System/Posix/Terminal/Common.hsc +71/−71
- System/Posix/Time.hsc +8/−6
- System/Posix/Unistd.hsc +76/−18
- System/Posix/User.hsc +18/−18
- cbits/HsUnix.c +1/−8
- cbits/execvpe.c +25/−24
- cbits/ghcrts.c +15/−0
- changelog.md +36/−0
- config.guess +27/−165
- config.sub +13/−10
- configure +75/−108
- configure.ac +15/−49
- include/HsUnix.h +0/−7
- include/HsUnixConfig.h.in +21/−9
- include/execvpe.h +19/−17
- unix.cabal +13/−13
Setup.hs view
@@ -3,4 +3,4 @@ import Distribution.Simple main :: IO ()-main = defaultMainWithHooks defaultUserHooks+main = defaultMainWithHooks autoconfUserHooks
System/Posix/ByteString/FilePath.hsc view
@@ -1,12 +1,15 @@-#ifdef __GLASGOW_HASKELL__+#if __GLASGOW_HASKELL__ >= 709+{-# LANGUAGE Safe #-}+#elif __GLASGOW_HASKELL__ >= 703 {-# LANGUAGE Trustworthy #-} #endif+ ----------------------------------------------------------------------------- -- | -- Module : System.Posix.ByteString.FilePath -- Copyright : (c) The University of Glasgow 2002 -- License : BSD-style (see the file libraries/base/LICENSE)--- +-- -- Maintainer : libraries@haskell.org -- Stability : provisional -- Portability : non-portable (requires POSIX)
System/Posix/Directory.hsc view
@@ -8,7 +8,7 @@ -- Module : System.Posix.Directory -- Copyright : (c) The University of Glasgow 2002 -- License : BSD-style (see the file libraries/base/LICENSE)--- +-- -- Maintainer : libraries@haskell.org -- Stability : provisional -- Portability : non-portable (requires POSIX)@@ -27,7 +27,7 @@ DirStream, openDirStream, readDirStream,- rewindDirStream, + rewindDirStream, closeDirStream, DirStreamOffset, #ifdef HAVE_TELLDIR@@ -52,13 +52,13 @@ import System.Posix.Directory.Common import System.Posix.Internals (withFilePath, peekFilePath) --- | @createDirectory dir mode@ calls @mkdir@ to +-- | @createDirectory dir mode@ calls @mkdir@ to -- create a new directory, @dir@, with permissions based on -- @mode@. createDirectory :: FilePath -> FileMode -> IO () createDirectory name mode =- withFilePath name $ \s -> - throwErrnoPathIfMinus1Retry_ "createDirectory" name (c_mkdir s mode) + withFilePath name $ \s ->+ throwErrnoPathIfMinus1Retry_ "createDirectory" name (c_mkdir s mode) -- POSIX doesn't allow mkdir() to return EINTR, but it does on -- OS X (#5184), so we need the Retry variant here. @@ -88,19 +88,19 @@ resetErrno r <- c_readdir dirp ptr_dEnt if (r == 0)- then do dEnt <- peek ptr_dEnt- if (dEnt == nullPtr)- then return []- else do- entry <- (d_name dEnt >>= peekFilePath)- c_freeDirEnt dEnt- return entry- else do errno <- getErrno- if (errno == eINTR) then loop ptr_dEnt else do- let (Errno eo) = errno- if (eo == 0)- then return []- else throwErrno "readDirStream"+ then do dEnt <- peek ptr_dEnt+ if (dEnt == nullPtr)+ then return []+ else do+ entry <- (d_name dEnt >>= peekFilePath)+ c_freeDirEnt dEnt+ return entry+ else do errno <- getErrno+ if (errno == eINTR) then loop ptr_dEnt else do+ let (Errno eo) = errno+ if (eo == 0)+ then return []+ else throwErrno "readDirStream" -- traversing directories foreign import ccall unsafe "__hscore_readdir"@@ -120,17 +120,17 @@ p <- mallocBytes long_path_size go p long_path_size where go p bytes = do- p' <- c_getcwd p (fromIntegral bytes)- if p' /= nullPtr - then do s <- peekFilePath p'- free p'- return s- else do errno <- getErrno- if errno == eRANGE- then do let bytes' = bytes * 2- p'' <- reallocBytes p bytes'- go p'' bytes'- else throwErrno "getCurrentDirectory"+ p' <- c_getcwd p (fromIntegral bytes)+ if p' /= nullPtr+ then do s <- peekFilePath p'+ free p'+ return s+ else do errno <- getErrno+ if errno == eRANGE+ then do let bytes' = bytes * 2+ p'' <- reallocBytes p bytes'+ go p'' bytes'+ else throwErrno "getCurrentDirectory" foreign import ccall unsafe "getcwd" c_getcwd :: Ptr CChar -> CSize -> IO (Ptr CChar)@@ -143,7 +143,7 @@ changeWorkingDirectory :: FilePath -> IO () changeWorkingDirectory path = modifyIOError (`ioeSetFileName` path) $- withFilePath path $ \s -> + withFilePath path $ \s -> throwErrnoIfMinus1Retry_ "changeWorkingDirectory" (c_chdir s) foreign import ccall unsafe "chdir"
System/Posix/Directory/ByteString.hsc view
@@ -8,7 +8,7 @@ -- Module : System.Posix.Directory.ByteString -- Copyright : (c) The University of Glasgow 2002 -- License : BSD-style (see the file libraries/base/LICENSE)--- +-- -- Maintainer : libraries@haskell.org -- Stability : provisional -- Portability : non-portable (requires POSIX)@@ -27,7 +27,7 @@ DirStream, openDirStream, readDirStream,- rewindDirStream, + rewindDirStream, closeDirStream, DirStreamOffset, #ifdef HAVE_TELLDIR@@ -58,8 +58,8 @@ -- @mode@. createDirectory :: RawFilePath -> FileMode -> IO () createDirectory name mode =- withFilePath name $ \s -> - throwErrnoPathIfMinus1Retry_ "createDirectory" name (c_mkdir s mode) + withFilePath name $ \s ->+ throwErrnoPathIfMinus1Retry_ "createDirectory" name (c_mkdir s mode) -- POSIX doesn't allow mkdir() to return EINTR, but it does on -- OS X (#5184), so we need the Retry variant here. @@ -89,19 +89,19 @@ resetErrno r <- c_readdir dirp ptr_dEnt if (r == 0)- then do dEnt <- peek ptr_dEnt- if (dEnt == nullPtr)+ then do dEnt <- peek ptr_dEnt+ if (dEnt == nullPtr) then return BC.empty- else do- entry <- (d_name dEnt >>= peekFilePath)- c_freeDirEnt dEnt- return entry- else do errno <- getErrno- if (errno == eINTR) then loop ptr_dEnt else do- let (Errno eo) = errno- if (eo == 0)+ else do+ entry <- (d_name dEnt >>= peekFilePath)+ c_freeDirEnt dEnt+ return entry+ else do errno <- getErrno+ if (errno == eINTR) then loop ptr_dEnt else do+ let (Errno eo) = errno+ if (eo == 0) then return BC.empty- else throwErrno "readDirStream"+ else throwErrno "readDirStream" -- traversing directories foreign import ccall unsafe "__hscore_readdir"@@ -121,17 +121,17 @@ p <- mallocBytes long_path_size go p long_path_size where go p bytes = do- p' <- c_getcwd p (fromIntegral bytes)- if p' /= nullPtr - then do s <- peekFilePath p'- free p'- return s- else do errno <- getErrno- if errno == eRANGE- then do let bytes' = bytes * 2- p'' <- reallocBytes p bytes'- go p'' bytes'- else throwErrno "getCurrentDirectory"+ p' <- c_getcwd p (fromIntegral bytes)+ if p' /= nullPtr+ then do s <- peekFilePath p'+ free p'+ return s+ else do errno <- getErrno+ if errno == eRANGE+ then do let bytes' = bytes * 2+ p'' <- reallocBytes p bytes'+ go p'' bytes'+ else throwErrno "getCurrentDirectory" foreign import ccall unsafe "getcwd" c_getcwd :: Ptr CChar -> CSize -> IO (Ptr CChar)@@ -144,7 +144,7 @@ changeWorkingDirectory :: RawFilePath -> IO () changeWorkingDirectory path = modifyIOError (`ioeSetFileName` (BC.unpack path)) $- withFilePath path $ \s -> + withFilePath path $ \s -> throwErrnoIfMinus1Retry_ "changeWorkingDirectory" (c_chdir s) foreign import ccall unsafe "chdir"
System/Posix/Directory/Common.hsc view
@@ -1,4 +1,6 @@-#ifdef __GLASGOW_HASKELL__+#if __GLASGOW_HASKELL__ >= 709+{-# LANGUAGE Safe #-}+#elif __GLASGOW_HASKELL__ >= 703 {-# LANGUAGE Trustworthy #-} #endif @@ -7,7 +9,7 @@ -- Module : System.Posix.Directory.Common -- Copyright : (c) The University of Glasgow 2002 -- License : BSD-style (see the file libraries/base/LICENSE)--- +-- -- Maintainer : libraries@haskell.org -- Stability : provisional -- Portability : non-portable (requires POSIX)@@ -62,24 +64,24 @@ #ifdef HAVE_SEEKDIR seekDirStream :: DirStream -> DirStreamOffset -> IO () seekDirStream (DirStream dirp) (DirStreamOffset off) =- c_seekdir dirp off+ c_seekdir dirp (fromIntegral off) -- TODO: check for CLong/COff overflow foreign import ccall unsafe "seekdir"- c_seekdir :: Ptr CDir -> COff -> IO ()+ c_seekdir :: Ptr CDir -> CLong -> IO () #endif #ifdef HAVE_TELLDIR tellDirStream :: DirStream -> IO DirStreamOffset tellDirStream (DirStream dirp) = do off <- c_telldir dirp- return (DirStreamOffset off)+ return (DirStreamOffset (fromIntegral off)) -- TODO: check for overflow foreign import ccall unsafe "telldir"- c_telldir :: Ptr CDir -> IO COff+ c_telldir :: Ptr CDir -> IO CLong #endif changeWorkingDirectoryFd :: Fd -> IO ()-changeWorkingDirectoryFd (Fd fd) = +changeWorkingDirectoryFd (Fd fd) = throwErrnoIfMinus1Retry_ "changeWorkingDirectoryFd" (c_fchdir fd) foreign import ccall unsafe "fchdir"
System/Posix/DynamicLinker.hsc view
@@ -1,4 +1,6 @@-#ifdef __GLASGOW_HASKELL__+#if __GLASGOW_HASKELL__ >= 709+{-# LANGUAGE Safe #-}+#elif __GLASGOW_HASKELL__ >= 703 {-# LANGUAGE Trustworthy #-} #endif -----------------------------------------------------------------------------@@ -6,7 +8,7 @@ -- Module : System.Posix.DynamicLinker -- Copyright : (c) Volker Stolz <vs@foldr.org> 2003 -- License : BSD-style (see the file libraries/base/LICENSE)--- +-- -- Maintainer : vs@foldr.org -- Stability : provisional -- Portability : non-portable (requires POSIX)@@ -27,16 +29,16 @@ -- Usage: -- ******--- +-- -- Let's assume you want to open a local shared library \'foo\' (.\/libfoo.so) -- offering a function -- @char \* mogrify (char\*,int)@ -- and invoke @str = mogrify("test",1)@:--- --- +--+-- -- type Fun = CString -> Int -> IO CString -- foreign import dynamic unsafe fun__ :: FunPtr Fun -> Fun--- +-- -- withDL "libfoo.so" [RTLD_NOW] \$ \\ mod -> do -- funptr <- dlsym mod "mogrify" -- let fun = fun__ funptr@@ -44,7 +46,7 @@ -- strptr <- fun str 1 -- strstr <- peekCString strptr -- ...--- +-- where @@ -54,7 +56,7 @@ #include "HsUnix.h" import Control.Exception ( bracket )-import Control.Monad ( liftM )+import Control.Monad ( liftM ) import Foreign import System.Posix.Internals ( withFilePath )
System/Posix/DynamicLinker/ByteString.hsc view
@@ -1,12 +1,15 @@-#ifdef __GLASGOW_HASKELL__+#if __GLASGOW_HASKELL__ >= 709+{-# LANGUAGE Safe #-}+#elif __GLASGOW_HASKELL__ >= 703 {-# LANGUAGE Trustworthy #-} #endif+ ----------------------------------------------------------------------------- -- | -- Module : System.Posix.DynamicLinker.ByteString -- Copyright : (c) Volker Stolz <vs@foldr.org> 2003 -- License : BSD-style (see the file libraries/base/LICENSE)--- +-- -- Maintainer : vs@foldr.org -- Stability : provisional -- Portability : non-portable (requires POSIX)@@ -27,16 +30,16 @@ -- Usage: -- ******--- +-- -- Let's assume you want to open a local shared library \'foo\' (.\/libfoo.so) -- offering a function -- @char \* mogrify (char\*,int)@ -- and invoke @str = mogrify("test",1)@:--- --- +--+-- -- type Fun = CString -> Int -> IO CString -- foreign import dynamic unsafe fun__ :: FunPtr Fun -> Fun--- +-- -- withDL "libfoo.so" [RTLD_NOW] \$ \\ mod -> do -- funptr <- dlsym mod "mogrify" -- let fun = fun__ funptr@@ -44,7 +47,7 @@ -- strptr <- fun str 1 -- strstr <- peekCString strptr -- ...--- +-- where @@ -54,7 +57,7 @@ #include "HsUnix.h" import Control.Exception ( bracket )-import Control.Monad ( liftM )+import Control.Monad ( liftM ) import Foreign import System.Posix.ByteString.FilePath
System/Posix/DynamicLinker/Common.hsc view
@@ -1,4 +1,6 @@-#ifdef __GLASGOW_HASKELL__+#if __GLASGOW_HASKELL__ >= 709+{-# LANGUAGE Safe #-}+#elif __GLASGOW_HASKELL__ >= 703 {-# LANGUAGE Trustworthy #-} #endif -----------------------------------------------------------------------------@@ -6,7 +8,7 @@ -- Module : System.Posix.DynamicLinker.Common -- Copyright : (c) Volker Stolz <vs@foldr.org> 2003 -- License : BSD-style (see the file libraries/base/LICENSE)--- +-- -- Maintainer : vs@foldr.org -- Stability : provisional -- Portability : non-portable (requires POSIX)@@ -27,16 +29,16 @@ -- Usage: -- ******--- +-- -- Let's assume you want to open a local shared library \'foo\' (.\/libfoo.so) -- offering a function -- @char \* mogrify (char\*,int)@ -- and invoke @str = mogrify("test",1)@:--- --- +--+-- -- type Fun = CString -> Int -> IO CString -- foreign import dynamic unsafe fun__ :: FunPtr Fun -> Fun--- +-- -- withDL "libfoo.so" [RTLD_NOW] \$ \\ mod -> do -- funptr <- dlsym mod "mogrify" -- let fun = fun__ funptr@@ -44,7 +46,7 @@ -- strptr <- fun str 1 -- strstr <- peekCString strptr -- ...--- +-- where @@ -59,7 +61,7 @@ dlclose h = error $ "dlclose: invalid argument" ++ (show h) dlerror :: IO String-dlerror = c_dlerror >>= peekCString +dlerror = c_dlerror >>= peekCString -- |'dlsym' returns the address binding of the symbol described in @symbol@, -- as it occurs in the shared object identified by @source@.
System/Posix/DynamicLinker/Module.hsc view
@@ -1,4 +1,6 @@-#ifdef __GLASGOW_HASKELL__+#if __GLASGOW_HASKELL__ >= 709+{-# LANGUAGE Safe #-}+#elif __GLASGOW_HASKELL__ >= 703 {-# LANGUAGE Trustworthy #-} #endif -----------------------------------------------------------------------------@@ -6,7 +8,7 @@ -- Module : System.Posix.DynamicLinker.Module -- Copyright : (c) Volker Stolz <vs@foldr.org> 2003 -- License : BSD-style (see the file libraries/base/LICENSE)--- +-- -- Maintainer : vs@foldr.org -- Stability : provisional -- Portability : non-portable (requires POSIX)@@ -21,15 +23,15 @@ -- Usage: -- ******--- +-- -- Let's assume you want to open a local shared library 'foo' (./libfoo.so) -- offering a function -- char * mogrify (char*,int) -- and invoke str = mogrify("test",1):--- +-- -- type Fun = CString -> Int -> IO CString -- foreign import dynamic unsafe fun__ :: FunPtr Fun -> Fun--- +-- -- withModule (Just ".") ("libfoo.so") [RTLD_NOW] $ \ mod -> do -- funptr <- moduleSymbol mod "mogrify" -- let fun = fun__ funptr@@ -43,16 +45,16 @@ , moduleSymbol -- :: Source -> String -> IO (FunPtr a) , moduleClose -- :: Module -> IO Bool , moduleError -- :: IO String- , withModule -- :: Maybe String - -- -> String - -- -> [ModuleFlags ]- -- -> (Module -> IO a) - -- -> IO a- , withModule_ -- :: Maybe String - -- -> String - -- -> [ModuleFlags] - -- -> (Module -> IO a) - -- -> IO ()+ , withModule -- :: Maybe String+ -- -> String+ -- -> [ModuleFlags ]+ -- -> (Module -> IO a)+ -- -> IO a+ , withModule_ -- :: Maybe String+ -- -> String+ -- -> [ModuleFlags]+ -- -> (Module -> IO a)+ -- -> IO () ) where @@ -82,38 +84,38 @@ moduleSymbol file sym = dlsym (DLHandle (unModule file)) sym -- Closes a module (EXPORTED)--- +-- moduleClose :: Module -> IO () moduleClose file = dlclose (DLHandle (unModule file)) -- Gets a string describing the last module error (EXPORTED)--- +-- moduleError :: IO String moduleError = dlerror -- Convenience function, cares for module open- & closing -- additionally returns status of `moduleClose' (EXPORTED)--- -withModule :: Maybe String - -> String - -> [RTLDFlags]- -> (Module -> IO a) - -> IO a+--+withModule :: Maybe String+ -> String+ -> [RTLDFlags]+ -> (Module -> IO a)+ -> IO a withModule mdir file flags p = do let modPath = case mdir of Nothing -> file- Just dir -> dir ++ if ((head (reverse dir)) == '/')+ Just dir -> dir ++ if ((head (reverse dir)) == '/') then file- else ('/':file)+ else ('/':file) modu <- moduleOpen modPath flags result <- p modu moduleClose modu return result -withModule_ :: Maybe String - -> String - -> [RTLDFlags]- -> (Module -> IO a) - -> IO ()+withModule_ :: Maybe String+ -> String+ -> [RTLDFlags]+ -> (Module -> IO a)+ -> IO () withModule_ dir file flags p = withModule dir file flags p >>= \ _ -> return ()
System/Posix/DynamicLinker/Module/ByteString.hsc view
@@ -1,12 +1,15 @@-#ifdef __GLASGOW_HASKELL__+#if __GLASGOW_HASKELL__ >= 709+{-# LANGUAGE Safe #-}+#elif __GLASGOW_HASKELL__ >= 703 {-# LANGUAGE Trustworthy #-} #endif+ ----------------------------------------------------------------------------- -- | -- Module : System.Posix.DynamicLinker.Module.ByteString -- Copyright : (c) Volker Stolz <vs@foldr.org> 2003 -- License : BSD-style (see the file libraries/base/LICENSE)--- +-- -- Maintainer : vs@foldr.org -- Stability : provisional -- Portability : non-portable (requires POSIX)@@ -21,15 +24,15 @@ -- Usage: -- ******--- +-- -- Let's assume you want to open a local shared library 'foo' (./libfoo.so) -- offering a function -- char * mogrify (char*,int) -- and invoke str = mogrify("test",1):--- +-- -- type Fun = CString -> Int -> IO CString -- foreign import dynamic unsafe fun__ :: FunPtr Fun -> Fun--- +-- -- withModule (Just ".") ("libfoo.so") [RTLD_NOW] $ \ mod -> do -- funptr <- moduleSymbol mod "mogrify" -- let fun = fun__ funptr@@ -43,16 +46,16 @@ , moduleSymbol -- :: Source -> String -> IO (FunPtr a) , moduleClose -- :: Module -> IO Bool , moduleError -- :: IO String- , withModule -- :: Maybe String - -- -> String - -- -> [ModuleFlags ]- -- -> (Module -> IO a) - -- -> IO a- , withModule_ -- :: Maybe String - -- -> String - -- -> [ModuleFlags] - -- -> (Module -> IO a) - -- -> IO ()+ , withModule -- :: Maybe String+ -- -> String+ -- -> [ModuleFlags ]+ -- -> (Module -> IO a)+ -- -> IO a+ , withModule_ -- :: Maybe String+ -- -> String+ -- -> [ModuleFlags]+ -- -> (Module -> IO a)+ -- -> IO () ) where
System/Posix/DynamicLinker/Prim.hsc view
@@ -1,12 +1,15 @@ #ifdef __GLASGOW_HASKELL__ {-# LANGUAGE Trustworthy #-}+#if __GLASGOW_HASKELL__ >= 709+{-# OPTIONS_GHC -fno-warn-trustworthy-safe #-} #endif+#endif ----------------------------------------------------------------------------- -- | -- Module : System.Posix.DynamicLinker.Prim -- Copyright : (c) Volker Stolz <vs@foldr.org> 2003 -- License : BSD-style (see the file libraries/base/LICENSE)--- +-- -- Maintainer : vs@foldr.org -- Stability : provisional -- Portability : non-portable (requires POSIX)@@ -36,30 +39,27 @@ #include "HsUnix.h" -import Data.Bits ( (.|.) )-import Foreign.Ptr ( Ptr, FunPtr, nullPtr )+import Data.Bits ( (.|.) )+import Foreign.Ptr ( Ptr, FunPtr, nullPtr ) import Foreign.C.Types-import Foreign.C.String ( CString )+import Foreign.C.String ( CString ) --- RTLD_NEXT madness--- On some host (e.g. SuSe Linux 7.2) RTLD_NEXT is not visible--- without setting _GNU_SOURCE. Since we don't want to set this--- flag, here's a different solution: You can use the Haskell--- function 'haveRtldNext' to check wether the flag is available--- to you. Ideally, this will be optimized by the compiler so--- that it should be as efficient as an #ifdef.--- If you fail to test the flag and use it although it is--- undefined, 'packOneModuleFlag' will bomb.--- The same applies to RTLD_LOCAL which isn't available on--- cygwin. +-- |On some hosts (e.g. SuSe and Ubuntu Linux) 'RTLD_NEXT' (and+-- 'RTLD_DEFAULT') are not visible without setting the macro+-- '_GNU_SOURCE'. Since we don't want to define this macro, you can use+-- the function 'haveRtldNext' to check wether the flag `Next` is+-- available. Ideally, this will be optimized by the compiler so that it+-- should be as efficient as an #ifdef.+--+-- If you fail to test the flag and use it although it is undefined,+-- 'packDL' will throw an error.+ haveRtldNext :: Bool #ifdef HAVE_RTLDNEXT haveRtldNext = True- foreign import ccall unsafe "__hsunix_rtldNext" rtldNext :: Ptr a- #else /* HAVE_RTLDNEXT */ haveRtldNext = False #endif /* HAVE_RTLDNEXT */@@ -69,17 +69,16 @@ #endif /* HAVE_RTLDDEFAULT */ haveRtldLocal :: Bool--#ifdef HAVE_RTLDLOCAL haveRtldLocal = True-#else /* HAVE_RTLDLOCAL */-haveRtldLocal = False-#endif /* HAVE_RTLDLOCAL */+{-# DEPRECATED haveRtldLocal "defaults to True" #-} -data RTLDFlags ++-- |Flags for 'System.Posix.DynamicLinker.dlopen'.++data RTLDFlags = RTLD_LAZY | RTLD_NOW- | RTLD_GLOBAL + | RTLD_GLOBAL | RTLD_LOCAL deriving (Show, Read) @@ -93,40 +92,33 @@ packRTLDFlag :: RTLDFlags -> CInt packRTLDFlag RTLD_LAZY = #const RTLD_LAZY--#ifdef HAVE_RTLDNOW packRTLDFlag RTLD_NOW = #const RTLD_NOW-#else /* HAVE_RTLDNOW */-packRTLDFlag RTLD_NOW = error "RTLD_NOW not available"-#endif /* HAVE_RTLDNOW */--#ifdef HAVE_RTLDGLOBAL packRTLDFlag RTLD_GLOBAL = #const RTLD_GLOBAL-#else /* HAVE_RTLDGLOBAL */-packRTLDFlag RTLD_GLOBAL = error "RTLD_GLOBAL not available"-#endif--#ifdef HAVE_RTLDLOCAL packRTLDFlag RTLD_LOCAL = #const RTLD_LOCAL-#else /* HAVE_RTLDLOCAL */-packRTLDFlag RTLD_LOCAL = error "RTLD_LOCAL not available"-#endif /* HAVE_RTLDLOCAL */ + -- |Flags for 'System.Posix.DynamicLinker.dlsym'. Notice that 'Next'--- might not be available on your particular platform!+-- might not be available on your particular platform! Use+-- `haveRtldNext`.+--+-- If 'RTLD_DEFAULT' is not defined on your platform, `packDL` `Default`+-- reduces to 'nullPtr'. data DL = Null | Next | Default | DLHandle (Ptr ()) deriving (Show) packDL :: DL -> Ptr () packDL Null = nullPtr+ #ifdef HAVE_RTLDNEXT packDL Next = rtldNext #else packDL Next = error "RTLD_NEXT not available" #endif+ #ifdef HAVE_RTLDDEFAULT packDL Default = rtldDefault #else packDL Default = nullPtr #endif+ packDL (DLHandle h) = h
System/Posix/Env.hsc view
@@ -1,4 +1,6 @@-#ifdef __GLASGOW_HASKELL__+#if __GLASGOW_HASKELL__ >= 709+{-# LANGUAGE Safe #-}+#elif __GLASGOW_HASKELL__ >= 703 {-# LANGUAGE Trustworthy #-} #endif -----------------------------------------------------------------------------@@ -132,7 +134,7 @@ putEnv keyvalue = do s <- newFilePath keyvalue -- Do not free `s` after calling putenv. -- According to SUSv2, the string passed to putenv- -- becomes part of the enviroment. #7342+ -- becomes part of the environment. #7342 throwErrnoIfMinus1_ "putenv" (c_putenv s) #if !MIN_VERSION_base(4,7,0) where
System/Posix/Env/ByteString.hsc view
@@ -1,12 +1,16 @@ #ifdef __GLASGOW_HASKELL__ {-# LANGUAGE Trustworthy #-}+#if __GLASGOW_HASKELL__ >= 709+{-# OPTIONS_GHC -fno-warn-trustworthy-safe #-} #endif+#endif+ ----------------------------------------------------------------------------- -- | -- Module : System.Posix.Env.ByteString -- Copyright : (c) The University of Glasgow 2002 -- License : BSD-style (see the file libraries/base/LICENSE)--- +-- -- Maintainer : libraries@haskell.org -- Stability : provisional -- Portability : non-portable (requires POSIX)@@ -18,10 +22,10 @@ module System.Posix.Env.ByteString ( -- * Environment Variables getEnv- , getEnvDefault- , getEnvironmentPrim- , getEnvironment- , putEnv+ , getEnvDefault+ , getEnvironmentPrim+ , getEnvironment+ , putEnv , setEnv , unsetEnv @@ -34,7 +38,7 @@ import Foreign import Foreign.C import Control.Monad ( liftM )-import Data.Maybe ( fromMaybe )+import Data.Maybe ( fromMaybe ) import qualified Data.ByteString as B import qualified Data.ByteString.Char8 as BC@@ -130,7 +134,7 @@ B.useAsCString key $ \ keyP -> B.useAsCString value $ \ valueP -> throwErrnoIfMinus1_ "setenv" $- c_setenv keyP valueP (fromIntegral (fromEnum ovrwrt))+ c_setenv keyP valueP (fromIntegral (fromEnum ovrwrt)) foreign import ccall unsafe "setenv" c_setenv :: CString -> CString -> CInt -> IO CInt
System/Posix/Error.hs view
@@ -1,5 +1,7 @@ {-# LANGUAGE CPP #-}-#ifdef __GLASGOW_HASKELL__+#if __GLASGOW_HASKELL__ >= 709+{-# LANGUAGE Safe #-}+#elif __GLASGOW_HASKELL__ >= 703 {-# LANGUAGE Trustworthy #-} #endif -----------------------------------------------------------------------------@@ -7,7 +9,7 @@ -- Module : System.Posix.Error -- Copyright : (c) The University of Glasgow 2002 -- License : BSD-style (see the file libraries/base/LICENSE)--- +-- -- Maintainer : libraries@haskell.org -- Stability : provisional -- Portability : non-portable (requires POSIX)@@ -17,14 +19,14 @@ ----------------------------------------------------------------------------- module System.Posix.Error (- throwErrnoPath,- throwErrnoPathIf, - throwErrnoPathIf_,+ throwErrnoPath,+ throwErrnoPathIf,+ throwErrnoPathIf_, throwErrnoPathIfRetry,- throwErrnoPathIfNull,- throwErrnoPathIfNullRetry,- throwErrnoPathIfMinus1,- throwErrnoPathIfMinus1_,+ throwErrnoPathIfNull,+ throwErrnoPathIfNullRetry,+ throwErrnoPathIfMinus1,+ throwErrnoPathIfMinus1_, throwErrnoPathIfMinus1Retry, throwErrnoPathIfMinus1Retry_ ) where
+ System/Posix/Fcntl.hsc view
@@ -0,0 +1,104 @@+{-# LANGUAGE CApiFFI #-}+#if __GLASGOW_HASKELL__ >= 709+{-# LANGUAGE Safe #-}+#elif __GLASGOW_HASKELL__ >= 703+{-# LANGUAGE Trustworthy #-}+#endif+-----------------------------------------------------------------------------+-- |+-- Module : System.Posix.Fcntl+-- Copyright : (c) The University of Glasgow 2014+-- License : BSD-style (see the file LICENSE)+--+-- Maintainer : libraries@haskell.org+-- Stability : provisional+-- Portability : non-portable (requires POSIX)+--+-- POSIX file control support+--+-- /Since: 2.7.1.0/+-----------------------------------------------------------------------------++#include "HsUnix.h"++module System.Posix.Fcntl (+ -- * File allocation+ Advice(..), fileAdvise,+ fileAllocate,+ ) where++#if HAVE_POSIX_FALLOCATE || HAVE_POSIX_FADVISE+import Foreign.C+#endif+import System.Posix.Types++#if !HAVE_POSIX_FALLOCATE+import System.IO.Error ( ioeSetLocation )+import GHC.IO.Exception ( unsupportedOperation )+#endif++-- -----------------------------------------------------------------------------+-- File control++-- | Advice parameter for 'fileAdvise' operation.+--+-- For more details, see documentation of @posix_fadvise(2)@.+--+-- /Since: 2.7.1.0/+data Advice+ = AdviceNormal+ | AdviceRandom+ | AdviceSequential+ | AdviceWillNeed+ | AdviceDontNeed+ | AdviceNoReuse+ deriving Eq++-- | Performs @posix_fadvise(2)@ operation on file-descriptor.+--+-- If platform does not provide @posix_fadvise(2)@ 'fileAdvise'+-- becomes a no-op.+--+-- (use @#if HAVE_POSIX_FADVISE@ CPP guard to detect availability)+--+-- /Since: 2.7.1.0/+fileAdvise :: Fd -> FileOffset -> FileOffset -> Advice -> IO ()+#if HAVE_POSIX_FADVISE+fileAdvise fd off len adv = do+ throwErrnoIfMinus1_ "fileAdvise" (c_posix_fadvise (fromIntegral fd) (fromIntegral off) (fromIntegral len) (packAdvice adv))++foreign import capi safe "fcntl.h posix_fadvise"+ c_posix_fadvise :: CInt -> COff -> COff -> CInt -> IO CInt++packAdvice :: Advice -> CInt+packAdvice AdviceNormal = (#const POSIX_FADV_NORMAL)+packAdvice AdviceRandom = (#const POSIX_FADV_RANDOM)+packAdvice AdviceSequential = (#const POSIX_FADV_SEQUENTIAL)+packAdvice AdviceWillNeed = (#const POSIX_FADV_WILLNEED)+packAdvice AdviceDontNeed = (#const POSIX_FADV_DONTNEED)+packAdvice AdviceNoReuse = (#const POSIX_FADV_NOREUSE)+#else+fileAdvise _ _ _ _ = return ()+#endif++-- | Performs @posix_fallocate(2)@ operation on file-descriptor.+--+-- Throws 'IOError' (\"unsupported operation\") if platform does not+-- provide @posix_fallocate(2)@.+--+-- (use @#if HAVE_POSIX_FALLOCATE@ CPP guard to detect availability).+--+-- /Since: 2.7.1.0/+fileAllocate :: Fd -> FileOffset -> FileOffset -> IO ()+#if HAVE_POSIX_FALLOCATE+fileAllocate fd off len = do+ throwErrnoIfMinus1_ "fileAllocate" (c_posix_fallocate (fromIntegral fd) (fromIntegral off) (fromIntegral len))++foreign import capi safe "fcntl.h posix_fallocate"+ c_posix_fallocate :: CInt -> COff -> COff -> IO CInt+#else+{-# WARNING fileAllocate+ "operation will throw 'IOError' \"unsupported operation\" (CPP guard: @#if HAVE_POSIX_FALLOCATE@)" #-}+fileAllocate _ _ _ = ioError (ioeSetLocation unsupportedOperation+ "fileAllocate")+#endif
System/Posix/Files.hsc view
@@ -1,6 +1,10 @@-#ifdef __GLASGOW_HASKELL__+#if __GLASGOW_HASKELL__ >= 709+{-# LANGUAGE Safe #-}+#elif __GLASGOW_HASKELL__ >= 703 {-# LANGUAGE Trustworthy #-} #endif+{-# LANGUAGE CApiFFI #-}+ ----------------------------------------------------------------------------- -- | -- Module : System.Posix.Files@@ -99,7 +103,7 @@ import System.Posix.Error import System.Posix.Internals -import Data.Time.Clock.POSIX+import Data.Time.Clock.POSIX (POSIXTime) -- ----------------------------------------------------------------------------- -- chmod()@@ -152,7 +156,8 @@ if (r == 0) then return True else do err <- getErrno- if (err == eACCES || err == eROFS || err == eTXTBSY)+ if (err == eACCES || err == eROFS || err == eTXTBSY ||+ err == ePERM) then return False else throwErrnoPath "fileAccess" name @@ -420,7 +425,7 @@ withFilePath file $ \s -> throwErrnoPathIfMinus1_ "setFileSize" file (c_truncate s off) -foreign import ccall unsafe "truncate"+foreign import capi unsafe "HsUnix.h truncate" c_truncate :: CString -> COff -> IO CInt -- -----------------------------------------------------------------------------
System/Posix/Files/ByteString.hsc view
@@ -1,12 +1,16 @@-#ifdef __GLASGOW_HASKELL__+#if __GLASGOW_HASKELL__ >= 709+{-# LANGUAGE Safe #-}+#elif __GLASGOW_HASKELL__ >= 703 {-# LANGUAGE Trustworthy #-} #endif+{-# LANGUAGE CApiFFI #-}+ ----------------------------------------------------------------------------- -- | -- Module : System.Posix.Files.ByteString -- Copyright : (c) The University of Glasgow 2002 -- License : BSD-style (see the file libraries/base/LICENSE)--- +-- -- Maintainer : libraries@haskell.org -- Stability : provisional -- Portability : non-portable (requires POSIX)@@ -60,7 +64,7 @@ isDirectory, isSymbolicLink, isSocket, -- * Creation- createNamedPipe, + createNamedPipe, createDevice, -- * Hard links@@ -104,7 +108,7 @@ import System.Posix.Files.Common import System.Posix.ByteString.FilePath -import Data.Time.Clock.POSIX+import Data.Time.Clock.POSIX (POSIXTime) -- ----------------------------------------------------------------------------- -- chmod()@@ -141,26 +145,27 @@ -- -- Note: calls @access@. fileExist :: RawFilePath -> IO Bool-fileExist name = +fileExist name = withFilePath name $ \s -> do r <- c_access s (#const F_OK) if (r == 0)- then return True- else do err <- getErrno- if (err == eNOENT)- then return False- else throwErrnoPath "fileExist" name+ then return True+ else do err <- getErrno+ if (err == eNOENT)+ then return False+ else throwErrnoPath "fileExist" name access :: RawFilePath -> CMode -> IO Bool-access name flags = +access name flags = withFilePath name $ \s -> do r <- c_access s (fromIntegral flags) if (r == 0)- then return True- else do err <- getErrno- if (err == eACCES)- then return False- else throwErrnoPath "fileAccess" name+ then return True+ else do err <- getErrno+ if (err == eACCES || err == eROFS || err == eTXTBSY ||+ err == ePERM)+ then return False+ else throwErrnoPath "fileAccess" name -- | @getFileStatus path@ calls gets the @FileStatus@ information (user ID,@@ -169,9 +174,9 @@ -- Note: calls @stat@. getFileStatus :: RawFilePath -> IO FileStatus getFileStatus path = do- fp <- mallocForeignPtrBytes (#const sizeof(struct stat)) + fp <- mallocForeignPtrBytes (#const sizeof(struct stat)) withForeignPtr fp $ \p ->- withFilePath path $ \s -> + withFilePath path $ \s -> throwErrnoPathIfMinus1Retry_ "getFileStatus" path (c_stat s p) return (FileStatus fp) @@ -182,9 +187,9 @@ -- Note: calls @lstat@. getSymbolicLinkStatus :: RawFilePath -> IO FileStatus getSymbolicLinkStatus path = do- fp <- mallocForeignPtrBytes (#const sizeof(struct stat)) + fp <- mallocForeignPtrBytes (#const sizeof(struct stat)) withForeignPtr fp $ \p ->- withFilePath path $ \s -> + withFilePath path $ \s -> throwErrnoPathIfMinus1_ "getSymbolicLinkStatus" path (c_lstat s p) return (FileStatus fp) @@ -200,7 +205,7 @@ -- Note: calls @mkfifo@. createNamedPipe :: RawFilePath -> FileMode -> IO () createNamedPipe name mode = do- withFilePath name $ \s -> + withFilePath name $ \s -> throwErrnoPathIfMinus1_ "createNamedPipe" name (c_mkfifo s mode) -- | @createDevice path mode dev@ creates either a regular or a special file@@ -216,7 +221,7 @@ withFilePath path $ \s -> throwErrnoPathIfMinus1_ "createDevice" path (c_mknod s mode dev) -foreign import ccall unsafe "__hsunix_mknod" +foreign import ccall unsafe "__hsunix_mknod" c_mknod :: CString -> CMode -> CDev -> IO CInt -- -----------------------------------------------------------------------------@@ -275,8 +280,8 @@ readSymbolicLink file = allocaArray0 (#const PATH_MAX) $ \buf -> do withFilePath file $ \s -> do- len <- throwErrnoPathIfMinus1 "readSymbolicLink" file $ - c_readlink s buf (#const PATH_MAX)+ len <- throwErrnoPathIfMinus1 "readSymbolicLink" file $+ c_readlink s buf (#const PATH_MAX) peekFilePathLen (buf,fromIntegral len) foreign import ccall unsafe "readlink"@@ -323,7 +328,7 @@ setSymbolicLinkOwnerAndGroup name uid gid = do withFilePath name $ \s -> throwErrnoPathIfMinus1_ "setSymbolicLinkOwnerAndGroup" name- (c_lchown s uid gid)+ (c_lchown s uid gid) foreign import ccall unsafe "lchown" c_lchown :: CString -> CUid -> CGid -> IO CInt@@ -416,11 +421,11 @@ -- -- Note: calls @truncate@. setFileSize :: RawFilePath -> FileOffset -> IO ()-setFileSize file off = +setFileSize file off = withFilePath file $ \s -> throwErrnoPathIfMinus1_ "setFileSize" file (c_truncate s off) -foreign import ccall unsafe "truncate"+foreign import capi unsafe "HsUnix.h truncate" c_truncate :: CString -> COff -> IO CInt -- -----------------------------------------------------------------------------@@ -435,9 +440,9 @@ -- Note: calls @pathconf@. getPathVar :: RawFilePath -> PathVar -> IO Limit getPathVar name v = do- withFilePath name $ \ nameP -> - throwErrnoPathIfMinus1 "getPathVar" name $ + withFilePath name $ \ nameP ->+ throwErrnoPathIfMinus1 "getPathVar" name $ c_pathconf nameP (pathVarConst v) -foreign import ccall unsafe "pathconf" +foreign import ccall unsafe "pathconf" c_pathconf :: CString -> CInt -> IO CLong
System/Posix/Files/Common.hsc view
@@ -92,7 +92,7 @@ import Data.Int import Data.Ratio #endif-import Data.Time.Clock.POSIX+import Data.Time.Clock.POSIX (POSIXTime) import System.Posix.Internals import Foreign.C import Foreign.ForeignPtr@@ -159,8 +159,8 @@ -- | Owner, group and others have read and write permission. stdFileMode :: FileMode stdFileMode = ownerReadMode .|. ownerWriteMode .|.- groupReadMode .|. groupWriteMode .|.- otherReadMode .|. otherWriteMode+ groupReadMode .|. groupWriteMode .|.+ otherReadMode .|. otherWriteMode -- | Owner has read, write and execute permission. ownerModes :: FileMode@@ -534,67 +534,67 @@ -- pathconf()/fpathconf() support data PathVar- = FileSizeBits {- _PC_FILESIZEBITS -}+ = FileSizeBits {- _PC_FILESIZEBITS -} | LinkLimit {- _PC_LINK_MAX -} | InputLineLimit {- _PC_MAX_CANON -} | InputQueueLimit {- _PC_MAX_INPUT -} | FileNameLimit {- _PC_NAME_MAX -} | PathNameLimit {- _PC_PATH_MAX -} | PipeBufferLimit {- _PC_PIPE_BUF -}- -- These are described as optional in POSIX:- {- _PC_ALLOC_SIZE_MIN -}- {- _PC_REC_INCR_XFER_SIZE -}- {- _PC_REC_MAX_XFER_SIZE -}- {- _PC_REC_MIN_XFER_SIZE -}- {- _PC_REC_XFER_ALIGN -}- | SymbolicLinkLimit {- _PC_SYMLINK_MAX -}+ -- These are described as optional in POSIX:+ {- _PC_ALLOC_SIZE_MIN -}+ {- _PC_REC_INCR_XFER_SIZE -}+ {- _PC_REC_MAX_XFER_SIZE -}+ {- _PC_REC_MIN_XFER_SIZE -}+ {- _PC_REC_XFER_ALIGN -}+ | SymbolicLinkLimit {- _PC_SYMLINK_MAX -} | SetOwnerAndGroupIsRestricted {- _PC_CHOWN_RESTRICTED -} | FileNamesAreNotTruncated {- _PC_NO_TRUNC -}- | VDisableChar {- _PC_VDISABLE -}- | AsyncIOAvailable {- _PC_ASYNC_IO -}- | PrioIOAvailable {- _PC_PRIO_IO -}- | SyncIOAvailable {- _PC_SYNC_IO -}+ | VDisableChar {- _PC_VDISABLE -}+ | AsyncIOAvailable {- _PC_ASYNC_IO -}+ | PrioIOAvailable {- _PC_PRIO_IO -}+ | SyncIOAvailable {- _PC_SYNC_IO -} pathVarConst :: PathVar -> CInt pathVarConst v = case v of- LinkLimit -> (#const _PC_LINK_MAX)- InputLineLimit -> (#const _PC_MAX_CANON)- InputQueueLimit -> (#const _PC_MAX_INPUT)- FileNameLimit -> (#const _PC_NAME_MAX)- PathNameLimit -> (#const _PC_PATH_MAX)- PipeBufferLimit -> (#const _PC_PIPE_BUF)- SetOwnerAndGroupIsRestricted -> (#const _PC_CHOWN_RESTRICTED)- FileNamesAreNotTruncated -> (#const _PC_NO_TRUNC)- VDisableChar -> (#const _PC_VDISABLE)+ LinkLimit -> (#const _PC_LINK_MAX)+ InputLineLimit -> (#const _PC_MAX_CANON)+ InputQueueLimit -> (#const _PC_MAX_INPUT)+ FileNameLimit -> (#const _PC_NAME_MAX)+ PathNameLimit -> (#const _PC_PATH_MAX)+ PipeBufferLimit -> (#const _PC_PIPE_BUF)+ SetOwnerAndGroupIsRestricted -> (#const _PC_CHOWN_RESTRICTED)+ FileNamesAreNotTruncated -> (#const _PC_NO_TRUNC)+ VDisableChar -> (#const _PC_VDISABLE) #ifdef _PC_SYNC_IO- SyncIOAvailable -> (#const _PC_SYNC_IO)+ SyncIOAvailable -> (#const _PC_SYNC_IO) #else- SyncIOAvailable -> error "_PC_SYNC_IO not available"+ SyncIOAvailable -> error "_PC_SYNC_IO not available" #endif #ifdef _PC_ASYNC_IO- AsyncIOAvailable -> (#const _PC_ASYNC_IO)+ AsyncIOAvailable -> (#const _PC_ASYNC_IO) #else- AsyncIOAvailable -> error "_PC_ASYNC_IO not available"+ AsyncIOAvailable -> error "_PC_ASYNC_IO not available" #endif #ifdef _PC_PRIO_IO- PrioIOAvailable -> (#const _PC_PRIO_IO)+ PrioIOAvailable -> (#const _PC_PRIO_IO) #else- PrioIOAvailable -> error "_PC_PRIO_IO not available"+ PrioIOAvailable -> error "_PC_PRIO_IO not available" #endif #if _PC_FILESIZEBITS- FileSizeBits -> (#const _PC_FILESIZEBITS)+ FileSizeBits -> (#const _PC_FILESIZEBITS) #else- FileSizeBits -> error "_PC_FILESIZEBITS not available"+ FileSizeBits -> error "_PC_FILESIZEBITS not available" #endif #if _PC_SYMLINK_MAX- SymbolicLinkLimit -> (#const _PC_SYMLINK_MAX)+ SymbolicLinkLimit -> (#const _PC_SYMLINK_MAX) #else- SymbolicLinkLimit -> error "_PC_SYMLINK_MAX not available"+ SymbolicLinkLimit -> error "_PC_SYMLINK_MAX not available" #endif -- | @getFdPathVar var fd@ obtains the dynamic value of the requested
System/Posix/IO.hsc view
@@ -1,4 +1,6 @@-#ifdef __GLASGOW_HASKELL__+#if __GLASGOW_HASKELL__ >= 709+{-# LANGUAGE Safe #-}+#elif __GLASGOW_HASKELL__ >= 703 {-# LANGUAGE Trustworthy #-} #endif -----------------------------------------------------------------------------
System/Posix/IO/ByteString.hsc view
@@ -1,4 +1,6 @@-#ifdef __GLASGOW_HASKELL__+#if __GLASGOW_HASKELL__ >= 709+{-# LANGUAGE Safe #-}+#elif __GLASGOW_HASKELL__ >= 703 {-# LANGUAGE Trustworthy #-} #endif -----------------------------------------------------------------------------
System/Posix/IO/Common.hsc view
@@ -1,7 +1,10 @@ {-# LANGUAGE NondecreasingIndentation, RecordWildCards #-}-#ifdef __GLASGOW_HASKELL__+#if __GLASGOW_HASKELL__ >= 709+{-# LANGUAGE Safe #-}+#elif __GLASGOW_HASKELL__ >= 703 {-# LANGUAGE Trustworthy #-} #endif+ ----------------------------------------------------------------------------- -- | -- Module : System.Posix.IO.Common
System/Posix/Process.hsc view
@@ -1,4 +1,6 @@-#ifdef __GLASGOW_HASKELL__+#if __GLASGOW_HASKELL__ >= 709+{-# LANGUAGE Safe #-}+#elif __GLASGOW_HASKELL__ >= 703 {-# LANGUAGE Trustworthy #-} #endif -----------------------------------------------------------------------------@@ -6,7 +8,7 @@ -- Module : System.Posix.Process -- Copyright : (c) The University of Glasgow 2002 -- License : BSD-style (see the file libraries/base/LICENSE)--- +-- -- Maintainer : libraries@haskell.org -- Stability : provisional -- Portability : non-portable (requires POSIX)@@ -25,7 +27,7 @@ forkProcessWithUnmask, #endif executeFile,- + -- ** Exiting exitImmediately, @@ -86,21 +88,21 @@ -- environment is provided to supersede the process's current -- environment. The basename (leading directory names suppressed) of -- the command is passed to @execv*@ as @arg[0]@;--- the argument list passed to 'executeFile' therefore +-- the argument list passed to 'executeFile' therefore -- begins with @arg[1]@.-executeFile :: FilePath -- ^ Command- -> Bool -- ^ Search PATH?- -> [String] -- ^ Arguments- -> Maybe [(String, String)] -- ^ Environment+executeFile :: FilePath -- ^ Command+ -> Bool -- ^ Search PATH?+ -> [String] -- ^ Arguments+ -> Maybe [(String, String)] -- ^ Environment -> IO a executeFile path search args Nothing = do withFilePath path $ \s -> withMany withFilePath (path:args) $ \cstrs -> withArray0 nullPtr cstrs $ \arr -> do- pPrPr_disableITimers- if search - then throwErrnoPathIfMinus1_ "executeFile" path (c_execvp s arr)- else throwErrnoPathIfMinus1_ "executeFile" path (c_execv s arr)+ pPrPr_disableITimers+ if search+ then throwErrnoPathIfMinus1_ "executeFile" path (c_execvp s arr)+ else throwErrnoPathIfMinus1_ "executeFile" path (c_execv s arr) return undefined -- never reached executeFile path search args (Just env) = do@@ -110,12 +112,12 @@ let env' = map (\ (name, val) -> name ++ ('=' : val)) env in withMany withFilePath env' $ \cenv -> withArray0 nullPtr cenv $ \env_arr -> do- pPrPr_disableITimers- if search - then throwErrnoPathIfMinus1_ "executeFile" path- (c_execvpe s arg_arr env_arr)- else throwErrnoPathIfMinus1_ "executeFile" path- (c_execve s arg_arr env_arr)+ pPrPr_disableITimers+ if search+ then throwErrnoPathIfMinus1_ "executeFile" path+ (c_execvpe s arg_arr env_arr)+ else throwErrnoPathIfMinus1_ "executeFile" path+ (c_execve s arg_arr env_arr) return undefined -- never reached foreign import ccall unsafe "execvp"
System/Posix/Process/ByteString.hsc view
@@ -1,6 +1,9 @@-#ifdef __GLASGOW_HASKELL__+#if __GLASGOW_HASKELL__ >= 709+{-# LANGUAGE Safe #-}+#elif __GLASGOW_HASKELL__ >= 703 {-# LANGUAGE Trustworthy #-} #endif+ ----------------------------------------------------------------------------- -- | -- Module : System.Posix.Process.ByteString
System/Posix/Process/Internals.hs view
@@ -30,7 +30,7 @@ foreign import ccall unsafe "pPrPr_disableITimers" pPrPr_disableITimers :: IO () -foreign import ccall unsafe "execvpe"+foreign import ccall unsafe "__hsunix_execvpe" c_execvpe :: CString -> Ptr CString -> Ptr CString -> IO CInt decipherWaitStatus :: CInt -> IO ProcessStatus@@ -39,25 +39,25 @@ then do let exitstatus = c_WEXITSTATUS wstat if exitstatus == 0- then return (Exited ExitSuccess)- else return (Exited (ExitFailure (fromIntegral exitstatus)))+ then return (Exited ExitSuccess)+ else return (Exited (ExitFailure (fromIntegral exitstatus))) else do if c_WIFSIGNALED wstat /= 0- then do+ then do let termsig = c_WTERMSIG wstat let coredumped = c_WCOREDUMP wstat /= 0 return (Terminated termsig coredumped)- else do- if c_WIFSTOPPED wstat /= 0- then do- let stopsig = c_WSTOPSIG wstat+ else do+ if c_WIFSTOPPED wstat /= 0+ then do+ let stopsig = c_WSTOPSIG wstat return (Stopped stopsig)- else do- ioError (mkIOError illegalOperationErrorType- "waitStatus" Nothing Nothing)+ else do+ ioError (mkIOError illegalOperationErrorType+ "waitStatus" Nothing Nothing) foreign import ccall unsafe "__hsunix_wifexited"- c_WIFEXITED :: CInt -> CInt + c_WIFEXITED :: CInt -> CInt foreign import ccall unsafe "__hsunix_wexitstatus" c_WEXITSTATUS :: CInt -> CInt@@ -66,7 +66,7 @@ c_WIFSIGNALED :: CInt -> CInt foreign import ccall unsafe "__hsunix_wtermsig"- c_WTERMSIG :: CInt -> CInt + c_WTERMSIG :: CInt -> CInt foreign import ccall unsafe "__hsunix_wifstopped" c_WIFSTOPPED :: CInt -> CInt
System/Posix/Resource.hsc view
@@ -1,4 +1,6 @@-#ifdef __GLASGOW_HASKELL__+#if __GLASGOW_HASKELL__ >= 709+{-# LANGUAGE Safe #-}+#elif __GLASGOW_HASKELL__ >= 703 {-# LANGUAGE Trustworthy #-} #endif -----------------------------------------------------------------------------@@ -69,9 +71,9 @@ soft <- (#peek struct rlimit, rlim_cur) p_rlimit hard <- (#peek struct rlimit, rlim_max) p_rlimit return (ResourceLimits {- softLimit = unpackRLimit soft,- hardLimit = unpackRLimit hard- })+ softLimit = unpackRLimit soft,+ hardLimit = unpackRLimit hard+ }) setResourceLimit :: Resource -> ResourceLimits -> IO () setResourceLimit res ResourceLimits{softLimit=soft,hardLimit=hard} = do@@ -79,7 +81,7 @@ (#poke struct rlimit, rlim_cur) p_rlimit (packRLimit soft True) (#poke struct rlimit, rlim_max) p_rlimit (packRLimit hard False) throwErrnoIfMinus1_ "setResourceLimit" $- c_setrlimit (packResource res) p_rlimit+ c_setrlimit (packResource res) p_rlimit return () packResource :: Resource -> CInt@@ -126,14 +128,14 @@ main = do zipWithM_ (\r n -> setResourceLimit r ResourceLimits{- hardLimit = ResourceLimit n,- softLimit = ResourceLimit n })- allResources [1..]+ hardLimit = ResourceLimit n,+ softLimit = ResourceLimit n })+ allResources [1..] showAll mapM_ (\r -> setResourceLimit r ResourceLimits{- hardLimit = ResourceLimit 1,- softLimit = ResourceLimitInfinity })- allResources+ hardLimit = ResourceLimit 1,+ softLimit = ResourceLimitInfinity })+ allResources -- should fail @@ -142,11 +144,11 @@ allResources = [ResourceCoreFileSize, ResourceCPUTime, ResourceDataSize,- ResourceFileSize, ResourceOpenFiles, ResourceStackSize+ ResourceFileSize, ResourceOpenFiles, ResourceStackSize #ifdef RLIMIT_AS- , ResourceTotalMemory+ , ResourceTotalMemory #endif- ]+ ] showRLims ResourceLimits{hardLimit=h,softLimit=s} = "hard: " ++ showRLim h ++ ", soft: " ++ showRLim s
System/Posix/Semaphore.hsc view
@@ -1,4 +1,6 @@-#ifdef __GLASGOW_HASKELL__+#if __GLASGOW_HASKELL__ >= 709+{-# LANGUAGE Safe #-}+#elif __GLASGOW_HASKELL__ >= 703 {-# LANGUAGE Trustworthy #-} #endif -----------------------------------------------------------------------------@@ -16,8 +18,8 @@ ----------------------------------------------------------------------------- module System.Posix.Semaphore- (OpenSemFlags(..), Semaphore(), - semOpen, semUnlink, semWait, semTryWait, semThreadWait, + (OpenSemFlags(..), Semaphore(),+ semOpen, semUnlink, semWait, semTryWait, semThreadWait, semPost, semGetValue) where @@ -44,14 +46,14 @@ newtype Semaphore = Semaphore (ForeignPtr ()) --- | Open a named semaphore with the given name, flags, mode, and initial +-- | Open a named semaphore with the given name, flags, mode, and initial -- value. semOpen :: String -> OpenSemFlags -> FileMode -> Int -> IO Semaphore semOpen name flags mode value = let cflags = (if semCreate flags then #{const O_CREAT} else 0) .|. (if semExclusive flags then #{const O_EXCL} else 0) semOpen' cname =- do sem <- throwErrnoPathIfNull "semOpen" name $ + do sem <- throwErrnoPathIfNull "semOpen" name $ sem_open cname (toEnum cflags) mode (toEnum value) fptr <- newForeignPtr sem (finalize sem) return $ Semaphore fptr@@ -68,7 +70,7 @@ -- | Lock the semaphore, blocking until it becomes available. Since this -- is done through a system call, this will block the *entire runtime*, -- not just the current thread. If this is not the behaviour you want,--- use semThreadWait instead. +-- use semThreadWait instead. semWait :: Semaphore -> IO () semWait (Semaphore fptr) = withForeignPtr fptr semWait' where semWait' sem = throwErrnoIfMinus1Retry_ "semWait" $@@ -81,13 +83,13 @@ where semTrywait' sem = do res <- sem_trywait sem (if res == 0 then return True else do errno <- getErrno- (if errno == eINTR + (if errno == eINTR then semTrywait' sem else if errno == eAGAIN then return False else throwErrno "semTrywait")) --- | Poll the semaphore until it is available, then lock it. Unlike +-- | Poll the semaphore until it is available, then lock it. Unlike -- semWait, this will block only the current thread rather than the -- entire process. semThreadWait :: Semaphore -> IO ()
@@ -1,4 +1,6 @@-#ifdef __GLASGOW_HASKELL__+#if __GLASGOW_HASKELL__ >= 709+{-# LANGUAGE Safe #-}+#elif __GLASGOW_HASKELL__ >= 703 {-# LANGUAGE Trustworthy #-} #endif -----------------------------------------------------------------------------@@ -19,11 +21,11 @@ (ShmOpenFlags(..), shmOpen, shmUnlink) where +#include "HsUnix.h"+ #include <sys/types.h> #include <sys/mman.h> #include <fcntl.h>--#include "HsUnix.h" import System.Posix.Types #if defined(HAVE_SHM_OPEN) || defined(HAVE_SHM_UNLINK)
System/Posix/Signals/Exts.hsc view
@@ -1,12 +1,14 @@+{-# LANGUAGE CPP #-} #ifdef __GLASGOW_HASKELL__-{-# LANGUAGE Trustworthy #-}+{-# LANGUAGE Safe #-} #endif+ ----------------------------------------------------------------------------- -- | -- Module : System.Posix.Signals.Exts -- Copyright : (c) The University of Glasgow 2002 -- License : BSD-style (see the file libraries/base/LICENSE)--- +-- -- Maintainer : libraries@haskell.org -- Stability : provisional -- Portability : non-portable (requires POSIX, includes Linuxisms/BSDisms)@@ -15,45 +17,33 @@ -- ----------------------------------------------------------------------------- -#include "HsUnix.h"--module System.Posix.Signals.Exts (- module System.Posix.Signals+#include "HsUnixConfig.h"+##include "HsUnixConfig.h" -#ifdef SIGINFO- , infoEvent, sigINFO-#endif-#ifdef SIGWINCH- , windowChange, sigWINCH+#ifdef HAVE_SIGNAL_H+#include <signal.h> #endif +module System.Posix.Signals.Exts (+ module System.Posix.Signals+ , sigINFO+ , sigWINCH+ , infoEvent+ , windowChange ) where import Foreign.C import System.Posix.Signals -#ifdef __HUGS__-# ifdef SIGINFO-sigINFO = (#const SIGINFO) :: CInt-# endif-# ifdef SIGWINCH-sigWINCH = (#const SIGWINCH) :: CInt-# endif-#else /* !HUGS */-# ifdef SIGINFO-foreign import ccall unsafe "__hsunix_SIGINFO" sigINFO :: CInt-# endif-# ifdef SIGWINCH-foreign import ccall unsafe "__hsunix_SIGWINCH" sigWINCH :: CInt-# endif-#endif /* !HUGS */+sigINFO :: CInt+sigINFO = CONST_SIGINFO -#ifdef SIGINFO+sigWINCH :: CInt+sigWINCH = CONST_SIGWINCH++ infoEvent :: Signal infoEvent = sigINFO-#endif -#ifdef SIGWINCH windowChange :: Signal windowChange = sigWINCH-#endif
System/Posix/Temp.hsc view
@@ -1,4 +1,6 @@-#ifdef __GLASGOW_HASKELL__+#if __GLASGOW_HASKELL__ >= 709+{-# LANGUAGE Safe #-}+#elif __GLASGOW_HASKELL__ >= 703 {-# LANGUAGE Trustworthy #-} #endif -----------------------------------------------------------------------------
System/Posix/Temp/ByteString.hsc view
@@ -1,4 +1,6 @@-#ifdef __GLASGOW_HASKELL__+#if __GLASGOW_HASKELL__ >= 709+{-# LANGUAGE Safe #-}+#elif __GLASGOW_HASKELL__ >= 703 {-# LANGUAGE Trustworthy #-} #endif -----------------------------------------------------------------------------
System/Posix/Terminal.hsc view
@@ -1,4 +1,6 @@-#ifdef __GLASGOW_HASKELL__+#if __GLASGOW_HASKELL__ >= 709+{-# LANGUAGE Safe #-}+#elif __GLASGOW_HASKELL__ >= 703 {-# LANGUAGE Trustworthy #-} #endif -----------------------------------------------------------------------------
System/Posix/Terminal/ByteString.hsc view
@@ -1,4 +1,6 @@-#ifdef __GLASGOW_HASKELL__+#if __GLASGOW_HASKELL__ >= 709+{-# LANGUAGE Safe #-}+#elif __GLASGOW_HASKELL__ >= 703 {-# LANGUAGE Trustworthy #-} #endif -----------------------------------------------------------------------------@@ -6,7 +8,7 @@ -- Module : System.Posix.Terminal.ByteString -- Copyright : (c) The University of Glasgow 2002 -- License : BSD-style (see the file libraries/base/LICENSE)--- +-- -- Maintainer : libraries@haskell.org -- Stability : provisional -- Portability : non-portable (requires POSIX)
System/Posix/Terminal/Common.hsc view
@@ -7,7 +7,7 @@ -- Module : System.Posix.Terminal.Common -- Copyright : (c) The University of Glasgow 2002 -- License : BSD-style (see the file libraries/base/LICENSE)--- +-- -- Maintainer : libraries@haskell.org -- Stability : provisional -- Portability : non-portable (requires POSIX)@@ -92,44 +92,44 @@ data TerminalMode- -- input flags- = InterruptOnBreak -- BRKINT- | MapCRtoLF -- ICRNL- | IgnoreBreak -- IGNBRK- | IgnoreCR -- IGNCR- | IgnoreParityErrors -- IGNPAR- | MapLFtoCR -- INLCR- | CheckParity -- INPCK- | StripHighBit -- ISTRIP- | StartStopInput -- IXOFF- | StartStopOutput -- IXON- | MarkParityErrors -- PARMRK+ -- input flags+ = InterruptOnBreak -- BRKINT+ | MapCRtoLF -- ICRNL+ | IgnoreBreak -- IGNBRK+ | IgnoreCR -- IGNCR+ | IgnoreParityErrors -- IGNPAR+ | MapLFtoCR -- INLCR+ | CheckParity -- INPCK+ | StripHighBit -- ISTRIP+ | StartStopInput -- IXOFF+ | StartStopOutput -- IXON+ | MarkParityErrors -- PARMRK - -- output flags- | ProcessOutput -- OPOST- -- ToDo: ONLCR, OCRNL, ONOCR, ONLRET, OFILL,- -- NLDLY(NL0,NL1), CRDLY(CR0,CR1,CR2,CR2)- -- TABDLY(TAB0,TAB1,TAB2,TAB3)- -- BSDLY(BS0,BS1), VTDLY(VT0,VT1), FFDLY(FF0,FF1)+ -- output flags+ | ProcessOutput -- OPOST+ -- ToDo: ONLCR, OCRNL, ONOCR, ONLRET, OFILL,+ -- NLDLY(NL0,NL1), CRDLY(CR0,CR1,CR2,CR2)+ -- TABDLY(TAB0,TAB1,TAB2,TAB3)+ -- BSDLY(BS0,BS1), VTDLY(VT0,VT1), FFDLY(FF0,FF1) - -- control flags- | LocalMode -- CLOCAL- | ReadEnable -- CREAD- | TwoStopBits -- CSTOPB- | HangupOnClose -- HUPCL- | EnableParity -- PARENB- | OddParity -- PARODD+ -- control flags+ | LocalMode -- CLOCAL+ | ReadEnable -- CREAD+ | TwoStopBits -- CSTOPB+ | HangupOnClose -- HUPCL+ | EnableParity -- PARENB+ | OddParity -- PARODD - -- local modes- | EnableEcho -- ECHO- | EchoErase -- ECHOE- | EchoKill -- ECHOK- | EchoLF -- ECHONL- | ProcessInput -- ICANON- | ExtendedFunctions -- IEXTEN- | KeyboardInterrupts -- ISIG- | NoFlushOnInterrupt -- NOFLSH- | BackgroundWriteInterrupt -- TOSTOP+ -- local modes+ | EnableEcho -- ECHO+ | EchoErase -- ECHOE+ | EchoKill -- ECHOK+ | EchoLF -- ECHONL+ | ProcessInput -- ICANON+ | ExtendedFunctions -- IEXTEN+ | KeyboardInterrupts -- ISIG+ | NoFlushOnInterrupt -- NOFLSH+ | BackgroundWriteInterrupt -- TOSTOP withoutMode :: TerminalAttributes -> TerminalMode -> TerminalAttributes withoutMode termios InterruptOnBreak = clearInputFlag (#const BRKINT) termios@@ -226,11 +226,11 @@ where word2Bits :: CTcflag -> Int word2Bits x =- if x == (#const CS5) then 5- else if x == (#const CS6) then 6- else if x == (#const CS7) then 7- else if x == (#const CS8) then 8- else 0+ if x == (#const CS5) then 5+ else if x == (#const CS6) then 6+ else if x == (#const CS7) then 7+ else if x == (#const CS8) then 8+ else 0 withBits :: TerminalAttributes -> Int -> TerminalAttributes withBits termios bits = unsafePerformIO $ do@@ -247,15 +247,15 @@ mask _ = error "withBits bit value out of range [5..8]" data ControlCharacter- = EndOfFile -- VEOF- | EndOfLine -- VEOL- | Erase -- VERASE- | Interrupt -- VINTR- | Kill -- VKILL- | Quit -- VQUIT- | Start -- VSTART- | Stop -- VSTOP- | Suspend -- VSUSP+ = EndOfFile -- VEOF+ | EndOfLine -- VEOL+ | Erase -- VERASE+ | Interrupt -- VINTR+ | Kill -- VKILL+ | Quit -- VQUIT+ | Start -- VSTART+ | Stop -- VSTOP+ | Suspend -- VSUSP controlChar :: TerminalAttributes -> ControlCharacter -> Maybe Char controlChar termios cc = unsafePerformIO $ do@@ -265,7 +265,7 @@ if val == ((#const _POSIX_VDISABLE)::CCc) then return Nothing else return (Just (chr (fromEnum val)))- + withCC :: TerminalAttributes -> (ControlCharacter, Char) -> TerminalAttributes@@ -416,9 +416,9 @@ data QueueSelector- = InputQueue -- TCIFLUSH- | OutputQueue -- TCOFLUSH- | BothQueues -- TCIOFLUSH+ = InputQueue -- TCIFLUSH+ | OutputQueue -- TCOFLUSH+ | BothQueues -- TCIOFLUSH -- | @discardData fd queues@ calls @tcflush@ to discard -- pending input and\/or output for @Fd@ @fd@,@@ -436,12 +436,12 @@ c_tcflush :: CInt -> CInt -> IO CInt data FlowAction- = SuspendOutput -- ^ TCOOFF- | RestartOutput -- ^ TCOON- | TransmitStop -- ^ TCIOFF- | TransmitStart -- ^ TCION+ = SuspendOutput -- ^ TCOOFF+ | RestartOutput -- ^ TCOON+ | TransmitStop -- ^ TCIOFF+ | TransmitStart -- ^ TCION --- | @controlFlow fd action@ calls @tcflow@ to control the +-- | @controlFlow fd action@ calls @tcflow@ to control the -- flow of data on @Fd@ @fd@, as indicated by -- @action@. controlFlow :: Fd -> FlowAction -> IO ()@@ -458,7 +458,7 @@ c_tcflow :: CInt -> CInt -> IO CInt -- | @getTerminalProcessGroupID fd@ calls @tcgetpgrp@ to--- obtain the @ProcessGroupID@ of the foreground process group +-- obtain the @ProcessGroupID@ of the foreground process group -- associated with the terminal attached to @Fd@ @fd@. getTerminalProcessGroupID :: Fd -> IO ProcessGroupID getTerminalProcessGroupID (Fd fd) = do@@ -468,8 +468,8 @@ c_tcgetpgrp :: CInt -> IO CPid -- | @setTerminalProcessGroupID fd pgid@ calls @tcsetpgrp@ to--- set the @ProcessGroupID@ of the foreground process group --- associated with the terminal attached to @Fd@ +-- set the @ProcessGroupID@ of the foreground process group+-- associated with the terminal attached to @Fd@ -- @fd@ to @pgid@. setTerminalProcessGroupID :: Fd -> ProcessGroupID -> IO () setTerminalProcessGroupID (Fd fd) pgid =@@ -562,7 +562,7 @@ fp <- mallocForeignPtrBytes (#const sizeof(struct termios)) withForeignPtr fp $ \p1 -> do withTerminalAttributes termios $ \p2 -> do- copyBytes p1 p2 (#const sizeof(struct termios)) + copyBytes p1 p2 (#const sizeof(struct termios)) iflag <- (#peek struct termios, c_iflag) p2 (#poke struct termios, c_iflag) p1 (iflag .&. complement flag) return $ makeTerminalAttributes fp@@ -574,7 +574,7 @@ fp <- mallocForeignPtrBytes (#const sizeof(struct termios)) withForeignPtr fp $ \p1 -> do withTerminalAttributes termios $ \p2 -> do- copyBytes p1 p2 (#const sizeof(struct termios)) + copyBytes p1 p2 (#const sizeof(struct termios)) iflag <- (#peek struct termios, c_iflag) p2 (#poke struct termios, c_iflag) p1 (iflag .|. flag) return $ makeTerminalAttributes fp@@ -594,7 +594,7 @@ fp <- mallocForeignPtrBytes (#const sizeof(struct termios)) withForeignPtr fp $ \p1 -> do withTerminalAttributes termios $ \p2 -> do- copyBytes p1 p2 (#const sizeof(struct termios)) + copyBytes p1 p2 (#const sizeof(struct termios)) cflag <- (#peek struct termios, c_cflag) p2 (#poke struct termios, c_cflag) p1 (cflag .&. complement flag) return $ makeTerminalAttributes fp@@ -606,7 +606,7 @@ fp <- mallocForeignPtrBytes (#const sizeof(struct termios)) withForeignPtr fp $ \p1 -> do withTerminalAttributes termios $ \p2 -> do- copyBytes p1 p2 (#const sizeof(struct termios)) + copyBytes p1 p2 (#const sizeof(struct termios)) cflag <- (#peek struct termios, c_cflag) p2 (#poke struct termios, c_cflag) p1 (cflag .|. flag) return $ makeTerminalAttributes fp@@ -626,7 +626,7 @@ fp <- mallocForeignPtrBytes (#const sizeof(struct termios)) withForeignPtr fp $ \p1 -> do withTerminalAttributes termios $ \p2 -> do- copyBytes p1 p2 (#const sizeof(struct termios)) + copyBytes p1 p2 (#const sizeof(struct termios)) lflag <- (#peek struct termios, c_lflag) p2 (#poke struct termios, c_lflag) p1 (lflag .&. complement flag) return $ makeTerminalAttributes fp@@ -638,7 +638,7 @@ fp <- mallocForeignPtrBytes (#const sizeof(struct termios)) withForeignPtr fp $ \p1 -> do withTerminalAttributes termios $ \p2 -> do- copyBytes p1 p2 (#const sizeof(struct termios)) + copyBytes p1 p2 (#const sizeof(struct termios)) lflag <- (#peek struct termios, c_lflag) p2 (#poke struct termios, c_lflag) p1 (lflag .|. flag) return $ makeTerminalAttributes fp@@ -658,7 +658,7 @@ fp <- mallocForeignPtrBytes (#const sizeof(struct termios)) withForeignPtr fp $ \p1 -> do withTerminalAttributes termios $ \p2 -> do- copyBytes p1 p2 (#const sizeof(struct termios)) + copyBytes p1 p2 (#const sizeof(struct termios)) oflag <- (#peek struct termios, c_oflag) p2 (#poke struct termios, c_oflag) p1 (oflag .&. complement flag) return $ makeTerminalAttributes fp@@ -670,7 +670,7 @@ fp <- mallocForeignPtrBytes (#const sizeof(struct termios)) withForeignPtr fp $ \p1 -> do withTerminalAttributes termios $ \p2 -> do- copyBytes p1 p2 (#const sizeof(struct termios)) + copyBytes p1 p2 (#const sizeof(struct termios)) oflag <- (#peek struct termios, c_oflag) p2 (#poke struct termios, c_oflag) p1 (oflag .|. flag) return $ makeTerminalAttributes fp@@ -683,7 +683,7 @@ oflag <- (#peek struct termios, c_oflag) p return $! ((oflag .&. flag) /= 0) -withNewTermios :: TerminalAttributes -> (Ptr CTermios -> IO a) +withNewTermios :: TerminalAttributes -> (Ptr CTermios -> IO a) -> IO TerminalAttributes withNewTermios termios action = do fp1 <- mallocForeignPtrBytes (#const sizeof(struct termios))
System/Posix/Time.hsc view
@@ -1,4 +1,6 @@-#ifdef __GLASGOW_HASKELL__+#if __GLASGOW_HASKELL__ >= 709+{-# LANGUAGE Safe #-}+#elif __GLASGOW_HASKELL__ >= 703 {-# LANGUAGE Trustworthy #-} #endif -----------------------------------------------------------------------------@@ -6,7 +8,7 @@ -- Module : System.Posix.Time -- Copyright : (c) The University of Glasgow 2002 -- License : BSD-style (see the file libraries/base/LICENSE)--- +-- -- Maintainer : libraries@haskell.org -- Stability : provisional -- Portability : non-portable (requires POSIX)@@ -16,9 +18,9 @@ ----------------------------------------------------------------------------- module System.Posix.Time (- epochTime,- -- ToDo: lots more from sys/time.h- -- how much already supported by System.Time?+ epochTime,+ -- ToDo: lots more from sys/time.h+ -- how much already supported by System.Time? ) where #include "HsUnix.h"@@ -30,7 +32,7 @@ -- ----------------------------------------------------------------------------- -- epochTime --- | @epochTime@ calls @time@ to obtain the number of +-- | @epochTime@ calls @time@ to obtain the number of -- seconds that have elapsed since the epoch (Jan 01 00:00:00 GMT 1970). epochTime :: IO EpochTime epochTime = throwErrnoIfMinus1 "epochTime" (c_time nullPtr)
System/Posix/Unistd.hsc view
@@ -1,5 +1,8 @@+{-# LANGUAGE CApiFFI #-} {-# LANGUAGE NondecreasingIndentation #-}-#ifdef __GLASGOW_HASKELL__+#if __GLASGOW_HASKELL__ >= 709+{-# LANGUAGE Safe #-}+#elif __GLASGOW_HASKELL__ >= 703 {-# LANGUAGE Trustworthy #-} #endif -----------------------------------------------------------------------------@@ -7,7 +10,7 @@ -- Module : System.Posix.Unistd -- Copyright : (c) The University of Glasgow 2002 -- License : BSD-style (see the file libraries/base/LICENSE)--- +-- -- Maintainer : libraries@haskell.org -- Stability : provisional -- Portability : non-portable (requires POSIX)@@ -27,9 +30,13 @@ -- * Sleeping sleep, usleep, nanosleep, + -- * File synchronisation+ fileSynchronise,+ fileSynchroniseDataOnly,+ {- ToDo from unistd.h:- confstr, + confstr, lots of sysconf variables -- use Network.BSD@@ -55,18 +62,24 @@ import Foreign.C.String ( peekCString ) import Foreign.C.Types import Foreign+import System.Posix.Types import System.Posix.Internals +#if !(HAVE_FSYNC && HAVE_FDATASYNC)+import System.IO.Error ( ioeSetLocation )+import GHC.IO.Exception ( unsupportedOperation )+#endif+ -- ----------------------------------------------------------------------------- -- System environment (uname()) data SystemID = SystemID { systemName :: String- , nodeName :: String- , release :: String- , version :: String- , machine :: String- }+ , nodeName :: String+ , release :: String+ , version :: String+ , machine :: String+ } getSystemID :: IO SystemID getSystemID = do@@ -78,11 +91,11 @@ ver <- peekCString ((#ptr struct utsname, version) p_sid) mach <- peekCString ((#ptr struct utsname, machine) p_sid) return (SystemID { systemName = sysN,- nodeName = node,- release = rel,- version = ver,- machine = mach- })+ nodeName = node,+ release = rel,+ version = ver,+ machine = mach+ }) foreign import ccall unsafe "uname" c_uname :: Ptr CUtsname -> IO CInt@@ -152,7 +165,7 @@ allocaBytes (#const sizeof(struct timespec)) $ \pts1 -> do allocaBytes (#const sizeof(struct timespec)) $ \pts2 -> do let (tv_sec0, tv_nsec0) = nsecs `divMod` 1000000000- let + let loop tv_sec tv_nsec = do (#poke struct timespec, tv_sec) pts1 tv_sec (#poke struct timespec, tv_nsec) pts1 tv_nsec@@ -170,7 +183,7 @@ data CTimeSpec -foreign import ccall safe "__hsunix_nanosleep" +foreign import ccall safe "__hsunix_nanosleep" c_nanosleep :: Ptr CTimeSpec -> Ptr CTimeSpec -> IO CInt #endif @@ -185,14 +198,14 @@ | PosixVersion | HasSavedIDs | HasJobControl- -- ToDo: lots more+ -- ToDo: lots more getSysVar :: SysVar -> IO Integer getSysVar v = case v of ArgumentLimit -> sysconf (#const _SC_ARG_MAX) ChildLimit -> sysconf (#const _SC_CHILD_MAX)- ClockTick -> sysconf (#const _SC_CLK_TCK)+ ClockTick -> sysconf (#const _SC_CLK_TCK) GroupLimit -> sysconf (#const _SC_NGROUPS_MAX) OpenFileLimit -> sysconf (#const _SC_OPEN_MAX) PosixVersion -> sysconf (#const _SC_VERSION)@@ -200,9 +213,54 @@ HasJobControl -> sysconf (#const _SC_JOB_CONTROL) sysconf :: CInt -> IO Integer-sysconf n = do +sysconf n = do r <- throwErrnoIfMinus1 "getSysVar" (c_sysconf n) return (fromIntegral r) foreign import ccall unsafe "sysconf" c_sysconf :: CInt -> IO CLong++-- -----------------------------------------------------------------------------+-- File synchronization++-- | Performs @fsync(2)@ operation on file-descriptor.+--+-- Throws 'IOError' (\"unsupported operation\") if platform does not+-- provide @fsync(2)@ (use @#if HAVE_FSYNC@ CPP guard to+-- detect availability).+--+-- /Since: 2.7.1.0/+fileSynchronise :: Fd -> IO ()+#if HAVE_FSYNC+fileSynchronise fd = do+ throwErrnoIfMinus1_ "fileSynchronise" (c_fsync fd)++foreign import capi safe "unistd.h fsync"+ c_fsync :: Fd -> IO CInt+#else+{-# WARNING fileSynchronise+ "operation will throw 'IOError' \"unsupported operation\" (CPP guard: @#if HAVE_FSYNC@)" #-}+fileSynchronise _ = ioError (ioeSetLocation unsupportedOperation+ "fileSynchronise")+#endif++-- | Performs @fdatasync(2)@ operation on file-descriptor.+--+-- Throws 'IOError' (\"unsupported operation\") if platform does not+-- provide @fdatasync(2)@ (use @#if HAVE_FDATASYNC@ CPP guard to+-- detect availability).+--+-- /Since: 2.7.1.0/+fileSynchroniseDataOnly :: Fd -> IO ()+#if HAVE_FDATASYNC+fileSynchroniseDataOnly fd = do+ throwErrnoIfMinus1_ "fileSynchroniseDataOnly" (c_fdatasync fd)++foreign import capi safe "unistd.h fdatasync"+ c_fdatasync :: Fd -> IO CInt+#else+{-# WARNING fileSynchroniseDataOnly+ "operation will throw 'IOError' \"unsupported operation\" (CPP guard: @#if HAVE_FDATASYNC@)" #-}+fileSynchroniseDataOnly _ = ioError (ioeSetLocation unsupportedOperation+ "fileSynchroniseDataOnly")+#endif
System/Posix/User.hsc view
@@ -1,12 +1,12 @@ #ifdef __GLASGOW_HASKELL__-{-# LANGUAGE Trustworthy #-}+{-# LANGUAGE Trustworthy, CApiFFI #-} #endif ----------------------------------------------------------------------------- -- | -- Module : System.Posix.User -- Copyright : (c) The University of Glasgow 2002 -- License : BSD-style (see the file libraries/base/LICENSE)--- +-- -- Maintainer : libraries@haskell.org -- Stability : provisional -- Portability : non-portable (requires POSIX)@@ -55,7 +55,7 @@ import Foreign.Ptr import Foreign.Marshal import Foreign.Storable-import System.Posix.Internals ( CGroup, CPasswd )+import System.Posix.Internals ( CGroup, CPasswd ) #if !defined(HAVE_GETPWNAM_R) || !defined(HAVE_GETPWUID_R) || defined(HAVE_GETPWENT) || defined(HAVE_GETGRENT) import Control.Concurrent.MVar ( MVar, newMVar, withMVar )@@ -207,9 +207,9 @@ doubleAllocWhileERANGE "getGroupEntryForID" "group" grBufSize unpackGroupEntry $ c_getgrgid_r gid pgr -foreign import ccall unsafe "getgrgid_r"+foreign import capi unsafe "HsUnix.h getgrgid_r" c_getgrgid_r :: CGid -> Ptr CGroup -> CString- -> CSize -> Ptr (Ptr CGroup) -> IO CInt+ -> CSize -> Ptr (Ptr CGroup) -> IO CInt #else getGroupEntryForID = error "System.Posix.User.getGroupEntryForID: not supported" #endif@@ -226,9 +226,9 @@ doubleAllocWhileERANGE "getGroupEntryForName" "group" grBufSize unpackGroupEntry $ c_getgrnam_r pstr pgr -foreign import ccall unsafe "getgrnam_r"+foreign import capi unsafe "HsUnix.h getgrnam_r" c_getgrnam_r :: CString -> Ptr CGroup -> CString- -> CSize -> Ptr (Ptr CGroup) -> IO CInt+ -> CSize -> Ptr (Ptr CGroup) -> IO CInt #else getGroupEntryForName = error "System.Posix.User.getGroupEntryForName: not supported" #endif@@ -247,7 +247,7 @@ withMVar lock $ \_ -> bracket_ c_setgrent c_endgrent $ worker [] where worker accum = do resetErrno- ppw <- throwErrnoIfNullAndError "getAllGroupEntries" $ + ppw <- throwErrnoIfNullAndError "getAllGroupEntries" $ c_getgrent if ppw == nullPtr then return (reverse accum)@@ -321,15 +321,15 @@ c_getpwuid_r uid ppw foreign import ccall unsafe "__hsunix_getpwuid_r"- c_getpwuid_r :: CUid -> Ptr CPasswd -> - CString -> CSize -> Ptr (Ptr CPasswd) -> IO CInt+ c_getpwuid_r :: CUid -> Ptr CPasswd ->+ CString -> CSize -> Ptr (Ptr CPasswd) -> IO CInt #elif HAVE_GETPWUID getUserEntryForID uid = do withMVar lock $ \_ -> do ppw <- throwErrnoIfNull "getUserEntryForID" $ c_getpwuid uid unpackUserEntry ppw -foreign import ccall unsafe "getpwuid" +foreign import ccall unsafe "getpwuid" c_getpwuid :: CUid -> IO (Ptr CPasswd) #else getUserEntryForID = error "System.Posix.User.getUserEntryForID: not supported"@@ -357,21 +357,21 @@ ppw <- throwErrnoIfNull "getUserEntryForName" $ c_getpwnam pstr unpackUserEntry ppw -foreign import ccall unsafe "getpwnam" +foreign import ccall unsafe "getpwnam" c_getpwnam :: CString -> IO (Ptr CPasswd) #else getUserEntryForName = error "System.Posix.User.getUserEntryForName: not supported" #endif --- | @getAllUserEntries@ returns all user entries on the system by +-- | @getAllUserEntries@ returns all user entries on the system by -- repeatedly calling @getpwent@ getAllUserEntries :: IO [UserEntry] #ifdef HAVE_GETPWENT-getAllUserEntries = +getAllUserEntries = withMVar lock $ \_ -> bracket_ c_setpwent c_endpwent $ worker []- where worker accum = + where worker accum = do resetErrno- ppw <- throwErrnoIfNullAndError "getAllUserEntries" $ + ppw <- throwErrnoIfNullAndError "getAllUserEntries" $ c_getpwent if ppw == nullPtr then return (reverse accum)@@ -403,10 +403,10 @@ -- We need a default value since sysconf can fail and return -1 -- even when the parameter name is defined in unistd.h.--- One example of this is _SC_GETPW_R_SIZE_MAX under +-- One example of this is _SC_GETPW_R_SIZE_MAX under -- Mac OS X 10.4.9 on i386. sysconfWithDefault :: Int -> CInt -> Int-sysconfWithDefault def sc = +sysconfWithDefault def sc = unsafePerformIO $ do v <- fmap fromIntegral $ c_sysconf sc return $ if v == (-1) then def else v #endif
cbits/HsUnix.c view
@@ -21,14 +21,7 @@ #endif #ifdef HAVE_RTLDDEFAULT-void *__hsunix_rtldDefault (void) {return RTLD_DEFAULT;} -#endif--#ifdef SIGINFO-int __hsunix_SIGINFO(void) { return SIGINFO; }-#endif-#ifdef SIGWINCH-int __hsunix_SIGWINCH(void) { return SIGWINCH; }+void *__hsunix_rtldDefault (void) {return RTLD_DEFAULT;} #endif // lstat is a macro on some platforms, so we need a wrapper:
cbits/execvpe.c view
@@ -2,25 +2,33 @@ (c) The University of Glasgow 1995-2004 Our low-level exec() variant.- -------------------------------------------------------------------------- */-#include "execvpe.h" -#ifdef __GLASGOW_HASKELL__-#include "Rts.h"-#endif+ Note: __hsunix_execvpe() is very similiar to the function+ execvpe(3) as provided by glibc 2.11 and later. However, if+ execvpe(3) is available, we use that instead. -#if !(defined(_MSC_VER) || defined(__MINGW32__) || defined(_WIN32)) /* to the end */-#ifndef __QNXNTO__+ -------------------------------------------------------------------------- */ -/* Evidently non-Posix. */-/* #include "PosixSource.h" */+#include "HsUnixConfig.h" +#if HAVE_EXECVPE+# define _GNU_SOURCE+#endif++#include <errno.h>+#include <sys/types.h>+#if HAVE_SYS_WAIT_H+# include <sys/wait.h>+#endif #include <unistd.h> #include <sys/time.h> #include <stdlib.h> #include <string.h> #include <errno.h> +#define HSUNIX_EXECVPE_H_NO_COMPAT+#include "execvpe.h"+ /* * We want the search semantics of execvp, but we want to provide our * own environment, like execve. The following copyright applies to@@ -59,8 +67,11 @@ */ int-execvpe(char *name, char *const argv[], char **envp)+__hsunix_execvpe(const char *name, char *const argv[], char *const envp[]) {+#if HAVE_EXECVPE+ return execvpe(name, argv, envp);+#else register int lp, ln; register char *p; int eacces=0, etxtbsy=0;@@ -75,18 +86,18 @@ /* Get the path we're searching. */ if (!(path = getenv("PATH"))) {-#ifdef HAVE_CONFSTR+# ifdef HAVE_CONFSTR ln = confstr(_CS_PATH, NULL, 0); if ((cur = path = malloc(ln + 1)) != NULL) { path[0] = ':'; (void) confstr (_CS_PATH, path + 1, ln); }-#else+# else if ((cur = path = malloc(1 + 1)) != NULL) { path[0] = ':'; path[1] = '\0'; }-#endif+# endif } else cur = path = strdup(path); @@ -120,6 +131,7 @@ case EACCES: eacces = 1; break;+ case ENOTDIR: case ENOENT: break; case ENOEXEC:@@ -157,16 +169,5 @@ if (buf) free(buf); return (-1);-} #endif---/* Copied verbatim from ghc/lib/std/cbits/system.c. */-void pPrPr_disableITimers (void)-{-#ifdef __GLASGOW_HASKELL__- stopTimer();-#endif }--#endif
+ cbits/ghcrts.c view
@@ -0,0 +1,15 @@+#ifdef __GLASGOW_HASKELL__+// for 'void StopTimer(void)' prototype+# include "Rts.h"+#endif++#define HSUNIX_EXECVPE_H_NO_COMPAT+#include "execvpe.h"++/* Copied verbatim from ghc/lib/std/cbits/system.c. */+void pPrPr_disableITimers (void)+{+#ifdef __GLASGOW_HASKELL__+ stopTimer();+#endif+}
changelog.md view
@@ -1,3 +1,39 @@+# Changelog for [`unix` package](http://hackage.haskell.org/package/unix)++## 2.7.1.0 *Dec 2014*++ * Bundled with GHC 7.10.1++ * Add support for `base-4.8.0.0`++ * Tighten `SafeHaskell` bounds for GHC 7.10+++ * Add haddock comments on `RTLD_NEXT` and `RTLD_DEFAULT`++ * Deprecate function `haveRtldLocal`++ * Fix `getGroupEntryForID/getGroupEntryForName` on Solaris. Solaris uses+ CPP macros for required `getgrgid_r` and `getgrnam_r` functions definition+ so the fix is to change from C ABI calling convention to C API calling+ convention++ * Fix potential type-mismatch in `telldir`/`seekdir` FFI imports++ * Use CAPI FFI import for `truncate` to make sure the LFS-version is used.++ * `executeFile`: Fix `ENOTDIR` error for entries with non-directory+ components in `PATH` (and instead skip over non-directory `PATH`-elements)++ * New functions in `System.Posix.Unistd`:+ - `fileSynchronise` (aka `fsync(2)`), and+ - `fileSynchroniseDataOnly` (aka `fdatasync(2)`)++ * New module `System.Posix.Fcntl` providing+ - `fileAdvise` (aka `posix_fadvise(2)`), and+ - `fileAllocate` (aka `posix_fallocate(2)`)++ * Fix SIGINFO and SIGWINCH definitions+ ## 2.7.0.1 *Mar 2014* * Bundled with GHC 7.8.1
config.guess view
@@ -1,8 +1,8 @@ #! /bin/sh # Attempt to guess a canonical system name.-# Copyright 1992-2013 Free Software Foundation, Inc.+# Copyright 1992-2014 Free Software Foundation, Inc. -timestamp='2013-06-10'+timestamp='2014-03-23' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by@@ -50,7 +50,7 @@ GNU config.guess ($timestamp) Originally written by Per Bothner.-Copyright 1992-2013 Free Software Foundation, Inc.+Copyright 1992-2014 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."@@ -149,7 +149,7 @@ LIBC=gnu #endif EOF- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`+ eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` ;; esac @@ -826,7 +826,7 @@ *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;;- i*:MSYS*:*)+ *:MSYS*:*) echo ${UNAME_MACHINE}-pc-msys exit ;; i*:windows32*:*)@@ -969,10 +969,10 @@ eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } ;;- or1k:Linux:*:*)- echo ${UNAME_MACHINE}-unknown-linux-${LIBC}+ openrisc*:Linux:*:*)+ echo or1k-unknown-linux-${LIBC} exit ;;- or32:Linux:*:*)+ or32:Linux:*:* | or1k*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-${LIBC} exit ;; padre:Linux:*:*)@@ -1260,16 +1260,26 @@ if test "$UNAME_PROCESSOR" = unknown ; then UNAME_PROCESSOR=powerpc fi- if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then- if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \- (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \- grep IS_64BIT_ARCH >/dev/null- then- case $UNAME_PROCESSOR in- i386) UNAME_PROCESSOR=x86_64 ;;- powerpc) UNAME_PROCESSOR=powerpc64 ;;- esac+ if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then+ if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then+ if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \+ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \+ grep IS_64BIT_ARCH >/dev/null+ then+ case $UNAME_PROCESSOR in+ i386) UNAME_PROCESSOR=x86_64 ;;+ powerpc) UNAME_PROCESSOR=powerpc64 ;;+ esac+ fi fi+ elif test "$UNAME_PROCESSOR" = i386 ; then+ # Avoid executing cc on OS X 10.9, as it ships with a stub+ # that puts up a graphical alert prompting to install+ # developer tools. Any system running Mac OS X 10.7 or+ # later (Darwin 11 and later) is required to have a 64-bit+ # processor. This is not true of the ARM version of Darwin+ # that Apple uses in portable devices.+ UNAME_PROCESSOR=x86_64 fi echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;;@@ -1360,154 +1370,6 @@ echo ${UNAME_MACHINE}-unknown-esx exit ;; esac--eval $set_cc_for_build-cat >$dummy.c <<EOF-#ifdef _SEQUENT_-# include <sys/types.h>-# include <sys/utsname.h>-#endif-main ()-{-#if defined (sony)-#if defined (MIPSEB)- /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,- I don't know.... */- printf ("mips-sony-bsd\n"); exit (0);-#else-#include <sys/param.h>- printf ("m68k-sony-newsos%s\n",-#ifdef NEWSOS4- "4"-#else- ""-#endif- ); exit (0);-#endif-#endif--#if defined (__arm) && defined (__acorn) && defined (__unix)- printf ("arm-acorn-riscix\n"); exit (0);-#endif--#if defined (hp300) && !defined (hpux)- printf ("m68k-hp-bsd\n"); exit (0);-#endif--#if defined (NeXT)-#if !defined (__ARCHITECTURE__)-#define __ARCHITECTURE__ "m68k"-#endif- int version;- version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;- if (version < 4)- printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);- else- printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);- exit (0);-#endif--#if defined (MULTIMAX) || defined (n16)-#if defined (UMAXV)- printf ("ns32k-encore-sysv\n"); exit (0);-#else-#if defined (CMU)- printf ("ns32k-encore-mach\n"); exit (0);-#else- printf ("ns32k-encore-bsd\n"); exit (0);-#endif-#endif-#endif--#if defined (__386BSD__)- printf ("i386-pc-bsd\n"); exit (0);-#endif--#if defined (sequent)-#if defined (i386)- printf ("i386-sequent-dynix\n"); exit (0);-#endif-#if defined (ns32000)- printf ("ns32k-sequent-dynix\n"); exit (0);-#endif-#endif--#if defined (_SEQUENT_)- struct utsname un;-- uname(&un);-- if (strncmp(un.version, "V2", 2) == 0) {- printf ("i386-sequent-ptx2\n"); exit (0);- }- if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */- printf ("i386-sequent-ptx1\n"); exit (0);- }- printf ("i386-sequent-ptx\n"); exit (0);--#endif--#if defined (vax)-# if !defined (ultrix)-# include <sys/param.h>-# if defined (BSD)-# if BSD == 43- printf ("vax-dec-bsd4.3\n"); exit (0);-# else-# if BSD == 199006- printf ("vax-dec-bsd4.3reno\n"); exit (0);-# else- printf ("vax-dec-bsd\n"); exit (0);-# endif-# endif-# else- printf ("vax-dec-bsd\n"); exit (0);-# endif-# else- printf ("vax-dec-ultrix\n"); exit (0);-# endif-#endif--#if defined (alliant) && defined (i860)- printf ("i860-alliant-bsd\n"); exit (0);-#endif-- exit (1);-}-EOF--$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&- { echo "$SYSTEM_NAME"; exit; }--# Apollos put the system type in the environment.--test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }--# Convex versions that predate uname can use getsysinfo(1)--if [ -x /usr/convex/getsysinfo ]-then- case `getsysinfo -f cpu_type` in- c1*)- echo c1-convex-bsd- exit ;;- c2*)- if getsysinfo -f scalar_acc- then echo c32-convex-bsd- else echo c2-convex-bsd- fi- exit ;;- c34*)- echo c34-convex-bsd- exit ;;- c38*)- echo c38-convex-bsd- exit ;;- c4*)- echo c4-convex-bsd- exit ;;- esac-fi cat >&2 <<EOF $0: unable to guess system type
config.sub view
@@ -1,8 +1,8 @@ #! /bin/sh # Configuration validation subroutine script.-# Copyright 1992-2013 Free Software Foundation, Inc.+# Copyright 1992-2014 Free Software Foundation, Inc. -timestamp='2013-08-10'+timestamp='2014-05-01' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by@@ -68,7 +68,7 @@ version="\ GNU config.sub ($timestamp) -Copyright 1992-2013 Free Software Foundation, Inc.+Copyright 1992-2014 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."@@ -265,6 +265,7 @@ | hexagon \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \+ | k1om \ | le32 | le64 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \@@ -282,8 +283,10 @@ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \+ | mipsisa32r6 | mipsisa32r6el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \+ | mipsisa64r6 | mipsisa64r6el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipsr5900 | mipsr5900el \@@ -295,8 +298,7 @@ | nds32 | nds32le | nds32be \ | nios | nios2 | nios2eb | nios2el \ | ns16k | ns32k \- | open8 \- | or1k | or32 \+ | open8 | or1k | or1knd | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ | pyramid \@@ -324,7 +326,7 @@ c6x) basic_machine=tic6x-unknown ;;- m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip)+ m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) basic_machine=$basic_machine-unknown os=-none ;;@@ -381,6 +383,7 @@ | hexagon-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \+ | k1om-* \ | le32-* | le64-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \@@ -400,8 +403,10 @@ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \+ | mipsisa32r6-* | mipsisa32r6el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \+ | mipsisa64r6-* | mipsisa64r6el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipsr5900-* | mipsr5900el-* \@@ -413,6 +418,7 @@ | nios-* | nios2-* | nios2eb-* | nios2el-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | open8-* \+ | or1k*-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \@@ -1374,7 +1380,7 @@ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \- | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*)+ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*)@@ -1590,9 +1596,6 @@ os=-elf ;; mips*-*)- os=-elf- ;;- or1k-*) os=-elf ;; or32-*)
configure view
@@ -3674,7 +3674,7 @@ We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1];@@ -3720,7 +3720,7 @@ We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1];@@ -3744,7 +3744,7 @@ We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1];@@ -3789,7 +3789,7 @@ We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1];@@ -3813,7 +3813,7 @@ We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1];@@ -4009,6 +4009,18 @@ done +for ac_func in execvpe+do :+ ac_fn_c_check_func "$LINENO" "execvpe" "ac_cv_func_execvpe"+if test "x$ac_cv_func_execvpe" = xyes; then :+ cat >>confdefs.h <<_ACEOF+#define HAVE_EXECVPE 1+_ACEOF++fi+done++ ac_fn_c_check_member "$LINENO" "struct stat" "st_atim" "ac_cv_member_struct_stat_st_atim" "$ac_includes_default" if test "x$ac_cv_member_struct_stat_st_atim" = xyes; then : @@ -4211,6 +4223,32 @@ done +# Functions for file synchronization and allocation control+for ac_func in fsync fdatasync+do :+ as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :+ cat >>confdefs.h <<_ACEOF+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1+_ACEOF++fi+done++for ac_func in posix_fadvise posix_fallocate+do :+ as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :+ cat >>confdefs.h <<_ACEOF+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1+_ACEOF++fi+done++ # Avoid adding rt if absent or unneeded # shm_open needs -lrt on linux { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing shm_open" >&5@@ -4284,7 +4322,7 @@ EXTRA_LIBS="$EXTRA_LIBS rt" fi -for fp_const_name in SIGABRT SIGALRM SIGBUS SIGCHLD SIGCONT SIGFPE SIGHUP SIGILL SIGINT SIGKILL SIGPIPE SIGQUIT SIGSEGV SIGSTOP SIGTERM SIGTSTP SIGTTIN SIGTTOU SIGUSR1 SIGUSR2 SIGPOLL SIGPROF SIGSYS SIGTRAP SIGURG SIGVTALRM SIGXCPU SIGXFSZ SIG_BLOCK SIG_SETMASK SIG_UNBLOCK+for fp_const_name in SIGABRT SIGALRM SIGBUS SIGCHLD SIGCONT SIGFPE SIGHUP SIGILL SIGINT SIGKILL SIGPIPE SIGQUIT SIGSEGV SIGSTOP SIGTERM SIGTSTP SIGTTIN SIGTTOU SIGUSR1 SIGUSR2 SIGPOLL SIGPROF SIGSYS SIGTRAP SIGURG SIGVTALRM SIGXCPU SIGXFSZ SIG_BLOCK SIG_SETMASK SIG_UNBLOCK SIGINFO SIGWINCH do as_fp_Cache=`$as_echo "fp_cv_const_$fp_const_name" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking value of $fp_const_name" >&5@@ -4486,93 +4524,6 @@ rm -f conftest* -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for RTLD_LOCAL from dlfcn.h" >&5-$as_echo_n "checking for RTLD_LOCAL from dlfcn.h... " >&6; }-cat confdefs.h - <<_ACEOF >conftest.$ac_ext-/* end confdefs.h. */-- #include <dlfcn.h>- #ifdef RTLD_LOCAL- yes- #endif--_ACEOF-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |- $EGREP "yes" >/dev/null 2>&1; then :-- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5-$as_echo "yes" >&6; }--$as_echo "#define HAVE_RTLDLOCAL 1" >>confdefs.h---else-- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5-$as_echo "no" >&6; }--fi-rm -f conftest*---{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for RTLD_GLOBAL from dlfcn.h" >&5-$as_echo_n "checking for RTLD_GLOBAL from dlfcn.h... " >&6; }-cat confdefs.h - <<_ACEOF >conftest.$ac_ext-/* end confdefs.h. */-- #include <dlfcn.h>- #ifdef RTLD_GLOBAL- yes- #endif--_ACEOF-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |- $EGREP "yes" >/dev/null 2>&1; then :-- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5-$as_echo "yes" >&6; }--$as_echo "#define HAVE_RTLDGLOBAL 1" >>confdefs.h---else-- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5-$as_echo "no" >&6; }--fi-rm -f conftest*---{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for RTLD_NOW from dlfcn.h" >&5-$as_echo_n "checking for RTLD_NOW from dlfcn.h... " >&6; }-cat confdefs.h - <<_ACEOF >conftest.$ac_ext-/* end confdefs.h. */-- #include <dlfcn.h>- #ifdef RTLD_NOW- yes- #endif--_ACEOF-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |- $EGREP "yes" >/dev/null 2>&1; then :-- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5-$as_echo "yes" >&6; }--$as_echo "#define HAVE_RTLDNOW 1" >>confdefs.h---else-- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5-$as_echo "no" >&6; }--fi-rm -f conftest*-- for ac_func in openpty do : ac_fn_c_check_func "$LINENO" "openpty" "ac_cv_func_openpty"@@ -4700,13 +4651,12 @@ fi # Avoid adding dl if absent or unneeded-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5-$as_echo_n "checking for dlopen in -ldl... " >&6; }-if ${ac_cv_lib_dl_dlopen+:} false; then :+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlopen" >&5+$as_echo_n "checking for library containing dlopen... " >&6; }+if ${ac_cv_search_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else- ac_check_lib_save_LIBS=$LIBS-LIBS="-ldl $LIBS"+ ac_func_search_save_LIBS=$LIBS cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -4725,19 +4675,36 @@ return 0; } _ACEOF-if ac_fn_c_try_link "$LINENO"; then :- ac_cv_lib_dl_dlopen=yes-else- ac_cv_lib_dl_dlopen=no+for ac_lib in '' dl; do+ if test -z "$ac_lib"; then+ ac_res="none required"+ else+ ac_res=-l$ac_lib+ LIBS="-l$ac_lib $ac_func_search_save_LIBS"+ fi+ if ac_fn_c_try_link "$LINENO"; then :+ ac_cv_search_dlopen=$ac_res fi rm -f core conftest.err conftest.$ac_objext \- conftest$ac_exeext conftest.$ac_ext-LIBS=$ac_check_lib_save_LIBS+ conftest$ac_exeext+ if ${ac_cv_search_dlopen+:} false; then :+ break fi-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5-$as_echo "$ac_cv_lib_dl_dlopen" >&6; }-if test "x$ac_cv_lib_dl_dlopen" = xyes; then :- EXTRA_LIBS="$EXTRA_LIBS dl"+done+if ${ac_cv_search_dlopen+:} false; then :++else+ ac_cv_search_dlopen=no+fi+rm conftest.$ac_ext+LIBS=$ac_func_search_save_LIBS+fi+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dlopen" >&5+$as_echo "$ac_cv_search_dlopen" >&6; }+ac_res=$ac_cv_search_dlopen+if test "$ac_res" != no; then :+ test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"+ EXTRA_LIBS="$EXTRA_LIBS $ac_lib" fi
configure.ac view
@@ -18,6 +18,9 @@ dnl ** Enable large file support. NB. do this before testing the type of dnl off_t, because it will affect the result of that test.+dnl+dnl WARNING: It's essential this check agrees with HsBaseConfig.h as otherwise+dnl the definitions of COff/coff_t don't line up AC_SYS_LARGEFILE AC_CHECK_HEADERS([dirent.h fcntl.h grp.h limits.h pwd.h signal.h string.h])@@ -36,6 +39,9 @@ dnl not available on android so check for it AC_CHECK_FUNCS([telldir seekdir]) +dnl This is e.g. available as a GNU extension in glibc 2.11++AC_CHECK_FUNCS([execvpe])+ AC_CHECK_MEMBERS([struct stat.st_atim]) AC_CHECK_MEMBERS([struct stat.st_mtim]) AC_CHECK_MEMBERS([struct stat.st_ctim])@@ -61,12 +67,16 @@ # Additional temp functions AC_CHECK_FUNCS([mkstemps mkdtemp]) +# Functions for file synchronization and allocation control+AC_CHECK_FUNCS([fsync fdatasync])+AC_CHECK_FUNCS([posix_fadvise posix_fallocate])+ # Avoid adding rt if absent or unneeded # shm_open needs -lrt on linux AC_SEARCH_LIBS(shm_open, rt, [AC_CHECK_FUNCS([shm_open shm_unlink])]) AS_IF([test "x$ac_cv_search_shm_open" = x-lrt], [EXTRA_LIBS="$EXTRA_LIBS rt"]) -FP_CHECK_CONSTS([SIGABRT SIGALRM SIGBUS SIGCHLD SIGCONT SIGFPE SIGHUP SIGILL SIGINT SIGKILL SIGPIPE SIGQUIT SIGSEGV SIGSTOP SIGTERM SIGTSTP SIGTTIN SIGTTOU SIGUSR1 SIGUSR2 SIGPOLL SIGPROF SIGSYS SIGTRAP SIGURG SIGVTALRM SIGXCPU SIGXFSZ SIG_BLOCK SIG_SETMASK SIG_UNBLOCK], [+FP_CHECK_CONSTS([SIGABRT SIGALRM SIGBUS SIGCHLD SIGCONT SIGFPE SIGHUP SIGILL SIGINT SIGKILL SIGPIPE SIGQUIT SIGSEGV SIGSTOP SIGTERM SIGTSTP SIGTTIN SIGTTOU SIGUSR1 SIGUSR2 SIGPOLL SIGPROF SIGSYS SIGTRAP SIGURG SIGVTALRM SIGXCPU SIGXFSZ SIG_BLOCK SIG_SETMASK SIG_UNBLOCK SIGINFO SIGWINCH], [ #if HAVE_SIGNAL_H #include <signal.h> #endif])@@ -124,7 +134,9 @@ ;; esac -dnl ** sometimes RTLD_NEXT is hidden in #ifdefs we really don't wan to set+dnl On some hosts (e.g. SuSe and Ubuntu Linux) RTLD_NEXT and RTLD_DEFAULT are+dnl not visible without setting _GNU_SOURCE, which we really don't want to.+dnl Also see comments in System/Posix/DynamicLinker/Prim.hsc. AC_MSG_CHECKING(for RTLD_NEXT from dlfcn.h) AC_EGREP_CPP(yes, [@@ -139,7 +151,6 @@ AC_MSG_RESULT(no) ]) -dnl ** RTLD_DEFAULT isn't available on cygwin AC_MSG_CHECKING(for RTLD_DEFAULT from dlfcn.h) AC_EGREP_CPP(yes, [@@ -154,51 +165,6 @@ AC_MSG_RESULT(no) ]) -dnl ** RTLD_LOCAL isn't available on cygwin or openbsd-AC_MSG_CHECKING(for RTLD_LOCAL from dlfcn.h)-AC_EGREP_CPP(yes,-[- #include <dlfcn.h>- #ifdef RTLD_LOCAL- yes- #endif-], [- AC_MSG_RESULT(yes)- AC_DEFINE([HAVE_RTLDLOCAL], [1], [Define to 1 if RTLD_LOCAL is available.])-], [- AC_MSG_RESULT(no)- ]) --dnl ** RTLD_GLOBAL isn't available on openbsd-AC_MSG_CHECKING(for RTLD_GLOBAL from dlfcn.h)-AC_EGREP_CPP(yes,-[- #include <dlfcn.h>- #ifdef RTLD_GLOBAL- yes- #endif-], [- AC_MSG_RESULT(yes)- AC_DEFINE([HAVE_RTLDGLOBAL], [1], [Define to 1 if RTLD_GLOBAL is available.])-], [- AC_MSG_RESULT(no)- ]) --dnl ** RTLD_NOW isn't available on openbsd-AC_MSG_CHECKING(for RTLD_NOW from dlfcn.h)-AC_EGREP_CPP(yes,-[- #include <dlfcn.h>- #ifdef RTLD_NOW- yes- #endif-], [- AC_MSG_RESULT(yes)- AC_DEFINE([HAVE_RTLDNOW], [1], [Define to 1 if we can see RTLD_NOW in dlfcn.h])-], [- AC_MSG_RESULT(no)- ]) - AC_CHECK_FUNCS(openpty,, AC_CHECK_LIB(util,openpty, [AC_DEFINE(HAVE_OPENPTY) EXTRA_LIBS="$EXTRA_LIBS util"],@@ -227,7 +193,7 @@ fi # Avoid adding dl if absent or unneeded-AC_CHECK_LIB(dl, dlopen, [EXTRA_LIBS="$EXTRA_LIBS dl"])+AC_SEARCH_LIBS([dlopen], [dl], [EXTRA_LIBS="$EXTRA_LIBS $ac_lib"]) # -{l,}pthread goo AC_CANONICAL_TARGET
include/HsUnix.h view
@@ -119,13 +119,6 @@ #define O_SYNC O_FSYNC #endif -#ifdef SIGINFO-int __hsunix_SIGINFO();-#endif-#ifdef SIGWINCH-int __hsunix_SIGWINCH();-#endif- // lstat is a macro on some platforms, so we need a wrapper: int __hsunix_lstat(const char *path, struct stat *buf);
include/HsUnixConfig.h.in view
@@ -24,6 +24,9 @@ /* The value of SIGILL. */ #undef CONST_SIGILL +/* The value of SIGINFO. */+#undef CONST_SIGINFO+ /* The value of SIGINT. */ #undef CONST_SIGINT @@ -78,6 +81,9 @@ /* The value of SIGVTALRM. */ #undef CONST_SIGVTALRM +/* The value of SIGWINCH. */+#undef CONST_SIGWINCH+ /* The value of SIGXCPU. */ #undef CONST_SIGXCPU @@ -108,9 +114,18 @@ /* Define to 1 if you have the <dirent.h> header file. */ #undef HAVE_DIRENT_H +/* Define to 1 if you have the `execvpe' function. */+#undef HAVE_EXECVPE+ /* Define to 1 if you have the <fcntl.h> header file. */ #undef HAVE_FCNTL_H +/* Define to 1 if you have the `fdatasync' function. */+#undef HAVE_FDATASYNC++/* Define to 1 if you have the `fsync' function. */+#undef HAVE_FSYNC+ /* Define to 1 if you have the `futimens' function. */ #undef HAVE_FUTIMENS @@ -177,6 +192,12 @@ /* Define to 1 if you have the `openpty' function. */ #undef HAVE_OPENPTY +/* Define to 1 if you have the `posix_fadvise' function. */+#undef HAVE_POSIX_FADVISE++/* Define to 1 if you have the `posix_fallocate' function. */+#undef HAVE_POSIX_FALLOCATE+ /* Define to 1 if you have the `ptsname' function. */ #undef HAVE_PTSNAME @@ -192,17 +213,8 @@ /* Define to 1 if RTLD_DEFAULT is available. */ #undef HAVE_RTLDDEFAULT -/* Define to 1 if RTLD_GLOBAL is available. */-#undef HAVE_RTLDGLOBAL--/* Define to 1 if RTLD_LOCAL is available. */-#undef HAVE_RTLDLOCAL- /* Define to 1 if we can see RTLD_NEXT in dlfcn.h. */ #undef HAVE_RTLDNEXT--/* Define to 1 if we can see RTLD_NOW in dlfcn.h */-#undef HAVE_RTLDNOW /* Define to 1 if <unistd.h> defines _SC_GETGR_R_SIZE_MAX. */ #undef HAVE_SC_GETGR_R_SIZE_MAX
include/execvpe.h view
@@ -1,27 +1,29 @@ /* ---------------------------------------------------------------------------- (c) The University of Glasgow 2004 - Interface for code in execvpe.c+ Interface for code in cbits/execvpe.c ------------------------------------------------------------------------- */ -#include "HsUnixConfig.h"-// Otherwise these clash with similar definitions from other packages:-#undef PACKAGE_BUGREPORT-#undef PACKAGE_NAME-#undef PACKAGE_STRING-#undef PACKAGE_TARNAME-#undef PACKAGE_VERSION+#ifndef HSUNIX_EXECVPE_H+#define HSUNIX_EXECVPE_H -#include <errno.h>-#include <sys/types.h>-#if HAVE_SYS_WAIT_H-#include <sys/wait.h>-#endif+extern int+__hsunix_execvpe(const char *name, char *const argv[], char *const envp[]); -#if !defined(_MSC_VER) && !defined(__MINGW32__) && !defined(_WIN32)-#ifndef __QNXNTO__-extern int execvpe(char *name, char *const argv[], char **envp);+// this hack is needed for `process`; to be removed in unix-2.8+#ifndef HSUNIX_EXECVPE_H_NO_COMPAT+#include "HsUnixConfig.h"+#if HAVE_EXECVPE+# define _GNU_SOURCE+# include <unistd.h>+extern int+execvpe(const char *name, char *const argv[], char *const envp[]);+#else+# define execvpe(name,argv,envp) __hsunix_execvpe(name,argv,envp) #endif-extern void pPrPr_disableITimers (void); #endif +// implemented in cbits/ghcrts.c+extern void pPrPr_disableITimers (void);++#endif
unix.cabal view
@@ -1,15 +1,16 @@ name: unix-version: 2.7.0.1--- GHC 7.6.1 released with 2.6.0.0+version: 2.7.1.0+-- NOTE: Don't forget to update ./changelog.md license: BSD3 license-file: LICENSE maintainer: libraries@haskell.org-bug-reports: http://ghc.haskell.org/trac/ghc/newticket?component=libraries/unix+homepage: https://github.com/haskell/unix+bug-reports: https://github.com/haskell/unix/issues synopsis: POSIX functionality category: System build-type: Configure cabal-version: >= 1.10-tested-with: GHC==7.6.3, GHC==7.6.2, GHC==7.6.1, GHC==7.4.2, GHC==7.4.1+tested-with: GHC>=7.4.1 description: This package gives you access to the set of operating system services standardised by POSIX 1003.1b (or the IEEE Portable@@ -38,12 +39,7 @@ source-repository head type: git- location: http://git.haskell.org/packages/unix.git--source-repository this- type: git- location: http://git.haskell.org/packages/unix.git- tag: unix-2.7.0.1-release+ location: https://github.com/haskell/unix.git library default-language: Haskell2010@@ -52,9 +48,10 @@ CPP DeriveDataTypeable InterruptibleFFI- NoMonomorphismRestriction+ NondecreasingIndentation OverloadedStrings RankNTypes+ RecordWildCards if impl(ghc) other-extensions:@@ -62,9 +59,9 @@ Trustworthy build-depends:- base >= 4.5 && < 4.8,+ base >= 4.5 && < 4.9, bytestring >= 0.9.2 && < 0.11,- time >= 1.2 && < 1.5+ time >= 1.2 && < 1.6 exposed-modules: System.Posix@@ -100,6 +97,8 @@ System.Posix.Env System.Posix.Env.ByteString + System.Posix.Fcntl+ System.Posix.Process System.Posix.Process.Internals System.Posix.Process.ByteString@@ -131,3 +130,4 @@ cbits/HsUnix.c cbits/dirUtils.c cbits/execvpe.c+ cbits/ghcrts.c