Hello,<br><br> 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:<br>
<br>aioError :: AIOCB -> IO Errno<br>aioError aiocb = do<br> allocaBytes (#const sizeof(struct aiocb)) $ \ p_aiocb -> do<br> poke p_aiocb aiocb<br> errno <- throwErrnoIfMinus1 "aioError" (c_aio_error p_aiocb)<br>
return (errno)<br><br>foreign import ccall safe "aio.h aio_error"<br> c_aio_error :: Ptr AIOCB -> IO Errno<br><br>"ghc" thinks that "Errno" should be an instance of "Num":<br>
<br>System/Posix/Aio.hsc:117:15:<br> No instance for (Num Errno)<br> <br><br>Why?<br><br>Vasili <br><br><br><br><div class="gmail_quote">On Tue, Jul 1, 2008 at 2:42 AM, Galchin, Vasili <<a href="mailto:vigalchin@gmail.com">vigalchin@gmail.com</a>> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hello,<br><br> 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 ...<br>
<br>aioReturn :: AIOCB -> IO (AIOCB, ByteCount)<br>aioReturn aiocb = do<br> allocaBytes (#const sizeof(struct aiocb)) $ \ p_aiocb -> do<br> poke p_aiocb aiocb<br> count <- throwErrnoIfMinus1 "aioReturn" (c_aio_return p_aiocb)<br>
aiocb <- peek p_aiocb<br> return (aiocb, fromIntegral count)<br><br>foreign import ccall safe "aio.h aio_return"<br> c_aio_return :: Ptr AIOCB -> IO CInt<br><br>Maybe someone can spot something that I haven't. <br>
<br>Thanks, Vasili<br>
</blockquote></div><br>