Re: [PATCH] signal: fix building with clang

From: Oleg Nesterov
Date: Thu Mar 07 2019 - 11:46:56 EST


On 03/07, Arnd Bergmann wrote:
>
> We could use % everywhere,

Yes.

But again, why not simply use the "for (;;)" loops? Why we can't kill the
supid switch(_NSIG_WORDS) tricks altogether?

Oleg.

--- x/include/linux/signal.h
+++ x/include/linux/signal.h
@@ -121,26 +121,9 @@
#define _SIG_SET_BINOP(name, op) \
static inline void name(sigset_t *r, const sigset_t *a, const sigset_t *b) \
{ \
- unsigned long a0, a1, a2, a3, b0, b1, b2, b3; \
- \
- switch (_NSIG_WORDS) { \
- case 4: \
- a3 = a->sig[3]; a2 = a->sig[2]; \
- b3 = b->sig[3]; b2 = b->sig[2]; \
- r->sig[3] = op(a3, b3); \
- r->sig[2] = op(a2, b2); \
- /* fall through */ \
- case 2: \
- a1 = a->sig[1]; b1 = b->sig[1]; \
- r->sig[1] = op(a1, b1); \
- /* fall through */ \
- case 1: \
- a0 = a->sig[0]; b0 = b->sig[0]; \
- r->sig[0] = op(a0, b0); \
- break; \
- default: \
- BUILD_BUG(); \
- } \
+ int i; \
+ for (i = 0; i < ARRAY_SIZE(r->sig); ++i) \
+ r->sig[i] = op(a->sig[i], b->sig[i]); \
}

#define _sig_or(x,y) ((x) | (y))