Hello,<br><br>&nbsp;&nbsp;&nbsp; Haskell 101 question! I discovered that aio_error returns &quot;errno&quot; rather -1. Of course, my aio_error binding is called before my aio_return binding (aio calling sequence &quot;protocol&quot;). I have worked on&nbsp; Posix OS&#39;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 &quot;AIOCB -&gt; IO Errno&quot; signature:<br>
<br>aioError :: AIOCB -&gt; IO Errno<br>aioError aiocb = do<br>&nbsp;&nbsp; allocaBytes (#const sizeof(struct aiocb)) $ \ p_aiocb -&gt; do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; poke p_aiocb aiocb<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; errno &lt;- throwErrnoIfMinus1 &quot;aioError&quot; (c_aio_error&nbsp; p_aiocb)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return (errno)<br><br>foreign import ccall safe &quot;aio.h aio_error&quot;<br>&nbsp;&nbsp;&nbsp; c_aio_error :: Ptr AIOCB -&gt; IO Errno<br><br>&quot;ghc&quot; thinks that &quot;Errno&quot; should be an instance of &quot;Num&quot;:<br>
<br>System/Posix/Aio.hsc:117:15:<br>&nbsp;&nbsp;&nbsp; No instance for (Num Errno)<br>&nbsp;<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 &lt;<a href="mailto:vigalchin@gmail.com">vigalchin@gmail.com</a>&gt; 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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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&#39;s in the code. .....Here is the code ...<br>

<br>aioReturn :: AIOCB -&gt; IO (AIOCB, ByteCount)<br>aioReturn aiocb = do<br>&nbsp;&nbsp; allocaBytes (#const sizeof(struct aiocb)) $ \ p_aiocb -&gt; do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; poke p_aiocb aiocb<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; count &lt;- throwErrnoIfMinus1 &quot;aioReturn&quot; (c_aio_return&nbsp; p_aiocb)<br>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; aiocb &lt;- peek p_aiocb<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return (aiocb, fromIntegral count)<br><br>foreign import ccall safe &quot;aio.h aio_return&quot;<br>&nbsp;&nbsp;&nbsp; c_aio_return :: Ptr AIOCB -&gt; IO CInt<br><br>Maybe someone can spot something that I haven&#39;t. <br>

<br>Thanks, Vasili<br>
</blockquote></div><br>