Sophie

Sophie

distrib > CentOS > 6 > i386 > by-pkgid > cf93d8a8acdcc6fe2225039da0502495 > files > 1551

kernel-doc-2.6.32-131.17.1.el6.centos.plus.noarch.rpm

<?xml version="1.0" encoding="ANSI_X3.4-1968" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968" /><title>bitmap_onto</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /><link rel="home" href="index.html" title="The Linux Kernel API" /><link rel="up" href="ch03.html#id2962812" title="Bitmap Operations" /><link rel="prev" href="re111.html" title="bitmap_bitremap" /><link rel="next" href="re113.html" title="bitmap_fold" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center"><span>bitmap_onto</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="re111.html">Prev</a>&#160;</td><th width="60%" align="center">Bitmap Operations</th><td width="20%" align="right">&#160;<a accesskey="n" href="re113.html">Next</a></td></tr></table><hr /></div><div class="refentry" title="bitmap_onto"><a id="API-bitmap-onto"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>bitmap_onto &#8212; 
     translate one bitmap relative to another
 </p></div><div class="refsynopsisdiv" title="Synopsis"><h2>Synopsis</h2><div class="funcsynopsis"><table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table"><tr><td><code class="funcdef">void <b class="fsfunc">bitmap_onto </b>(</code></td><td>unsigned long * <var class="pdparam">dst</var>, </td></tr><tr><td>&#160;</td><td>const unsigned long * <var class="pdparam">orig</var>, </td></tr><tr><td>&#160;</td><td>const unsigned long * <var class="pdparam">relmap</var>, </td></tr><tr><td>&#160;</td><td>int <var class="pdparam">bits</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer">&#160;</div></div></div><div class="refsect1" title="Arguments"><a id="id2964979"></a><h2>Arguments</h2><div class="variablelist"><dl><dt><span class="term"><em class="parameter"><code>dst</code></em></span></dt><dd><p>
     resulting translated bitmap
    </p></dd><dt><span class="term"><em class="parameter"><code>orig</code></em></span></dt><dd><p>
     original untranslated bitmap
    </p></dd><dt><span class="term"><em class="parameter"><code>relmap</code></em></span></dt><dd><p>
     bitmap relative to which translated
    </p></dd><dt><span class="term"><em class="parameter"><code>bits</code></em></span></dt><dd><p>
     number of bits in each of these bitmaps
    </p></dd></dl></div></div><div class="refsect1" title="Description"><a id="id2965058"></a><h2>Description</h2><p>
   Set the n-th bit of <em class="parameter"><code>dst</code></em> iff there exists some m such that the
   n-th bit of <em class="parameter"><code>relmap</code></em> is set, the m-th bit of <em class="parameter"><code>orig</code></em> is set, and
   the n-th bit of <em class="parameter"><code>relmap</code></em> is also the m-th _set_ bit of <em class="parameter"><code>relmap</code></em>.
   (If you understood the previous sentence the first time your
   read it, you're overqualified for your current job.)
   </p><p>

   In other words, <em class="parameter"><code>orig</code></em> is mapped onto (surjectively) <em class="parameter"><code>dst</code></em>,
   using the the map { &lt;n, m&gt; | the n-th bit of <em class="parameter"><code>relmap</code></em> is the
   m-th set bit of <em class="parameter"><code>relmap</code></em> }.
   </p><p>

   Any set bits in <em class="parameter"><code>orig</code></em> above bit number W, where W is the
   weight of (number of set bits in) <em class="parameter"><code>relmap</code></em> are mapped nowhere.
   In particular, if for all bits m set in <em class="parameter"><code>orig</code></em>, m &gt;= W, then
   <em class="parameter"><code>dst</code></em> will end up empty.  In situations where the possibility
   of such an empty result is not desired, one way to avoid it is
   to use the <code class="function">bitmap_fold</code> operator, below, to first fold the
   <em class="parameter"><code>orig</code></em> bitmap over itself so that all its set bits x are in the
   range 0 &lt;= x &lt; W.  The <code class="function">bitmap_fold</code> operator does this by
   setting the bit (m % W) in <em class="parameter"><code>dst</code></em>, for each bit (m) set in <em class="parameter"><code>orig</code></em>.
   </p><p>

   Example [1] for <code class="function">bitmap_onto</code>:
   Let's say <em class="parameter"><code>relmap</code></em> has bits 30-39 set, and <em class="parameter"><code>orig</code></em> has bits
   1, 3, 5, 7, 9 and 11 set.  Then on return from this routine,
   <em class="parameter"><code>dst</code></em> will have bits 31, 33, 35, 37 and 39 set.
   </p><p>

   When bit 0 is set in <em class="parameter"><code>orig</code></em>, it means turn on the bit in
   <em class="parameter"><code>dst</code></em> corresponding to whatever is the first bit (if any)
   that is turned on in <em class="parameter"><code>relmap</code></em>.  Since bit 0 was off in the
   above example, we leave off that bit (bit 30) in <em class="parameter"><code>dst</code></em>.
   </p><p>

   When bit 1 is set in <em class="parameter"><code>orig</code></em> (as in the above example), it
   means turn on the bit in <em class="parameter"><code>dst</code></em> corresponding to whatever
   is the second bit that is turned on in <em class="parameter"><code>relmap</code></em>.  The second
   bit in <em class="parameter"><code>relmap</code></em> that was turned on in the above example was
   bit 31, so we turned on bit 31 in <em class="parameter"><code>dst</code></em>.
   </p><p>

   Similarly, we turned on bits 33, 35, 37 and 39 in <em class="parameter"><code>dst</code></em>,
   because they were the 4th, 6th, 8th and 10th set bits
   set in <em class="parameter"><code>relmap</code></em>, and the 4th, 6th, 8th and 10th bits of
   <em class="parameter"><code>orig</code></em> (i.e. bits 3, 5, 7 and 9) were also set.
   </p><p>

   When bit 11 is set in <em class="parameter"><code>orig</code></em>, it means turn on the bit in
   <em class="parameter"><code>dst</code></em> corresponding to whatever is the twelth bit that is
   turned on in <em class="parameter"><code>relmap</code></em>.  In the above example, there were
   only ten bits turned on in <em class="parameter"><code>relmap</code></em> (30..39), so that bit
   11 was set in <em class="parameter"><code>orig</code></em> had no affect on <em class="parameter"><code>dst</code></em>.
   </p><p>

   Example [2] for <code class="function">bitmap_fold</code> + <code class="function">bitmap_onto</code>:
   Let's say <em class="parameter"><code>relmap</code></em> has these ten bits set:
   40 41 42 43 45 48 53 61 74 95
   (for the curious, that's 40 plus the first ten terms of the
   Fibonacci sequence.)
   </p><p>

   Further lets say we use the following code, invoking
   <code class="function">bitmap_fold</code> then bitmap_onto, as suggested above to
   avoid the possitility of an empty <em class="parameter"><code>dst</code></em> result:
   </p><p>

   unsigned long *tmp;	// a temporary bitmap's bits
   </p><p>

   bitmap_fold(tmp, orig, bitmap_weight(relmap, bits), bits);
   bitmap_onto(dst, tmp, relmap, bits);
   </p><p>

   Then this table shows what various values of <em class="parameter"><code>dst</code></em> would be, for
   various <em class="parameter"><code>orig</code></em>'s.  I list the zero-based positions of each set bit.
   The tmp column shows the intermediate result, as computed by
   using <code class="function">bitmap_fold</code> to fold the <em class="parameter"><code>orig</code></em> bitmap modulo ten
   (the weight of <em class="parameter"><code>relmap</code></em>).
   </p><p>

   <em class="parameter"><code>orig</code></em>           tmp            <em class="parameter"><code>dst</code></em>
   0                0             40
   1                1             41
   9                9             95
   10               0             40 (*)
   1 3 5 7          1 3 5 7       41 43 48 61
   0 1 2 3 4        0 1 2 3 4     40 41 42 43 45
   0 9 18 27        0 9 8 7       40 61 74 95
   0 10 20 30       0             40
   0 11 22 33       0 1 2 3       40 41 42 43
   0 12 24 36       0 2 4 6       40 42 45 53
   78 102 211       1 2 8         41 42 74 (*)
   </p><p>

   (*) For these marked lines, if we hadn't first done <code class="function">bitmap_fold</code>
   into tmp, then the <em class="parameter"><code>dst</code></em> result would have been empty.
   </p><p>

   If either of <em class="parameter"><code>orig</code></em> or <em class="parameter"><code>relmap</code></em> is empty (no set bits), then <em class="parameter"><code>dst</code></em>
   will be returned empty.
   </p><p>

   If (as explained above) the only set bits in <em class="parameter"><code>orig</code></em> are in positions
   m where m &gt;= W, (where W is the weight of <em class="parameter"><code>relmap</code></em>) then <em class="parameter"><code>dst</code></em> will
   once again be returned empty.
   </p><p>

   All bits in <em class="parameter"><code>dst</code></em> not set by the above rule are cleared.
</p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="re111.html">Prev</a>&#160;</td><td width="20%" align="center"><a accesskey="u" href="ch03.html#id2962812">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="re113.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span>bitmap_bitremap</span>&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;<span>bitmap_fold</span></td></tr></table></div></body></html>