do-while-0
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| do-while-0 [February 18, 2026 at 12:46] – created yanevskiv | do-while-0 [May 14, 2026 at 11:38] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | # do { ... } while (0) | ||
| + | In C programming language, | ||
| + | |||
| + | |||
| + | 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 | ||
| + | | ||
| + | | ||
| + | */ | ||
| + | #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:// | ||
| + | |||
