<div dir="ltr">Hi,<br><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Nov 2, 2013 at 11:35 PM, lx <span dir="ltr">&lt;<a href="mailto:lxlenovostar@gmail.com" target="_blank">lxlenovostar@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">hi all:<div>       the codes of functions is:</div><div><br></div><div><pre style="font-family:Monaco,&#39;Courier New&#39;,Courier,monospace;font-size:1.1em;padding:1em;color:rgb(0,12,0);background-color:rgb(51,51,51);overflow:auto;border:1px solid rgb(136,136,136)">
<span style="color:rgb(255,255,255)"> </span><a name="1421cad9544e9769_L51" href="http://lxr.oss.org.cn/source/include/asm-sh/posix_types.h?v=2.6.16#L51" style="text-decoration:none;border-bottom-width:1px;border-bottom-style:dotted;border-bottom-color:rgb(153,153,153);color:white" target="_blank"><span style="color:rgb(205,92,92)">51</span></a><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(135,206,235)">#undef</span><span style="color:rgb(255,255,255)">  </span><a href="http://lxr.oss.org.cn/ident?v=2.6.16;i=__FD_SET" style="text-decoration:none;border-bottom-width:1px;border-bottom-style:dotted;border-bottom-color:rgb(153,153,153);color:white" target="_blank"><span>__FD_SET</span></a><span style="color:rgb(255,255,255)">
 </span><a name="1421cad9544e9769_L52" href="http://lxr.oss.org.cn/source/include/asm-sh/posix_types.h?v=2.6.16#L52" style="text-decoration:none;border-bottom-width:1px;border-bottom-style:dotted;border-bottom-color:rgb(153,153,153);color:white" target="_blank"><span style="color:rgb(205,92,92)">52</span></a><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(240,230,140);font-weight:bold">static</span><span style="color:rgb(255,255,255)"> __inline__ </span><span style="color:rgb(240,230,140);font-weight:bold">void</span><span style="color:rgb(255,255,255)"> </span><a href="http://lxr.oss.org.cn/ident?v=2.6.16;i=__FD_SET" style="text-decoration:none;border-bottom-width:1px;border-bottom-style:dotted;border-bottom-color:rgb(153,153,153);color:white" target="_blank"><span>__FD_SET</span></a><span style="color:rgb(255,255,255)">(</span><span style="color:rgb(240,230,140);font-weight:bold">unsigned</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(240,230,140);font-weight:bold">long</span><span style="color:rgb(255,255,255)"> __fd</span><span style="color:rgb(255,255,255)">,</span><span style="color:rgb(255,255,255)"> </span><a href="http://lxr.oss.org.cn/ident?v=2.6.16;i=__kernel_fd_set" style="text-decoration:none;border-bottom-width:1px;border-bottom-style:dotted;border-bottom-color:rgb(153,153,153);color:white" target="_blank"><span>__kernel_fd_set</span></a><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,255,255)">*</span><span style="color:rgb(255,255,255)">__fdsetp</span><span style="color:rgb(255,255,255)">)</span><span style="color:rgb(255,255,255)">
 </span><a name="1421cad9544e9769_L53" href="http://lxr.oss.org.cn/source/include/asm-sh/posix_types.h?v=2.6.16#L53" style="text-decoration:none;border-bottom-width:1px;border-bottom-style:dotted;border-bottom-color:rgb(153,153,153);color:white" target="_blank"><span style="color:rgb(205,92,92)">53</span></a><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,255,255)">{</span><span style="color:rgb(255,255,255)">
 </span><a name="1421cad9544e9769_L54" href="http://lxr.oss.org.cn/source/include/asm-sh/posix_types.h?v=2.6.16#L54" style="text-decoration:none;border-bottom-width:1px;border-bottom-style:dotted;border-bottom-color:rgb(153,153,153);color:white" target="_blank"><span style="color:rgb(205,92,92)">54</span></a><span style="color:rgb(255,255,255)">         </span><span style="color:rgb(240,230,140);font-weight:bold">unsigned</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(240,230,140);font-weight:bold">long</span><span style="color:rgb(255,255,255)"> __tmp </span><span style="color:rgb(255,255,255)">=</span><span style="color:rgb(255,255,255)"> __fd </span><span style="color:rgb(255,255,255)">/</span><span style="color:rgb(255,255,255)"> </span><a href="http://lxr.oss.org.cn/ident?v=2.6.16;i=__NFDBITS" style="text-decoration:none;border-bottom-width:1px;border-bottom-style:dotted;border-bottom-color:rgb(153,153,153);color:white" target="_blank"><span>__NFDBITS</span></a><span style="color:rgb(255,255,255)">;</span><span style="color:rgb(255,255,255)">
 </span><a name="1421cad9544e9769_L55" href="http://lxr.oss.org.cn/source/include/asm-sh/posix_types.h?v=2.6.16#L55" style="text-decoration:none;border-bottom-width:1px;border-bottom-style:dotted;border-bottom-color:rgb(153,153,153);color:white" target="_blank"><span style="color:rgb(205,92,92)">55</span></a><span style="color:rgb(255,255,255)">         </span><span style="color:rgb(240,230,140);font-weight:bold">unsigned</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(240,230,140);font-weight:bold">long</span><span style="color:rgb(255,255,255)"> __rem </span><span style="color:rgb(255,255,255)">=</span><span style="color:rgb(255,255,255)"> __fd </span><span style="color:rgb(255,255,255)">%</span><span style="color:rgb(255,255,255)"> </span><a href="http://lxr.oss.org.cn/ident?v=2.6.16;i=__NFDBITS" style="text-decoration:none;border-bottom-width:1px;border-bottom-style:dotted;border-bottom-color:rgb(153,153,153);color:white" target="_blank"><span>__NFDBITS</span></a><span style="color:rgb(255,255,255)">;</span><span style="color:rgb(255,255,255)">
 </span><a name="1421cad9544e9769_L56" href="http://lxr.oss.org.cn/source/include/asm-sh/posix_types.h?v=2.6.16#L56" style="text-decoration:none;border-bottom-width:1px;border-bottom-style:dotted;border-bottom-color:rgb(153,153,153);color:white" target="_blank"><span style="color:rgb(205,92,92)">56</span></a><span style="color:rgb(255,255,255)">         __fdsetp</span><span style="color:rgb(255,255,255)">-&gt;</span><span style="color:rgb(255,255,255)">fds_bits</span><span style="color:rgb(255,255,255)">[</span><span style="color:rgb(255,255,255)">__tmp</span><span style="color:rgb(255,255,255)">]</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,255,255)">|=</span><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,255,255)">(</span><span style="color:rgb(205,92,92)">1UL</span><span style="color:rgb(255,255,255)">&lt;&lt;</span><span style="color:rgb(255,255,255)">__rem</span><span style="color:rgb(255,255,255)">);</span><span style="color:rgb(255,255,255)">
 </span><a name="1421cad9544e9769_L57" href="http://lxr.oss.org.cn/source/include/asm-sh/posix_types.h?v=2.6.16#L57" style="text-decoration:none;border-bottom-width:1px;border-bottom-style:dotted;border-bottom-color:rgb(153,153,153);color:white" target="_blank"><span style="color:rgb(205,92,92)">57</span></a><span style="color:rgb(255,255,255)"> </span><span style="color:rgb(255,255,255)">}</span></pre>

</div><div><br></div><div>I can&#39;t understand the usage of __rem,How to understand it? thank you.</div></div></blockquote><div><br></div><div>fds_bits is an array of entries which are each __NFDBITS long (in your example, each entry is 32-bits). __tmp gives you the index into the array. __rem is the remainder of the division, and gets  you the bit number within the 32-bit entry.<br>
</div></div><br>-- <br>Dave Hylands<br>Shuswap, BC, Canada<br><a href="http://www.davehylands.com" target="_blank">http://www.davehylands.com</a>
</div></div>