Hello, Haskell 101 question! I discovered that aio_error returns "errno" rather -1. Of course, my aio_error binding is called before my aio_return binding (aio calling sequence "protocol"). I have worked on Posix OS's for quite a while but am unhappy with non-consistent errno handling ;^(. In any case, I modified my aio_error binding implementation to have a "AIOCB -> IO Errno" signature:
aioError :: AIOCB -> IO Errno aioError aiocb = do allocaBytes (#const sizeof(struct aiocb)) $ \ p_aiocb -> do poke p_aiocb aiocb errno <- throwErrnoIfMinus1 "aioError" (c_aio_error p_aiocb) return (errno) foreign import ccall safe "aio.h aio_error" c_aio_error :: Ptr AIOCB -> IO Errno "ghc" thinks that "Errno" should be an instance of "Num": System/Posix/Aio.hsc:117:15: No instance for (Num Errno) Why? Vasili On Tue, Jul 1, 2008 at 2:42 AM, Galchin, Vasili <[EMAIL PROTECTED]> wrote: > Hello, > > I am also testing my aio support. The aio_write binding seems to > work ok .. as well as aio_error, Aio_return is a problem child. I think I > wrote a really simple binding. I always receive nbytes as 0. I have been > staring at the code hoping to catch a stupid mistake. I put putStrLn's in > the code. .....Here is the code ... > > aioReturn :: AIOCB -> IO (AIOCB, ByteCount) > aioReturn aiocb = do > allocaBytes (#const sizeof(struct aiocb)) $ \ p_aiocb -> do > poke p_aiocb aiocb > count <- throwErrnoIfMinus1 "aioReturn" (c_aio_return p_aiocb) > aiocb <- peek p_aiocb > return (aiocb, fromIntegral count) > > foreign import ccall safe "aio.h aio_return" > c_aio_return :: Ptr AIOCB -> IO CInt > > Maybe someone can spot something that I haven't. > > Thanks, Vasili >
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe