# do { ... } while (0) In C programming language,`do { ... } while (0)` is a loop which does a single iteration. A compiler will optimize it away completely, so the syntax produces no actual machine code. Most commonly, it's used to make [[function-macro|function-macros]]. Example: ```c /* * - 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) ``` ## Links - https://stackoverflow.com/questions/2381300/what-does-do-while-0-do-exactly-in-kernel-code