On Mon, 1 Jul 2019 00:21:12 +0800 Gavin Hu <gavin...@arm.com> wrote:
> +#ifdef RTE_USE_WFE > +#define rte_wait_until_equal_relaxed(addr, expected) do {\ > + typeof(*addr) tmp; \ > + if (__builtin_constant_p((expected))) \ > + do { \ > + if (sizeof(*(addr)) == 16)\ > + asm volatile( \ > + "sevl\n" \ > + "1: wfe\n" \ > + "ldxrh %w0, %1\n" \ > + "cmp %w0, %w2\n" \ > + "bne 1b\n" \ > + : "=&r"(tmp) \ > + : "Q"(*addr), "i"(expected) \ > + : "cc", "memory"); \ > + else if (sizeof(*(addr)) == 32)\ > + asm volatile( \ > + "sevl\n" \ > + "1: wfe\n" \ > + "ldxr %w0, %1\n" \ > + "cmp %w0, %w2\n" \ > + "bne 1b\n" \ > + : "=&r"(tmp) \ > + : "Q"(*addr), "i"(expected) \ > + : "cc", "memory"); \ > + else if (sizeof(*(addr)) == 64)\ > + asm volatile( \ > + "sevl\n" \ > + "1: wfe\n" \ > + "ldxr %x0, %1\n" \ > + "cmp %x0, %x2\n" \ > + "bne 1b\n" \ > + : "=&r" (tmp) \ > + : "Q"(*addr), "i"(expected) \ > + : "cc", "memory"); \ > + } while (0); \ > + else \ > + do { \ > + if (sizeof(*(addr)) == 16)\ > + asm volatile( \ > + "sevl\n" \ > + "1: wfe\n" \ > + "ldxrh %w0, %1\n" \ > + "cmp %w0, %w2\n" \ > + "bne 1b\n" \ > + : "=&r"(tmp) \ > + : "Q"(*addr), "r"(expected) \ > + : "cc", "memory"); \ > + else if (sizeof(*(addr)) == 32)\ > + asm volatile( \ > + "sevl\n" \ > + "1: wfe\n" \ > + "ldxr %w0, %1\n" \ > + "cmp %w0, %w2\n" \ > + "bne 1b\n" \ > + : "=&r"(tmp) \ > + : "Q"(*addr), "r"(expected) \ > + : "cc", "memory"); \ > + else if (sizeof(*(addr)) == 64)\ > + asm volatile( \ > + "sevl\n" \ > + "1: wfe\n" \ > + "ldxr %x0, %1\n" \ > + "cmp %x0, %x2\n" \ > + "bne 1b\n" \ > + : "=&r" (tmp) \ > + : "Q"(*addr), "r"(expected) \ > + : "cc", "memory"); \ > + } while (0); \ > +} while (0) That is a hot mess. Macro's are harder to maintain and offer no benefit over inline functions.