1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>bitmap_remap</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="The Linux Kernel API"><link rel="up" href="kernel-lib.html#idp1123213284" title="Bitmap Operations"><link rel="prev" href="API-bitmap-parselist-user.html" title="bitmap_parselist_user"><link rel="next" href="API-bitmap-bitremap.html" title="bitmap_bitremap"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center"><span class="phrase">bitmap_remap</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="API-bitmap-parselist-user.html">Prev</a> </td><th width="60%" align="center">Bitmap Operations</th><td width="20%" align="right"> <a accesskey="n" href="API-bitmap-bitremap.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="API-bitmap-remap"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>bitmap_remap — 2 Apply map defined by a pair of bitmaps to another bitmap 3 </p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="funcsynopsis"><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">void <b class="fsfunc">bitmap_remap </b>(</code></td><td>unsigned long * <var class="pdparam">dst</var>, </td></tr><tr><td> </td><td>const unsigned long * <var class="pdparam">src</var>, </td></tr><tr><td> </td><td>const unsigned long * <var class="pdparam">old</var>, </td></tr><tr><td> </td><td>const unsigned long * <var class="pdparam">new</var>, </td></tr><tr><td> </td><td>unsigned int <var class="pdparam">nbits</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1"><a name="idp1123309628"></a><h2>Arguments</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="parameter"><code>dst</code></em></span></dt><dd><p> 4 remapped result 5 </p></dd><dt><span class="term"><em class="parameter"><code>src</code></em></span></dt><dd><p> 6 subset to be remapped 7 </p></dd><dt><span class="term"><em class="parameter"><code>old</code></em></span></dt><dd><p> 8 defines domain of map 9 </p></dd><dt><span class="term"><em class="parameter"><code>new</code></em></span></dt><dd><p> 10 defines range of map 11 </p></dd><dt><span class="term"><em class="parameter"><code>nbits</code></em></span></dt><dd><p> 12 number of bits in each of these bitmaps 13 </p></dd></dl></div></div><div class="refsect1"><a name="idp1123315284"></a><h2>Description</h2><p> 14 Let <em class="parameter"><code>old</code></em> and <em class="parameter"><code>new</code></em> define a mapping of bit positions, such that 15 whatever position is held by the n-th set bit in <em class="parameter"><code>old</code></em> is mapped 16 to the n-th set bit in <em class="parameter"><code>new</code></em>. In the more general case, allowing 17 for the possibility that the weight 'w' of <em class="parameter"><code>new</code></em> is less than the 18 weight of <em class="parameter"><code>old</code></em>, map the position of the n-th set bit in <em class="parameter"><code>old</code></em> to 19 the position of the m-th set bit in <em class="parameter"><code>new</code></em>, where m == n % w. 20 </p><p> 21 22 If either of the <em class="parameter"><code>old</code></em> and <em class="parameter"><code>new</code></em> bitmaps are empty, or if <em class="parameter"><code>src</code></em> and 23 <em class="parameter"><code>dst</code></em> point to the same location, then this routine copies <em class="parameter"><code>src</code></em> 24 to <em class="parameter"><code>dst</code></em>. 25 </p><p> 26 27 The positions of unset bits in <em class="parameter"><code>old</code></em> are mapped to themselves 28 (the identify map). 29 </p><p> 30 31 Apply the above specified mapping to <em class="parameter"><code>src</code></em>, placing the result in 32 <em class="parameter"><code>dst</code></em>, clearing any bits previously set in <em class="parameter"><code>dst</code></em>. 33 </p><p> 34 35 For example, lets say that <em class="parameter"><code>old</code></em> has bits 4 through 7 set, and 36 <em class="parameter"><code>new</code></em> has bits 12 through 15 set. This defines the mapping of bit 37 position 4 to 12, 5 to 13, 6 to 14 and 7 to 15, and of all other 38 bit positions unchanged. So if say <em class="parameter"><code>src</code></em> comes into this routine 39 with bits 1, 5 and 7 set, then <em class="parameter"><code>dst</code></em> should leave with bits 1, 40 13 and 15 set. 41</p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="API-bitmap-parselist-user.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="kernel-lib.html#idp1123213284">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="API-bitmap-bitremap.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="phrase">bitmap_parselist_user</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> <span class="phrase">bitmap_bitremap</span></td></tr></table></div></body></html> 42