<?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>__test_and_clear_bit</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="ch02s03.html" title="Bit Operations" /><link rel="prev" href="API-test-and-clear-bit.html" title="test_and_clear_bit" /><link rel="next" href="API-test-and-change-bit.html" title="test_and_change_bit" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center"><span class="phrase">__test_and_clear_bit</span></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="API-test-and-clear-bit.html">Prev</a> </td><th width="60%" align="center">Bit Operations</th><td width="20%" align="right"> <a accesskey="n" href="API-test-and-change-bit.html">Next</a></td></tr></table><hr /></div><div class="refentry"><a id="API---test-and-clear-bit"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>__test_and_clear_bit — Clear a bit and return its old value </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">int <strong class="fsfunc">__test_and_clear_bit </strong>(</code></td><td>int <var class="pdparam">nr</var>, </td></tr><tr><td> </td><td>volatile unsigned long * <var class="pdparam">addr</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1"><a id="idm139749901684816"></a><h2>Arguments</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><em class="parameter"><code>nr</code></em></span></dt><dd><p> Bit to clear </p></dd><dt><span class="term"><em class="parameter"><code>addr</code></em></span></dt><dd><p> Address to count from </p></dd></dl></div></div><div class="refsect1"><a id="idm139749901679856"></a><h2>Description</h2><p> This operation is non-atomic and can be reordered. If two examples of this operation race, one can appear to succeed but actually fail. You must protect multiple accesses with a lock. </p></div><div class="refsect1"><a id="idm139749901678496"></a><h2>Note</h2><p> the operation is performed atomically with respect to the local CPU, but not other CPUs. Portable code should not rely on this behaviour. KVM relies on this behaviour on x86 for modifying memory that is also </p></div><div class="refsect1"><a id="idm139749901677104"></a><h2>accessed from a hypervisor on the same CPU if running in a VM</h2><p> don't change this without also updating arch/x86/kernel/kvm.c </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="API-test-and-clear-bit.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ch02s03.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="API-test-and-change-bit.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="phrase">test_and_clear_bit</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">test_and_change_bit</span></td></tr></table></div></body></html>