{-# LANGUAGE Trustworthy #-}{-# LANGUAGE CPP, NoImplicitPrelude, ForeignFunctionInterface #-}{-# OPTIONS_GHC -#include "HsBase.h" #-}------------------------------------------------------------------------------- |-- Module : Foreign.C.Error-- Copyright : (c) The FFI task force 2001-- License : BSD-style (see the file libraries/base/LICENSE)-- -- Maintainer : ffi@haskell.org-- Stability : provisional-- Portability : portable---- C-specific Marshalling support: Handling of C \"errno\" error codes.-------------------------------------------------------------------------------moduleForeign.C.Error(-- * Haskell representations of @errno@ valuesErrno(..),-- instance: Eq-- ** Common @errno@ symbols-- | Different operating systems and\/or C libraries often support-- different values of @errno@. This module defines the common values,-- but due to the open definition of 'Errno' users may add definitions-- which are not predefined.eOK,e2BIG,eACCES,eADDRINUSE,eADDRNOTAVAIL,eADV,eAFNOSUPPORT,eAGAIN,eALREADY,eBADF,eBADMSG,eBADRPC,eBUSY,eCHILD,eCOMM,eCONNABORTED,eCONNREFUSED,eCONNRESET,eDEADLK,eDESTADDRREQ,eDIRTY,eDOM,eDQUOT,eEXIST,eFAULT,eFBIG,eFTYPE,eHOSTDOWN,eHOSTUNREACH,eIDRM,eILSEQ,eINPROGRESS,eINTR,eINVAL,eIO,eISCONN,eISDIR,eLOOP,eMFILE,eMLINK,eMSGSIZE,eMULTIHOP,eNAMETOOLONG,eNETDOWN,eNETRESET,eNETUNREACH,eNFILE,eNOBUFS,eNODATA,eNODEV,eNOENT,eNOEXEC,eNOLCK,eNOLINK,eNOMEM,eNOMSG,eNONET,eNOPROTOOPT,eNOSPC,eNOSR,eNOSTR,eNOSYS,eNOTBLK,eNOTCONN,eNOTDIR,eNOTEMPTY,eNOTSOCK,eNOTTY,eNXIO,eOPNOTSUPP,ePERM,ePFNOSUPPORT,ePIPE,ePROCLIM,ePROCUNAVAIL,ePROGMISMATCH,ePROGUNAVAIL,ePROTO,ePROTONOSUPPORT,ePROTOTYPE,eRANGE,eREMCHG,eREMOTE,eROFS,eRPCMISMATCH,eRREMOTE,eSHUTDOWN,eSOCKTNOSUPPORT,eSPIPE,eSRCH,eSRMNT,eSTALE,eTIME,eTIMEDOUT,eTOOMANYREFS,eTXTBSY,eUSERS,eWOULDBLOCK,eXDEV,-- ** 'Errno' functions-- :: ErrnoisValidErrno,-- :: Errno -> Bool-- access to the current thread's "errno" value--getErrno,-- :: IO ErrnoresetErrno,-- :: IO ()-- conversion of an "errno" value into IO error--errnoToIOError,-- :: String -- location-- -> Errno -- errno-- -> Maybe Handle -- handle-- -> Maybe String -- filename-- -> IOError-- throw current "errno" value--throwErrno,-- :: String -> IO a-- ** Guards for IO operations that may failthrowErrnoIf,-- :: (a -> Bool) -> String -> IO a -> IO athrowErrnoIf_,-- :: (a -> Bool) -> String -> IO a -> IO ()throwErrnoIfRetry,-- :: (a -> Bool) -> String -> IO a -> IO athrowErrnoIfRetry_,-- :: (a -> Bool) -> String -> IO a -> IO ()throwErrnoIfMinus1,-- :: Num a -- => String -> IO a -> IO athrowErrnoIfMinus1_,-- :: Num a -- => String -> IO a -> IO ()throwErrnoIfMinus1Retry,-- :: Num a -- => String -> IO a -> IO athrowErrnoIfMinus1Retry_,-- :: Num a -- => String -> IO a -> IO ()throwErrnoIfNull,-- :: String -> IO (Ptr a) -> IO (Ptr a)throwErrnoIfNullRetry,-- :: String -> IO (Ptr a) -> IO (Ptr a)throwErrnoIfRetryMayBlock,throwErrnoIfRetryMayBlock_,throwErrnoIfMinus1RetryMayBlock,throwErrnoIfMinus1RetryMayBlock_,throwErrnoIfNullRetryMayBlock,throwErrnoPath,throwErrnoPathIf,throwErrnoPathIf_,throwErrnoPathIfNull,throwErrnoPathIfMinus1,throwErrnoPathIfMinus1_,)where-- this is were we get the CONST_XXX definitions from that configure-- calculated for us--#ifndef __NHC__#include "HsBaseConfig.h"#endifimportForeign.PtrimportForeign.C.TypesimportForeign.C.StringimportForeign.Marshal.Error(void)importData.Maybe#if __GLASGOW_HASKELL__importGHC.IOimportGHC.IO.ExceptionimportGHC.IO.Handle.TypesimportGHC.NumimportGHC.Base#elif __HUGS__importHugs.Prelude(Handle,IOError,ioError)importSystem.IO.Unsafe(unsafePerformIO)#elseimportSystem.IO(Handle)importSystem.IO.Error(IOError,ioError)importSystem.IO.Unsafe(unsafePerformIO)importForeign.Storable(Storable(poke,peek))#endif#ifdef __HUGS__{-# CFILES cbits/PrelIOUtils.c #-}#endif-- "errno" type-- -------------- | Haskell representation for @errno@ values.-- The implementation is deliberately exposed, to allow users to add-- their own definitions of 'Errno' values.newtypeErrno=ErrnoCIntinstanceEqErrnowhereerrno1@(Errnono1)==errno2@(Errnono2)|isValidErrnoerrno1&&isValidErrnoerrno2=no1==no2|otherwise=False-- common "errno" symbols--eOK,e2BIG,eACCES,eADDRINUSE,eADDRNOTAVAIL,eADV,eAFNOSUPPORT,eAGAIN,eALREADY,eBADF,eBADMSG,eBADRPC,eBUSY,eCHILD,eCOMM,eCONNABORTED,eCONNREFUSED,eCONNRESET,eDEADLK,eDESTADDRREQ,eDIRTY,eDOM,eDQUOT,eEXIST,eFAULT,eFBIG,eFTYPE,eHOSTDOWN,eHOSTUNREACH,eIDRM,eILSEQ,eINPROGRESS,eINTR,eINVAL,eIO,eISCONN,eISDIR,eLOOP,eMFILE,eMLINK,eMSGSIZE,eMULTIHOP,eNAMETOOLONG,eNETDOWN,eNETRESET,eNETUNREACH,eNFILE,eNOBUFS,eNODATA,eNODEV,eNOENT,eNOEXEC,eNOLCK,eNOLINK,eNOMEM,eNOMSG,eNONET,eNOPROTOOPT,eNOSPC,eNOSR,eNOSTR,eNOSYS,eNOTBLK,eNOTCONN,eNOTDIR,eNOTEMPTY,eNOTSOCK,eNOTTY,eNXIO,eOPNOTSUPP,ePERM,ePFNOSUPPORT,ePIPE,ePROCLIM,ePROCUNAVAIL,ePROGMISMATCH,ePROGUNAVAIL,ePROTO,ePROTONOSUPPORT,ePROTOTYPE,eRANGE,eREMCHG,eREMOTE,eROFS,eRPCMISMATCH,eRREMOTE,eSHUTDOWN,eSOCKTNOSUPPORT,eSPIPE,eSRCH,eSRMNT,eSTALE,eTIME,eTIMEDOUT,eTOOMANYREFS,eTXTBSY,eUSERS,eWOULDBLOCK,eXDEV::Errno---- the cCONST_XXX identifiers are cpp symbols whose value is computed by-- configure --eOK=Errno0#ifdef __NHC__#include "Errno.hs"#elsee2BIG=Errno(CONST_E2BIG)eACCES=Errno(CONST_EACCES)eADDRINUSE=Errno(CONST_EADDRINUSE)eADDRNOTAVAIL=Errno(CONST_EADDRNOTAVAIL)eADV=Errno(CONST_EADV)eAFNOSUPPORT=Errno(CONST_EAFNOSUPPORT)eAGAIN=Errno(CONST_EAGAIN)eALREADY=Errno(CONST_EALREADY)eBADF=Errno(CONST_EBADF)eBADMSG=Errno(CONST_EBADMSG)eBADRPC=Errno(CONST_EBADRPC)eBUSY=Errno(CONST_EBUSY)eCHILD=Errno(CONST_ECHILD)eCOMM=Errno(CONST_ECOMM)eCONNABORTED=Errno(CONST_ECONNABORTED)eCONNREFUSED=Errno(CONST_ECONNREFUSED)eCONNRESET=Errno(CONST_ECONNRESET)eDEADLK=Errno(CONST_EDEADLK)eDESTADDRREQ=Errno(CONST_EDESTADDRREQ)eDIRTY=Errno(CONST_EDIRTY)eDOM=Errno(CONST_EDOM)eDQUOT=Errno(CONST_EDQUOT)eEXIST=Errno(CONST_EEXIST)eFAULT=Errno(CONST_EFAULT)eFBIG=Errno(CONST_EFBIG)eFTYPE=Errno(CONST_EFTYPE)eHOSTDOWN=Errno(CONST_EHOSTDOWN)eHOSTUNREACH=Errno(CONST_EHOSTUNREACH)eIDRM=Errno(CONST_EIDRM)eILSEQ=Errno(CONST_EILSEQ)eINPROGRESS=Errno(CONST_EINPROGRESS)eINTR=Errno(CONST_EINTR)eINVAL=Errno(CONST_EINVAL)eIO=Errno(CONST_EIO)eISCONN=Errno(CONST_EISCONN)eISDIR=Errno(CONST_EISDIR)eLOOP=Errno(CONST_ELOOP)eMFILE=Errno(CONST_EMFILE)eMLINK=Errno(CONST_EMLINK)eMSGSIZE=Errno(CONST_EMSGSIZE)eMULTIHOP=Errno(CONST_EMULTIHOP)eNAMETOOLONG=Errno(CONST_ENAMETOOLONG)eNETDOWN=Errno(CONST_ENETDOWN)eNETRESET=Errno(CONST_ENETRESET)eNETUNREACH=Errno(CONST_ENETUNREACH)eNFILE=Errno(CONST_ENFILE)eNOBUFS=Errno(CONST_ENOBUFS)eNODATA=Errno(CONST_ENODATA)eNODEV=Errno(CONST_ENODEV)eNOENT=Errno(CONST_ENOENT)eNOEXEC=Errno(CONST_ENOEXEC)eNOLCK=Errno(CONST_ENOLCK)eNOLINK=Errno(CONST_ENOLINK)eNOMEM=Errno(CONST_ENOMEM)eNOMSG=Errno(CONST_ENOMSG)eNONET=Errno(CONST_ENONET)eNOPROTOOPT=Errno(CONST_ENOPROTOOPT)eNOSPC=Errno(CONST_ENOSPC)eNOSR=Errno(CONST_ENOSR)eNOSTR=Errno(CONST_ENOSTR)eNOSYS=Errno(CONST_ENOSYS)eNOTBLK=Errno(CONST_ENOTBLK)eNOTCONN=Errno(CONST_ENOTCONN)eNOTDIR=Errno(CONST_ENOTDIR)eNOTEMPTY=Errno(CONST_ENOTEMPTY)eNOTSOCK=Errno(CONST_ENOTSOCK)eNOTTY=Errno(CONST_ENOTTY)eNXIO=Errno(CONST_ENXIO)eOPNOTSUPP=Errno(CONST_EOPNOTSUPP)ePERM=Errno(CONST_EPERM)ePFNOSUPPORT=Errno(CONST_EPFNOSUPPORT)ePIPE=Errno(CONST_EPIPE)ePROCLIM=Errno(CONST_EPROCLIM)ePROCUNAVAIL=Errno(CONST_EPROCUNAVAIL)ePROGMISMATCH=Errno(CONST_EPROGMISMATCH)ePROGUNAVAIL=Errno(CONST_EPROGUNAVAIL)ePROTO=Errno(CONST_EPROTO)ePROTONOSUPPORT=Errno(CONST_EPROTONOSUPPORT)ePROTOTYPE=Errno(CONST_EPROTOTYPE)eRANGE=Errno(CONST_ERANGE)eREMCHG=Errno(CONST_EREMCHG)eREMOTE=Errno(CONST_EREMOTE)eROFS=Errno(CONST_EROFS)eRPCMISMATCH=Errno(CONST_ERPCMISMATCH)eRREMOTE=Errno(CONST_ERREMOTE)eSHUTDOWN=Errno(CONST_ESHUTDOWN)eSOCKTNOSUPPORT=Errno(CONST_ESOCKTNOSUPPORT)eSPIPE=Errno(CONST_ESPIPE)eSRCH=Errno(CONST_ESRCH)eSRMNT=Errno(CONST_ESRMNT)eSTALE=Errno(CONST_ESTALE)eTIME=Errno(CONST_ETIME)eTIMEDOUT=Errno(CONST_ETIMEDOUT)eTOOMANYREFS=Errno(CONST_ETOOMANYREFS)eTXTBSY=Errno(CONST_ETXTBSY)eUSERS=Errno(CONST_EUSERS)eWOULDBLOCK=Errno(CONST_EWOULDBLOCK)eXDEV=Errno(CONST_EXDEV)#endif-- | Yield 'True' if the given 'Errno' value is valid on the system.-- This implies that the 'Eq' instance of 'Errno' is also system dependent-- as it is only defined for valid values of 'Errno'.--isValidErrno::Errno->Bool---- the configure script sets all invalid "errno"s to -1--isValidErrno(Errnoerrno)=errno/=-1-- access to the current thread's "errno" value-- ---------------------------------------------- | Get the current value of @errno@ in the current thread.--getErrno::IOErrno-- We must call a C function to get the value of errno in general. On-- threaded systems, errno is hidden behind a C macro so that each OS-- thread gets its own copy.#ifdef __NHC__getErrno=doe<-peek_errno;return(Errnoe)foreignimportccallunsafe"errno.h &errno"_errno::PtrCInt#elsegetErrno=doe<-get_errno;return(Errnoe)foreignimportccallunsafe"HsBase.h __hscore_get_errno"get_errno::IOCInt#endif-- | Reset the current thread\'s @errno@ value to 'eOK'.--resetErrno::IO()-- Again, setting errno has to be done via a C function.#ifdef __NHC__resetErrno=poke_errno0#elseresetErrno=set_errno0foreignimportccallunsafe"HsBase.h __hscore_set_errno"set_errno::CInt->IO()#endif-- throw current "errno" value-- ----------------------------- | Throw an 'IOError' corresponding to the current value of 'getErrno'.--throwErrno::String-- ^ textual description of the error location->IOathrowErrnoloc=doerrno<-getErrnoioError(errnoToIOErrorlocerrnoNothingNothing)-- guards for IO operations that may fail-- ---------------------------------------- | Throw an 'IOError' corresponding to the current value of 'getErrno'-- if the result value of the 'IO' action meets the given predicate.--throwErrnoIf::(a->Bool)-- ^ predicate to apply to the result value-- of the 'IO' operation->String-- ^ textual description of the location->IOa-- ^ the 'IO' operation to be executed->IOathrowErrnoIfpredlocf=dores<-fifpredresthenthrowErrnolocelsereturnres-- | as 'throwErrnoIf', but discards the result of the 'IO' action after-- error handling.--throwErrnoIf_::(a->Bool)->String->IOa->IO()throwErrnoIf_predlocf=void$throwErrnoIfpredlocf-- | as 'throwErrnoIf', but retry the 'IO' action when it yields the-- error code 'eINTR' - this amounts to the standard retry loop for-- interrupted POSIX system calls.--throwErrnoIfRetry::(a->Bool)->String->IOa->IOathrowErrnoIfRetrypredlocf=dores<-fifpredresthendoerr<-getErrnoiferr==eINTRthenthrowErrnoIfRetrypredlocfelsethrowErrnolocelsereturnres-- | as 'throwErrnoIfRetry', but additionally if the operation -- yields the error code 'eAGAIN' or 'eWOULDBLOCK', an alternative-- action is executed before retrying.--throwErrnoIfRetryMayBlock::(a->Bool)-- ^ predicate to apply to the result value-- of the 'IO' operation->String-- ^ textual description of the location->IOa-- ^ the 'IO' operation to be executed->IOb-- ^ action to execute before retrying if-- an immediate retry would block->IOathrowErrnoIfRetryMayBlockpredlocfon_block=dores<-fifpredresthendoerr<-getErrnoiferr==eINTRthenthrowErrnoIfRetryMayBlockpredlocfon_blockelseiferr==eWOULDBLOCK||err==eAGAINthendo_<-on_blockthrowErrnoIfRetryMayBlockpredlocfon_blockelsethrowErrnolocelsereturnres-- | as 'throwErrnoIfRetry', but discards the result.--throwErrnoIfRetry_::(a->Bool)->String->IOa->IO()throwErrnoIfRetry_predlocf=void$throwErrnoIfRetrypredlocf-- | as 'throwErrnoIfRetryMayBlock', but discards the result.--throwErrnoIfRetryMayBlock_::(a->Bool)->String->IOa->IOb->IO()throwErrnoIfRetryMayBlock_predlocfon_block=void$throwErrnoIfRetryMayBlockpredlocfon_block-- | Throw an 'IOError' corresponding to the current value of 'getErrno'-- if the 'IO' action returns a result of @-1@.--throwErrnoIfMinus1::Numa=>String->IOa->IOathrowErrnoIfMinus1=throwErrnoIf(==-1)-- | as 'throwErrnoIfMinus1', but discards the result.--throwErrnoIfMinus1_::Numa=>String->IOa->IO()throwErrnoIfMinus1_=throwErrnoIf_(==-1)-- | Throw an 'IOError' corresponding to the current value of 'getErrno'-- if the 'IO' action returns a result of @-1@, but retries in case of-- an interrupted operation.--throwErrnoIfMinus1Retry::Numa=>String->IOa->IOathrowErrnoIfMinus1Retry=throwErrnoIfRetry(==-1)-- | as 'throwErrnoIfMinus1', but discards the result.--throwErrnoIfMinus1Retry_::Numa=>String->IOa->IO()throwErrnoIfMinus1Retry_=throwErrnoIfRetry_(==-1)-- | as 'throwErrnoIfMinus1Retry', but checks for operations that would block.--throwErrnoIfMinus1RetryMayBlock::Numa=>String->IOa->IOb->IOathrowErrnoIfMinus1RetryMayBlock=throwErrnoIfRetryMayBlock(==-1)-- | as 'throwErrnoIfMinus1RetryMayBlock', but discards the result.--throwErrnoIfMinus1RetryMayBlock_::Numa=>String->IOa->IOb->IO()throwErrnoIfMinus1RetryMayBlock_=throwErrnoIfRetryMayBlock_(==-1)-- | Throw an 'IOError' corresponding to the current value of 'getErrno'-- if the 'IO' action returns 'nullPtr'.--throwErrnoIfNull::String->IO(Ptra)->IO(Ptra)throwErrnoIfNull=throwErrnoIf(==nullPtr)-- | Throw an 'IOError' corresponding to the current value of 'getErrno'-- if the 'IO' action returns 'nullPtr',-- but retry in case of an interrupted operation.--throwErrnoIfNullRetry::String->IO(Ptra)->IO(Ptra)throwErrnoIfNullRetry=throwErrnoIfRetry(==nullPtr)-- | as 'throwErrnoIfNullRetry', but checks for operations that would block.--throwErrnoIfNullRetryMayBlock::String->IO(Ptra)->IOb->IO(Ptra)throwErrnoIfNullRetryMayBlock=throwErrnoIfRetryMayBlock(==nullPtr)-- | as 'throwErrno', but exceptions include the given path when appropriate.--throwErrnoPath::String->FilePath->IOathrowErrnoPathlocpath=doerrno<-getErrnoioError(errnoToIOErrorlocerrnoNothing(Justpath))-- | as 'throwErrnoIf', but exceptions include the given path when-- appropriate.--throwErrnoPathIf::(a->Bool)->String->FilePath->IOa->IOathrowErrnoPathIfpredlocpathf=dores<-fifpredresthenthrowErrnoPathlocpathelsereturnres-- | as 'throwErrnoIf_', but exceptions include the given path when-- appropriate.--throwErrnoPathIf_::(a->Bool)->String->FilePath->IOa->IO()throwErrnoPathIf_predlocpathf=void$throwErrnoPathIfpredlocpathf-- | as 'throwErrnoIfNull', but exceptions include the given path when-- appropriate.--throwErrnoPathIfNull::String->FilePath->IO(Ptra)->IO(Ptra)throwErrnoPathIfNull=throwErrnoPathIf(==nullPtr)-- | as 'throwErrnoIfMinus1', but exceptions include the given path when-- appropriate.--throwErrnoPathIfMinus1::Numa=>String->FilePath->IOa->IOathrowErrnoPathIfMinus1=throwErrnoPathIf(==-1)-- | as 'throwErrnoIfMinus1_', but exceptions include the given path when-- appropriate.--throwErrnoPathIfMinus1_::Numa=>String->FilePath->IOa->IO()throwErrnoPathIfMinus1_=throwErrnoPathIf_(==-1)-- conversion of an "errno" value into IO error-- ---------------------------------------------- | Construct an 'IOError' based on the given 'Errno' value.-- The optional information can be used to improve the accuracy of-- error messages.--errnoToIOError::String-- ^ the location where the error occurred->Errno-- ^ the error number->MaybeHandle-- ^ optional handle associated with the error->MaybeString-- ^ optional filename associated with the error->IOErrorerrnoToIOErrorlocerrnomaybeHdlmaybeName=unsafePerformIO$dostr<-strerrorerrno>>=peekCString#if __GLASGOW_HASKELL__return(IOErrormaybeHdlerrTypelocstr(Justerrno')maybeName)whereErrnoerrno'=errnoerrType|errno==eOK=OtherError|errno==e2BIG=ResourceExhausted|errno==eACCES=PermissionDenied|errno==eADDRINUSE=ResourceBusy|errno==eADDRNOTAVAIL=UnsupportedOperation|errno==eADV=OtherError|errno==eAFNOSUPPORT=UnsupportedOperation|errno==eAGAIN=ResourceExhausted|errno==eALREADY=AlreadyExists|errno==eBADF=InvalidArgument|errno==eBADMSG=InappropriateType|errno==eBADRPC=OtherError|errno==eBUSY=ResourceBusy|errno==eCHILD=NoSuchThing|errno==eCOMM=ResourceVanished|errno==eCONNABORTED=OtherError|errno==eCONNREFUSED=NoSuchThing|errno==eCONNRESET=ResourceVanished|errno==eDEADLK=ResourceBusy|errno==eDESTADDRREQ=InvalidArgument|errno==eDIRTY=UnsatisfiedConstraints|errno==eDOM=InvalidArgument|errno==eDQUOT=PermissionDenied|errno==eEXIST=AlreadyExists|errno==eFAULT=OtherError|errno==eFBIG=PermissionDenied|errno==eFTYPE=InappropriateType|errno==eHOSTDOWN=NoSuchThing|errno==eHOSTUNREACH=NoSuchThing|errno==eIDRM=ResourceVanished|errno==eILSEQ=InvalidArgument|errno==eINPROGRESS=AlreadyExists|errno==eINTR=Interrupted|errno==eINVAL=InvalidArgument|errno==eIO=HardwareFault|errno==eISCONN=AlreadyExists|errno==eISDIR=InappropriateType|errno==eLOOP=InvalidArgument|errno==eMFILE=ResourceExhausted|errno==eMLINK=ResourceExhausted|errno==eMSGSIZE=ResourceExhausted|errno==eMULTIHOP=UnsupportedOperation|errno==eNAMETOOLONG=InvalidArgument|errno==eNETDOWN=ResourceVanished|errno==eNETRESET=ResourceVanished|errno==eNETUNREACH=NoSuchThing|errno==eNFILE=ResourceExhausted|errno==eNOBUFS=ResourceExhausted|errno==eNODATA=NoSuchThing|errno==eNODEV=UnsupportedOperation|errno==eNOENT=NoSuchThing|errno==eNOEXEC=InvalidArgument|errno==eNOLCK=ResourceExhausted|errno==eNOLINK=ResourceVanished|errno==eNOMEM=ResourceExhausted|errno==eNOMSG=NoSuchThing|errno==eNONET=NoSuchThing|errno==eNOPROTOOPT=UnsupportedOperation|errno==eNOSPC=ResourceExhausted|errno==eNOSR=ResourceExhausted|errno==eNOSTR=InvalidArgument|errno==eNOSYS=UnsupportedOperation|errno==eNOTBLK=InvalidArgument|errno==eNOTCONN=InvalidArgument|errno==eNOTDIR=InappropriateType|errno==eNOTEMPTY=UnsatisfiedConstraints|errno==eNOTSOCK=InvalidArgument|errno==eNOTTY=IllegalOperation|errno==eNXIO=NoSuchThing|errno==eOPNOTSUPP=UnsupportedOperation|errno==ePERM=PermissionDenied|errno==ePFNOSUPPORT=UnsupportedOperation|errno==ePIPE=ResourceVanished|errno==ePROCLIM=PermissionDenied|errno==ePROCUNAVAIL=UnsupportedOperation|errno==ePROGMISMATCH=ProtocolError|errno==ePROGUNAVAIL=UnsupportedOperation|errno==ePROTO=ProtocolError|errno==ePROTONOSUPPORT=ProtocolError|errno==ePROTOTYPE=ProtocolError|errno==eRANGE=UnsupportedOperation|errno==eREMCHG=ResourceVanished|errno==eREMOTE=IllegalOperation|errno==eROFS=PermissionDenied|errno==eRPCMISMATCH=ProtocolError|errno==eRREMOTE=IllegalOperation|errno==eSHUTDOWN=IllegalOperation|errno==eSOCKTNOSUPPORT=UnsupportedOperation|errno==eSPIPE=UnsupportedOperation|errno==eSRCH=NoSuchThing|errno==eSRMNT=UnsatisfiedConstraints|errno==eSTALE=ResourceVanished|errno==eTIME=TimeExpired|errno==eTIMEDOUT=TimeExpired|errno==eTOOMANYREFS=ResourceExhausted|errno==eTXTBSY=ResourceBusy|errno==eUSERS=ResourceExhausted|errno==eWOULDBLOCK=OtherError|errno==eXDEV=UnsupportedOperation|otherwise=OtherError#elsereturn(userError(loc++": "++str++maybe""(": "++)maybeName))#endifforeignimportccallunsafe"string.h"strerror::Errno->IO(PtrCChar)