Home | History | Annotate | Download | only in reference
      1 page.title=RenderScript Atomic Update Functions
      2 
      3 @jd:body
      4 
      5 <div class='renderscript'>
      6 <h2>Overview</h2>
      7 <p> To update values shared between multiple threads, use the functions below.
      8 They ensure that the values are atomically updated, i.e. that the memory
      9 reads, the updates, and the memory writes are done in the right order.
     10 </p>
     11 
     12 <p> These functions are slower than their non-atomic equivalents, so use
     13 them only when synchronization is needed.
     14 </p>
     15 
     16 <p> Note that in RenderScript, your code is likely to be running in separate
     17 threads even though you did not explicitely create them.  The RenderScript
     18 runtime will very often split the execution of one kernel across multiple
     19 threads.  Updating globals should be done with atomic functions.  If possible,
     20 modify your algorithm to avoid them altogether.
     21 </p>
     22 <h2>Summary</h2>
     23 <table class='jd-sumtable'><tbody>
     24   <tr><th colspan='2'>Functions</th></tr>
     25   <tr class='alt-color api apilevel-1'>
     26     <td class='jd-linkcol'>
     27       <a href='rs_atomic.html#android_rs:rsAtomicAdd'>rsAtomicAdd</a>
     28     </td>
     29     <td class='jd-descrcol' width='100%'>
     30       Thread-safe addition
     31     </td>
     32   </tr>
     33   <tr class='alt-color api apilevel-1'>
     34     <td class='jd-linkcol'>
     35       <a href='rs_atomic.html#android_rs:rsAtomicAnd'>rsAtomicAnd</a>
     36     </td>
     37     <td class='jd-descrcol' width='100%'>
     38       Thread-safe bitwise and
     39     </td>
     40   </tr>
     41   <tr class='alt-color api apilevel-1'>
     42     <td class='jd-linkcol'>
     43       <a href='rs_atomic.html#android_rs:rsAtomicCas'>rsAtomicCas</a>
     44     </td>
     45     <td class='jd-descrcol' width='100%'>
     46       Thread-safe compare and set
     47     </td>
     48   </tr>
     49   <tr class='alt-color api apilevel-1'>
     50     <td class='jd-linkcol'>
     51       <a href='rs_atomic.html#android_rs:rsAtomicDec'>rsAtomicDec</a>
     52     </td>
     53     <td class='jd-descrcol' width='100%'>
     54       Thread-safe decrement
     55     </td>
     56   </tr>
     57   <tr class='alt-color api apilevel-1'>
     58     <td class='jd-linkcol'>
     59       <a href='rs_atomic.html#android_rs:rsAtomicInc'>rsAtomicInc</a>
     60     </td>
     61     <td class='jd-descrcol' width='100%'>
     62       Thread-safe increment
     63     </td>
     64   </tr>
     65   <tr class='alt-color api apilevel-1'>
     66     <td class='jd-linkcol'>
     67       <a href='rs_atomic.html#android_rs:rsAtomicMax'>rsAtomicMax</a>
     68     </td>
     69     <td class='jd-descrcol' width='100%'>
     70       Thread-safe maximum
     71     </td>
     72   </tr>
     73   <tr class='alt-color api apilevel-1'>
     74     <td class='jd-linkcol'>
     75       <a href='rs_atomic.html#android_rs:rsAtomicMin'>rsAtomicMin</a>
     76     </td>
     77     <td class='jd-descrcol' width='100%'>
     78       Thread-safe minimum
     79     </td>
     80   </tr>
     81   <tr class='alt-color api apilevel-1'>
     82     <td class='jd-linkcol'>
     83       <a href='rs_atomic.html#android_rs:rsAtomicOr'>rsAtomicOr</a>
     84     </td>
     85     <td class='jd-descrcol' width='100%'>
     86       Thread-safe bitwise or
     87     </td>
     88   </tr>
     89   <tr class='alt-color api apilevel-1'>
     90     <td class='jd-linkcol'>
     91       <a href='rs_atomic.html#android_rs:rsAtomicSub'>rsAtomicSub</a>
     92     </td>
     93     <td class='jd-descrcol' width='100%'>
     94       Thread-safe subtraction
     95     </td>
     96   </tr>
     97   <tr class='alt-color api apilevel-1'>
     98     <td class='jd-linkcol'>
     99       <a href='rs_atomic.html#android_rs:rsAtomicXor'>rsAtomicXor</a>
    100     </td>
    101     <td class='jd-descrcol' width='100%'>
    102       Thread-safe bitwise exclusive or
    103     </td>
    104   </tr>
    105 </tbody></table>
    106 <h2>Functions</h2>
    107 <a name='android_rs:rsAtomicAdd'></a>
    108 <div class='jd-details'>
    109   <h4 class='jd-details-title'>
    110     <span class='sympad'>rsAtomicAdd</span>
    111     <span class='normal'>: Thread-safe addition</span>
    112   </h4>
    113   <div class='jd-details-descr'>
    114     <table class='jd-tagtable'><tbody>
    115       <tr>
    116         <td><a href='rs_value_types.html#android_rs:int32_t'>int32_t</a> rsAtomicAdd(volatile <a href='rs_value_types.html#android_rs:int32_t'>int32_t</a>* addr, <a href='rs_value_types.html#android_rs:int32_t'>int32_t</a> value);
    117 </td>
    118         <td>    Added in <a href='http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels'>API level 14</a>
    119         </td>
    120       </tr>
    121       <tr>
    122         <td><a href='rs_value_types.html#android_rs:int32_t'>int32_t</a> rsAtomicAdd(volatile <a href='rs_value_types.html#android_rs:uint32_t'>uint32_t</a>* addr, <a href='rs_value_types.html#android_rs:uint32_t'>uint32_t</a> value);
    123 </td>
    124         <td>    Added in <a href='http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels'>API level 20</a>
    125         </td>
    126       </tr>
    127     </tbody></table>
    128   </div>
    129   <div class='jd-tagdata'>    <h5 class='jd-tagtitle'>Parameters</h5>
    130     <table class='jd-tagtable'><tbody>
    131     <tr><th>addr</th><td>Address of the value to modify.</td></tr>
    132     <tr><th>value</th><td>Amount to add.</td></tr>
    133     </tbody></table>
    134   </div>
    135   <div class='jd-tagdata'>    <h5 class='jd-tagtitle'>Returns</h5>
    136     <table class='jd-tagtable'><tbody>
    137     <tr><td>Value of *addr prior to the operation.</td></tr>
    138     </tbody></table>
    139   </div>
    140   <div class='jd-tagdata jd-tagdescr'>
    141 <p> Atomicly adds a value to the value at addr, i.e. <code>*addr += value</code>.
    142 </p>
    143   </div>
    144 </div>
    145 
    146 <a name='android_rs:rsAtomicAnd'></a>
    147 <div class='jd-details'>
    148   <h4 class='jd-details-title'>
    149     <span class='sympad'>rsAtomicAnd</span>
    150     <span class='normal'>: Thread-safe bitwise and</span>
    151   </h4>
    152   <div class='jd-details-descr'>
    153     <table class='jd-tagtable'><tbody>
    154       <tr>
    155         <td><a href='rs_value_types.html#android_rs:int32_t'>int32_t</a> rsAtomicAnd(volatile <a href='rs_value_types.html#android_rs:int32_t'>int32_t</a>* addr, <a href='rs_value_types.html#android_rs:int32_t'>int32_t</a> value);
    156 </td>
    157         <td>    Added in <a href='http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels'>API level 14</a>
    158         </td>
    159       </tr>
    160       <tr>
    161         <td><a href='rs_value_types.html#android_rs:int32_t'>int32_t</a> rsAtomicAnd(volatile <a href='rs_value_types.html#android_rs:uint32_t'>uint32_t</a>* addr, <a href='rs_value_types.html#android_rs:uint32_t'>uint32_t</a> value);
    162 </td>
    163         <td>    Added in <a href='http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels'>API level 20</a>
    164         </td>
    165       </tr>
    166     </tbody></table>
    167   </div>
    168   <div class='jd-tagdata'>    <h5 class='jd-tagtitle'>Parameters</h5>
    169     <table class='jd-tagtable'><tbody>
    170     <tr><th>addr</th><td>Address of the value to modify.</td></tr>
    171     <tr><th>value</th><td>Value to and with.</td></tr>
    172     </tbody></table>
    173   </div>
    174   <div class='jd-tagdata'>    <h5 class='jd-tagtitle'>Returns</h5>
    175     <table class='jd-tagtable'><tbody>
    176     <tr><td>Value of *addr prior to the operation.</td></tr>
    177     </tbody></table>
    178   </div>
    179   <div class='jd-tagdata jd-tagdescr'>
    180 <p> Atomicly performs a bitwise and of two values, storing the result back at addr,
    181 i.e. <code>*addr &amp;= value</code>.
    182 </p>
    183   </div>
    184 </div>
    185 
    186 <a name='android_rs:rsAtomicCas'></a>
    187 <div class='jd-details'>
    188   <h4 class='jd-details-title'>
    189     <span class='sympad'>rsAtomicCas</span>
    190     <span class='normal'>: Thread-safe compare and set</span>
    191   </h4>
    192   <div class='jd-details-descr'>
    193     <table class='jd-tagtable'><tbody>
    194       <tr>
    195         <td><a href='rs_value_types.html#android_rs:int32_t'>int32_t</a> rsAtomicCas(volatile <a href='rs_value_types.html#android_rs:int32_t'>int32_t</a>* addr, <a href='rs_value_types.html#android_rs:int32_t'>int32_t</a> compareValue, <a href='rs_value_types.html#android_rs:int32_t'>int32_t</a> newValue);
    196 </td>
    197         <td>    Added in <a href='http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels'>API level 14</a>
    198         </td>
    199       </tr>
    200       <tr>
    201         <td><a href='rs_value_types.html#android_rs:uint32_t'>uint32_t</a> rsAtomicCas(volatile <a href='rs_value_types.html#android_rs:uint32_t'>uint32_t</a>* addr, <a href='rs_value_types.html#android_rs:uint32_t'>uint32_t</a> compareValue, <a href='rs_value_types.html#android_rs:uint32_t'>uint32_t</a> newValue);
    202 </td>
    203         <td>    Added in <a href='http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels'>API level 14</a>
    204         </td>
    205       </tr>
    206     </tbody></table>
    207   </div>
    208   <div class='jd-tagdata'>    <h5 class='jd-tagtitle'>Parameters</h5>
    209     <table class='jd-tagtable'><tbody>
    210     <tr><th>addr</th><td>Address of the value to compare and replace if the test passes.</td></tr>
    211     <tr><th>compareValue</th><td>Value to test *addr against.</td></tr>
    212     <tr><th>newValue</th><td>Value to write if the test passes.</td></tr>
    213     </tbody></table>
    214   </div>
    215   <div class='jd-tagdata'>    <h5 class='jd-tagtitle'>Returns</h5>
    216     <table class='jd-tagtable'><tbody>
    217     <tr><td>Value of *addr prior to the operation.</td></tr>
    218     </tbody></table>
    219   </div>
    220   <div class='jd-tagdata jd-tagdescr'>
    221 <p> If the value at addr matches compareValue then the newValue is written at addr,
    222 i.e. <code>if (*addr == compareValue) { *addr = newValue; }</code>.
    223 </p>
    224 
    225 <p> You can check that the value was written by checking that the value returned
    226 by rsAtomicCas() is compareValue.
    227 </p>
    228   </div>
    229 </div>
    230 
    231 <a name='android_rs:rsAtomicDec'></a>
    232 <div class='jd-details'>
    233   <h4 class='jd-details-title'>
    234     <span class='sympad'>rsAtomicDec</span>
    235     <span class='normal'>: Thread-safe decrement</span>
    236   </h4>
    237   <div class='jd-details-descr'>
    238     <table class='jd-tagtable'><tbody>
    239       <tr>
    240         <td><a href='rs_value_types.html#android_rs:int32_t'>int32_t</a> rsAtomicDec(volatile <a href='rs_value_types.html#android_rs:int32_t'>int32_t</a>* addr);
    241 </td>
    242         <td>    Added in <a href='http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels'>API level 14</a>
    243         </td>
    244       </tr>
    245       <tr>
    246         <td><a href='rs_value_types.html#android_rs:int32_t'>int32_t</a> rsAtomicDec(volatile <a href='rs_value_types.html#android_rs:uint32_t'>uint32_t</a>* addr);
    247 </td>
    248         <td>    Added in <a href='http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels'>API level 20</a>
    249         </td>
    250       </tr>
    251     </tbody></table>
    252   </div>
    253   <div class='jd-tagdata'>    <h5 class='jd-tagtitle'>Parameters</h5>
    254     <table class='jd-tagtable'><tbody>
    255     <tr><th>addr</th><td>Address of the value to decrement.</td></tr>
    256     </tbody></table>
    257   </div>
    258   <div class='jd-tagdata'>    <h5 class='jd-tagtitle'>Returns</h5>
    259     <table class='jd-tagtable'><tbody>
    260     <tr><td>Value of *addr prior to the operation.</td></tr>
    261     </tbody></table>
    262   </div>
    263   <div class='jd-tagdata jd-tagdescr'>
    264 <p> Atomicly subtracts one from the value at addr.  This is equivalent to <code><a href='rs_atomic.html#android_rs:rsAtomicSub'>rsAtomicSub</a>(addr, 1)</code>.
    265 </p>
    266   </div>
    267 </div>
    268 
    269 <a name='android_rs:rsAtomicInc'></a>
    270 <div class='jd-details'>
    271   <h4 class='jd-details-title'>
    272     <span class='sympad'>rsAtomicInc</span>
    273     <span class='normal'>: Thread-safe increment</span>
    274   </h4>
    275   <div class='jd-details-descr'>
    276     <table class='jd-tagtable'><tbody>
    277       <tr>
    278         <td><a href='rs_value_types.html#android_rs:int32_t'>int32_t</a> rsAtomicInc(volatile <a href='rs_value_types.html#android_rs:int32_t'>int32_t</a>* addr);
    279 </td>
    280         <td>    Added in <a href='http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels'>API level 14</a>
    281         </td>
    282       </tr>
    283       <tr>
    284         <td><a href='rs_value_types.html#android_rs:int32_t'>int32_t</a> rsAtomicInc(volatile <a href='rs_value_types.html#android_rs:uint32_t'>uint32_t</a>* addr);
    285 </td>
    286         <td>    Added in <a href='http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels'>API level 20</a>
    287         </td>
    288       </tr>
    289     </tbody></table>
    290   </div>
    291   <div class='jd-tagdata'>    <h5 class='jd-tagtitle'>Parameters</h5>
    292     <table class='jd-tagtable'><tbody>
    293     <tr><th>addr</th><td>Address of the value to increment.</td></tr>
    294     </tbody></table>
    295   </div>
    296   <div class='jd-tagdata'>    <h5 class='jd-tagtitle'>Returns</h5>
    297     <table class='jd-tagtable'><tbody>
    298     <tr><td>Value of *addr prior to the operation.</td></tr>
    299     </tbody></table>
    300   </div>
    301   <div class='jd-tagdata jd-tagdescr'>
    302 <p> Atomicly adds one to the value at addr.  This is equivalent to <code><a href='rs_atomic.html#android_rs:rsAtomicAdd'>rsAtomicAdd</a>(addr, 1)</code>.
    303 </p>
    304   </div>
    305 </div>
    306 
    307 <a name='android_rs:rsAtomicMax'></a>
    308 <div class='jd-details'>
    309   <h4 class='jd-details-title'>
    310     <span class='sympad'>rsAtomicMax</span>
    311     <span class='normal'>: Thread-safe maximum</span>
    312   </h4>
    313   <div class='jd-details-descr'>
    314     <table class='jd-tagtable'><tbody>
    315       <tr>
    316         <td><a href='rs_value_types.html#android_rs:int32_t'>int32_t</a> rsAtomicMax(volatile <a href='rs_value_types.html#android_rs:int32_t'>int32_t</a>* addr, <a href='rs_value_types.html#android_rs:int32_t'>int32_t</a> value);
    317 </td>
    318         <td>    Added in <a href='http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels'>API level 14</a>
    319         </td>
    320       </tr>
    321       <tr>
    322         <td><a href='rs_value_types.html#android_rs:uint32_t'>uint32_t</a> rsAtomicMax(volatile <a href='rs_value_types.html#android_rs:uint32_t'>uint32_t</a>* addr, <a href='rs_value_types.html#android_rs:uint32_t'>uint32_t</a> value);
    323 </td>
    324         <td>    Added in <a href='http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels'>API level 14</a>
    325         </td>
    326       </tr>
    327     </tbody></table>
    328   </div>
    329   <div class='jd-tagdata'>    <h5 class='jd-tagtitle'>Parameters</h5>
    330     <table class='jd-tagtable'><tbody>
    331     <tr><th>addr</th><td>Address of the value to modify.</td></tr>
    332     <tr><th>value</th><td>Comparison value.</td></tr>
    333     </tbody></table>
    334   </div>
    335   <div class='jd-tagdata'>    <h5 class='jd-tagtitle'>Returns</h5>
    336     <table class='jd-tagtable'><tbody>
    337     <tr><td>Value of *addr prior to the operation.</td></tr>
    338     </tbody></table>
    339   </div>
    340   <div class='jd-tagdata jd-tagdescr'>
    341 <p> Atomicly sets the value at addr to the maximum of *addr and value, i.e.
    342 <code>*addr = max(*addr, value)</code>.
    343 </p>
    344   </div>
    345 </div>
    346 
    347 <a name='android_rs:rsAtomicMin'></a>
    348 <div class='jd-details'>
    349   <h4 class='jd-details-title'>
    350     <span class='sympad'>rsAtomicMin</span>
    351     <span class='normal'>: Thread-safe minimum</span>
    352   </h4>
    353   <div class='jd-details-descr'>
    354     <table class='jd-tagtable'><tbody>
    355       <tr>
    356         <td><a href='rs_value_types.html#android_rs:int32_t'>int32_t</a> rsAtomicMin(volatile <a href='rs_value_types.html#android_rs:int32_t'>int32_t</a>* addr, <a href='rs_value_types.html#android_rs:int32_t'>int32_t</a> value);
    357 </td>
    358         <td>    Added in <a href='http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels'>API level 14</a>
    359         </td>
    360       </tr>
    361       <tr>
    362         <td><a href='rs_value_types.html#android_rs:uint32_t'>uint32_t</a> rsAtomicMin(volatile <a href='rs_value_types.html#android_rs:uint32_t'>uint32_t</a>* addr, <a href='rs_value_types.html#android_rs:uint32_t'>uint32_t</a> value);
    363 </td>
    364         <td>    Added in <a href='http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels'>API level 14</a>
    365         </td>
    366       </tr>
    367     </tbody></table>
    368   </div>
    369   <div class='jd-tagdata'>    <h5 class='jd-tagtitle'>Parameters</h5>
    370     <table class='jd-tagtable'><tbody>
    371     <tr><th>addr</th><td>Address of the value to modify.</td></tr>
    372     <tr><th>value</th><td>Comparison value.</td></tr>
    373     </tbody></table>
    374   </div>
    375   <div class='jd-tagdata'>    <h5 class='jd-tagtitle'>Returns</h5>
    376     <table class='jd-tagtable'><tbody>
    377     <tr><td>Value of *addr prior to the operation.</td></tr>
    378     </tbody></table>
    379   </div>
    380   <div class='jd-tagdata jd-tagdescr'>
    381 <p> Atomicly sets the value at addr to the minimum of *addr and value, i.e.
    382 <code>*addr = min(*addr, value)</code>.
    383 </p>
    384   </div>
    385 </div>
    386 
    387 <a name='android_rs:rsAtomicOr'></a>
    388 <div class='jd-details'>
    389   <h4 class='jd-details-title'>
    390     <span class='sympad'>rsAtomicOr</span>
    391     <span class='normal'>: Thread-safe bitwise or</span>
    392   </h4>
    393   <div class='jd-details-descr'>
    394     <table class='jd-tagtable'><tbody>
    395       <tr>
    396         <td><a href='rs_value_types.html#android_rs:int32_t'>int32_t</a> rsAtomicOr(volatile <a href='rs_value_types.html#android_rs:int32_t'>int32_t</a>* addr, <a href='rs_value_types.html#android_rs:int32_t'>int32_t</a> value);
    397 </td>
    398         <td>    Added in <a href='http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels'>API level 14</a>
    399         </td>
    400       </tr>
    401       <tr>
    402         <td><a href='rs_value_types.html#android_rs:int32_t'>int32_t</a> rsAtomicOr(volatile <a href='rs_value_types.html#android_rs:uint32_t'>uint32_t</a>* addr, <a href='rs_value_types.html#android_rs:uint32_t'>uint32_t</a> value);
    403 </td>
    404         <td>    Added in <a href='http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels'>API level 20</a>
    405         </td>
    406       </tr>
    407     </tbody></table>
    408   </div>
    409   <div class='jd-tagdata'>    <h5 class='jd-tagtitle'>Parameters</h5>
    410     <table class='jd-tagtable'><tbody>
    411     <tr><th>addr</th><td>Address of the value to modify.</td></tr>
    412     <tr><th>value</th><td>Value to or with.</td></tr>
    413     </tbody></table>
    414   </div>
    415   <div class='jd-tagdata'>    <h5 class='jd-tagtitle'>Returns</h5>
    416     <table class='jd-tagtable'><tbody>
    417     <tr><td>Value of *addr prior to the operation.</td></tr>
    418     </tbody></table>
    419   </div>
    420   <div class='jd-tagdata jd-tagdescr'>
    421 <p> Atomicly perform a bitwise or two values, storing the result at addr,
    422 i.e. <code>*addr |= value</code>.
    423 </p>
    424   </div>
    425 </div>
    426 
    427 <a name='android_rs:rsAtomicSub'></a>
    428 <div class='jd-details'>
    429   <h4 class='jd-details-title'>
    430     <span class='sympad'>rsAtomicSub</span>
    431     <span class='normal'>: Thread-safe subtraction</span>
    432   </h4>
    433   <div class='jd-details-descr'>
    434     <table class='jd-tagtable'><tbody>
    435       <tr>
    436         <td><a href='rs_value_types.html#android_rs:int32_t'>int32_t</a> rsAtomicSub(volatile <a href='rs_value_types.html#android_rs:int32_t'>int32_t</a>* addr, <a href='rs_value_types.html#android_rs:int32_t'>int32_t</a> value);
    437 </td>
    438         <td>    Added in <a href='http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels'>API level 14</a>
    439         </td>
    440       </tr>
    441       <tr>
    442         <td><a href='rs_value_types.html#android_rs:int32_t'>int32_t</a> rsAtomicSub(volatile <a href='rs_value_types.html#android_rs:uint32_t'>uint32_t</a>* addr, <a href='rs_value_types.html#android_rs:uint32_t'>uint32_t</a> value);
    443 </td>
    444         <td>    Added in <a href='http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels'>API level 20</a>
    445         </td>
    446       </tr>
    447     </tbody></table>
    448   </div>
    449   <div class='jd-tagdata'>    <h5 class='jd-tagtitle'>Parameters</h5>
    450     <table class='jd-tagtable'><tbody>
    451     <tr><th>addr</th><td>Address of the value to modify.</td></tr>
    452     <tr><th>value</th><td>Amount to subtract.</td></tr>
    453     </tbody></table>
    454   </div>
    455   <div class='jd-tagdata'>    <h5 class='jd-tagtitle'>Returns</h5>
    456     <table class='jd-tagtable'><tbody>
    457     <tr><td>Value of *addr prior to the operation.</td></tr>
    458     </tbody></table>
    459   </div>
    460   <div class='jd-tagdata jd-tagdescr'>
    461 <p> Atomicly subtracts a value from the value at addr, i.e. <code>*addr -= value</code>.
    462 </p>
    463   </div>
    464 </div>
    465 
    466 <a name='android_rs:rsAtomicXor'></a>
    467 <div class='jd-details'>
    468   <h4 class='jd-details-title'>
    469     <span class='sympad'>rsAtomicXor</span>
    470     <span class='normal'>: Thread-safe bitwise exclusive or</span>
    471   </h4>
    472   <div class='jd-details-descr'>
    473     <table class='jd-tagtable'><tbody>
    474       <tr>
    475         <td><a href='rs_value_types.html#android_rs:int32_t'>int32_t</a> rsAtomicXor(volatile <a href='rs_value_types.html#android_rs:int32_t'>int32_t</a>* addr, <a href='rs_value_types.html#android_rs:int32_t'>int32_t</a> value);
    476 </td>
    477         <td>    Added in <a href='http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels'>API level 14</a>
    478         </td>
    479       </tr>
    480       <tr>
    481         <td><a href='rs_value_types.html#android_rs:int32_t'>int32_t</a> rsAtomicXor(volatile <a href='rs_value_types.html#android_rs:uint32_t'>uint32_t</a>* addr, <a href='rs_value_types.html#android_rs:uint32_t'>uint32_t</a> value);
    482 </td>
    483         <td>    Added in <a href='http://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels'>API level 20</a>
    484         </td>
    485       </tr>
    486     </tbody></table>
    487   </div>
    488   <div class='jd-tagdata'>    <h5 class='jd-tagtitle'>Parameters</h5>
    489     <table class='jd-tagtable'><tbody>
    490     <tr><th>addr</th><td>Address of the value to modify.</td></tr>
    491     <tr><th>value</th><td>Value to xor with.</td></tr>
    492     </tbody></table>
    493   </div>
    494   <div class='jd-tagdata'>    <h5 class='jd-tagtitle'>Returns</h5>
    495     <table class='jd-tagtable'><tbody>
    496     <tr><td>Value of *addr prior to the operation.</td></tr>
    497     </tbody></table>
    498   </div>
    499   <div class='jd-tagdata jd-tagdescr'>
    500 <p> Atomicly performs a bitwise xor of two values, storing the result at addr,
    501 i.e. <code>*addr ^= value</code>.
    502 </p>
    503   </div>
    504 </div>
    505 
    506 </div>
    507