linux/lib/dec_and_lock.c
<<
a img src="v2..static/gfx/right.png" alt=">>">a href=a hre class="lxr_search">a ="+search" method="post" onsubmit="return do_search(this);">a input typptihidden" namptinavtarget" 1a input typptitext" namptisearch" idtisearch">a butt6.1typptisubmit">Searcha Plues="../la>a href=ion v./ldivf=ion v./i7ux acan> ="ajax+*" method="post" onsubmit="return false;">a input typptihidden" namptiajax_lookup" idtiajax_lookup" 1aion v./li7ux+vaion v./div class="headingbott6m">= /div idtifile_contents"+ v.1/la>#include <<6.16./export.h/la>> < v.2/la>#include <<6.16./spinlock.h/la>> < v.3/la>#include <<6.16./at6mic.h/la>> < v.4/la>a< v.5/la> hre class="comment">/* href=< v.6/la> hre class="comment"> * This is re implementa2.6.1of the no2.6.1of "decrement a href=< v.7/la> hre class="comment"> * lueerencu count, red return locked if it decremented to zero". href=< v.8/la> hre class="comment"> * href=< v.9/la> hre class="comment"> * NOTE NOTE NOTE! This is _no2_ equi1 ve="va> hre class="comment"> * href=< v11/la> hre class="comment"> * if (at6mic_dec_and_test(&at6mic)) { href=< v12/la> hre class="comment"> * spin_lock(&lock); href=< v13/la> hre class="comment"> * return 1; href=< v14/la> hre class="comment"> * } href=< v15/la> hre class="comment"> * return 0; href=< v16/la> hre class="comment"> * href=< v17/la> hre class="comment"> * because the spin-lock red the decrement must be href=< v18/la> hre class="comment"> * "at6mic". href=< v19/la> hre class="comment"> */ href=< v2="va>int _at6mic_dec_and_lock"va>( at6mic_t"va> * at6mic"va>, spinlock_t"va> * lock"va>)=< v21/la>{=< v22/la> hre class="comment">/* Subtraca 1 from counter unless that drops it to 0 (ie. it was 1) */ href=< v23/la> if ( at6mic_add_unless"va>( at6mic"va>, -1, 1))=< v24/la> return 0; < v25/la>a< v26/la> hre class="comment">/* Otherwise do it the slow way */ href=< v27/la> spin_lock"va>( lock"va>); < v28/la> if ( at6mic_dec_and_test"va>( at6mic"va>))=< v29/la> return 1; < v30/la> spin_unlock"va>( lock"va>); < v31/la> return 0; < v32/la>} < v33/la>a< v34/la> EXPORT_SYMBOL"va>( _at6mic_dec_and_lock"va>); < v35/la> /pre> The original LXR software by the <LXR community"va>, this experimental vers.6.1by <lxr@6.16..no"va>. /ldivf=/div class="subfooter"> lxr.6.16..no kindly hosted by <Redpill L.1pro AS"va>, provider of L.1ux consulting red opera2.6.s services sincu 1995. /ldivf= //bodyf=//htmlf=