Skip to content

Warn when functions are used on unsupported platforms. #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions System/Posix/Files.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,9 @@ setSymbolicLinkTimesHiRes name atime mtime =
throwErrnoPathIfMinus1_ "setSymbolicLinkTimesHiRes" name $
c_lutimes s times
#else
{-# WARNING setSymbolicLinkTimesHiRes
"System.Posix.Files.setSymbolicLinkTImesHiRes: not available on this platform"
#-}
setSymbolicLinkTimesHiRes =
error "setSymbolicLinkTimesHiRes: not available on this platform"
#endif
Expand All @@ -406,6 +409,9 @@ touchSymbolicLink name =
withFilePath name $ \s ->
throwErrnoPathIfMinus1_ "touchSymbolicLink" name (c_lutimes s nullPtr)
#else
{-#
WARNING touchSymbolicLink "System.Posix.Files.touchSymbolicLink: not available on this platform"
#-}
touchSymbolicLink =
error "touchSymbolicLink: not available on this platform"
#endif
Expand Down
2 changes: 2 additions & 0 deletions System/Posix/Files/ByteString.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ setSymbolicLinkTimesHiRes name atime mtime =
throwErrnoPathIfMinus1_ "setSymbolicLinkTimesHiRes" name $
c_lutimes s times
#else
{-# WARNING setSymbolicLinkTimesHiRes "setSymbolicLinkTimesHiRes: not available on this platform" #-}
setSymbolicLinkTimesHiRes =
error "setSymbolicLinkTimesHiRes: not available on this platform"
#endif
Expand All @@ -406,6 +407,7 @@ touchSymbolicLink name =
withFilePath name $ \s ->
throwErrnoPathIfMinus1_ "touchSymbolicLink" name (c_lutimes s nullPtr)
#else
{-# WARNING touchSymbolicLink "touchSymbolicLink: not available on this platform" #-}
touchSymbolicLink =
error "touchSymbolicLink: not available on this platform"
#endif
Expand Down
2 changes: 2 additions & 0 deletions System/Posix/Files/Common.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,7 @@ setFdTimesHiRes (Fd fd) atime mtime =
withArray [toCTimeVal atime, toCTimeVal mtime] $ \times ->
throwErrnoIfMinus1_ "setFdTimesHiRes" (c_futimes fd times)
#else
{-# WARNING setFdTimesHiRes "setFdTimesHiRes: not available on this platform" #-}
setFdTimesHiRes =
error "setSymbolicLinkTimesHiRes: not available on this platform"
#endif
Expand All @@ -502,6 +503,7 @@ touchFd :: Fd -> IO ()
touchFd (Fd fd) =
throwErrnoIfMinus1_ "touchFd" (c_futimes fd nullPtr)
#else
{-# WARNING touchFd "touchFd: not available on this platform" #-}
touchFd =
error "touchFd: not available on this platform"
#endif
Expand Down
2 changes: 2 additions & 0 deletions System/Posix/SharedMem.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ shmOpen name flags mode =
shm_open cname cflags mode
return $ Fd fd
#else
{-# WARNING shmOpen "System.Posix.SharedMem: shm_open: not available" #-}
shmOpen = error "System.Posix.SharedMem:shm_open: not available"
#endif

Expand All @@ -75,6 +76,7 @@ shmUnlink name = withCAString name shmUnlink'
where shmUnlink' cname =
throwErrnoIfMinus1_ "shmUnlink" $ shm_unlink cname
#else
{-# WARNING shmUnlink "System.Posix.SharedMem:shm_unlink: not available" #-}
shmUnlink = error "System.Posix.SharedMem:shm_unlink: not available"
#endif

Expand Down
2 changes: 2 additions & 0 deletions System/Posix/Signals.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,8 @@ installHandler :: Signal
-> IO Handler -- ^ old handler

#ifdef __PARALLEL_HASKELL__
{-# WARNING installHandler "installHandler: not available for Parallel Haskell"
- #-}
installHandler =
error "installHandler: not available for Parallel Haskell"
#else
Expand Down
1 change: 1 addition & 0 deletions System/Posix/Temp.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ mkstemps prefix suffix = do
h <- fdToHandle (Fd fd)
return (name, h)
#else
{-# WARNING mkstemps "System.Posix.Temp.mkstemps: not available on this platform" #-}
mkstemps = error "System.Posix.Temp.mkstemps: not available on this platform"
#endif

Expand Down
1 change: 1 addition & 0 deletions System/Posix/Temp/ByteString.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ mkstemps prefix suffix = do
h <- fdToHandle (Fd fd)
return (name, h)
#else
{-# WARNING mkstemps "System.Posix.Temp.mkstemps: not available on this platform" #-}
mkstemps = error "System.Posix.Temp.mkstemps: not available on this platform"
#endif

Expand Down
5 changes: 5 additions & 0 deletions System/Posix/Terminal.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ foreign import ccall unsafe "__hsunix_ptsname"
#else
getSlaveTerminalName _ =
ioError (errnoToIOError "getSlaveTerminalName" eNOSYS Nothing Nothing)
{-# WARNING getSlaveTerminalName "getSlaveTerminalName: not available on this platform" #-}
#endif

-- -----------------------------------------------------------------------------
Expand Down Expand Up @@ -159,6 +160,10 @@ openPseudoTerminal = do
# endif /* __hpux */
return (Fd master, slave)

# ifndef HAVE_PTSNAME
{-# WARNING openPseudoTerminal "openPseudoTerminal: not available on this platform (neither OPENPTY nor PTSNAME available)" #-}
# endif /* HAVE_PTSNAME */

-- Push a STREAMS module, for System V systems.
pushModule :: Fd -> String -> IO ()
pushModule (Fd fd) name =
Expand Down
1 change: 1 addition & 0 deletions System/Posix/Terminal/ByteString.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ getSlaveTerminalName (Fd fd) = do
foreign import ccall unsafe "__hsunix_ptsname"
c_ptsname :: CInt -> IO CString
#else
{-# WARNING getSlaveTerminalName "getSlaveTerminalName: not available on this platform" #-}
getSlaveTerminalName _ =
ioError (errnoToIOError "getSlaveTerminalName" eNOSYS Nothing Nothing)
#endif
Expand Down
1 change: 1 addition & 0 deletions System/Posix/Unistd.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ foreign import ccall safe "usleep"
-- /GHC Note/: the comment for 'usleep' also applies here.
nanosleep :: Integer -> IO ()
#ifndef HAVE_NANOSLEEP
{-# WARNING nanosleep "nanosleep: not available on this platform" #-}
nanosleep = error "nanosleep: not available on this platform"
#else
nanosleep 0 = return ()
Expand Down
6 changes: 6 additions & 0 deletions System/Posix/User.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ foreign import capi unsafe "HsUnix.h getgrgid_r"
c_getgrgid_r :: CGid -> Ptr CGroup -> CString
-> CSize -> Ptr (Ptr CGroup) -> IO CInt
#else
{-# WARNING getGroupEntryForID "System.Posix.User.getGroupEntryForID: not supported" #-}
getGroupEntryForID = error "System.Posix.User.getGroupEntryForID: not supported"
#endif

Expand All @@ -230,6 +231,7 @@ foreign import capi unsafe "HsUnix.h getgrnam_r"
c_getgrnam_r :: CString -> Ptr CGroup -> CString
-> CSize -> Ptr (Ptr CGroup) -> IO CInt
#else
{-# WARNING getGroupEntryForName "System.Posix.User.getGroupEntryForName: not supported" #-}
getGroupEntryForName = error "System.Posix.User.getGroupEntryForName: not supported"
#endif

Expand Down Expand Up @@ -261,6 +263,7 @@ foreign import ccall unsafe "setgrent"
foreign import ccall unsafe "endgrent"
c_endgrent :: IO ()
#else
{-# WARNING getAllGroupEntries "System.Posix.User.getAllGroupEntries: not supported" #-}
getAllGroupEntries = error "System.Posix.User.getAllGroupEntries: not supported"
#endif

Expand Down Expand Up @@ -332,6 +335,7 @@ getUserEntryForID uid = do
foreign import ccall unsafe "getpwuid"
c_getpwuid :: CUid -> IO (Ptr CPasswd)
#else
{-# WARNING getUserEntryForID "System.Posix.User.getUserEntryForID: not supported" #-}
getUserEntryForID = error "System.Posix.User.getUserEntryForID: not supported"
#endif

Expand Down Expand Up @@ -360,6 +364,7 @@ getUserEntryForName name = do
foreign import ccall unsafe "getpwnam"
c_getpwnam :: CString -> IO (Ptr CPasswd)
#else
{-# WARNING getUserEntryForName "System.Posix.User.getUserEntryForName: not supported" #-}
getUserEntryForName = error "System.Posix.User.getUserEntryForName: not supported"
#endif

Expand All @@ -385,6 +390,7 @@ foreign import ccall unsafe "setpwent"
foreign import ccall unsafe "endpwent"
c_endpwent :: IO ()
#else
{-# WARNING getAllUserEntries "System.Posix.User.getAllUserEntries: not supported" #-}
getAllUserEntries = error "System.Posix.User.getAllUserEntries: not supported"
#endif

Expand Down