title: What does "do { ... } while (0)" do exactly in kernel code?
body: <blockquote>
    <p><strong>Possible Duplicates:</strong><br>
    <a href="https://stackoverflow.com/questions/923822/whats-the-use-of-do-while0-when-we-define-a-macro">What&rsquo;s the use of do while(0) when we define a macro?</a><br>
    <a href="https://stackoverflow.com/questions/154136/why-are-there-sometimes-meaningless-do-while-and-if-else-statements-in-c-c-macr">Why are there sometimes meaningless do/while and if/else statements in C/C++ macros? </a><br>
    <a href="https://stackoverflow.com/questions/1067226/c-multi-line-macro-do-while0-vs-scope-block">C multi-line macro: do/while(0) vs scope block</a>  </p>
  </blockquote>
  
  
  
  <p>I have seen a lot of usages like this, previously I though that the programmer wanted to break out of a block of code easily. Why do we need a do { ... } while (0) loop here? Are we trying to tell the compiler something?</p>
  
  <p>For instance in Linux kernel 2.6.25, include/asm-ia64/system.h</p>
  
  <pre><code>/*
   * - clearing psr.i is implicitly serialized (visible by next insn)
   * - setting psr.i requires data serialization
   * - we need a stop-bit before reading PSR because we sometimes
   *   write a floating-point register right before reading the PSR
   *   and that writes to PSR.mfl
   */
  #define __local_irq_save(x)         \
  do {                    \
      ia64_stop();                \
      (x) = ia64_getreg(_IA64_REG_PSR);   \
      ia64_stop();                \
      ia64_rsm(IA64_PSR_I);           \
  } while (0)
  </code></pre>