Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

signal: use BUILD_BUG() instead of _NSIG_WORDS_is_unsupported_size()

Kill _NSIG_WORDS_is_unsupported_size(), use BUILD_BUG() instead. This
simplifies the code, avoids the nested-externs warnings, and this way we
do not defer the problem to linker.

Also, fix the indentation in _SIG_SET_BINOP() and _SIG_SET_OP().

Note: this patch assumes that the code like "if (0) BUILD_BUG();" is
valid. If not (say __compiletime_error() is not defined and thus
__compiletime_error_fallback() uses a negative array) we should fix
BUILD_BUG() and/or BUILD_BUG_ON_MSG(). This code should be fine by
definition, this is the documented purpose of BUILD_BUG().

[sfr@canb.auug.org.au: fix powerpc build failures]
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Reported-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Oleg Nesterov and committed by
Linus Torvalds
1c3bea0e 877aabd6

+13 -16
+13 -16
include/linux/signal.h
··· 2 2 #define _LINUX_SIGNAL_H 3 3 4 4 #include <linux/list.h> 5 + #include <linux/bug.h> 5 6 #include <uapi/linux/signal.h> 6 7 7 8 struct task_struct; ··· 68 67 69 68 static inline int sigisemptyset(sigset_t *set) 70 69 { 71 - extern void _NSIG_WORDS_is_unsupported_size(void); 72 70 switch (_NSIG_WORDS) { 73 71 case 4: 74 72 return (set->sig[3] | set->sig[2] | ··· 77 77 case 1: 78 78 return set->sig[0] == 0; 79 79 default: 80 - _NSIG_WORDS_is_unsupported_size(); 80 + BUILD_BUG(); 81 81 return 0; 82 82 } 83 83 } ··· 90 90 #define _SIG_SET_BINOP(name, op) \ 91 91 static inline void name(sigset_t *r, const sigset_t *a, const sigset_t *b) \ 92 92 { \ 93 - extern void _NSIG_WORDS_is_unsupported_size(void); \ 94 93 unsigned long a0, a1, a2, a3, b0, b1, b2, b3; \ 95 94 \ 96 95 switch (_NSIG_WORDS) { \ 97 - case 4: \ 96 + case 4: \ 98 97 a3 = a->sig[3]; a2 = a->sig[2]; \ 99 98 b3 = b->sig[3]; b2 = b->sig[2]; \ 100 99 r->sig[3] = op(a3, b3); \ 101 100 r->sig[2] = op(a2, b2); \ 102 - case 2: \ 101 + case 2: \ 103 102 a1 = a->sig[1]; b1 = b->sig[1]; \ 104 103 r->sig[1] = op(a1, b1); \ 105 - case 1: \ 104 + case 1: \ 106 105 a0 = a->sig[0]; b0 = b->sig[0]; \ 107 106 r->sig[0] = op(a0, b0); \ 108 107 break; \ 109 - default: \ 110 - _NSIG_WORDS_is_unsupported_size(); \ 108 + default: \ 109 + BUILD_BUG(); \ 111 110 } \ 112 111 } 113 112 ··· 127 128 #define _SIG_SET_OP(name, op) \ 128 129 static inline void name(sigset_t *set) \ 129 130 { \ 130 - extern void _NSIG_WORDS_is_unsupported_size(void); \ 131 - \ 132 131 switch (_NSIG_WORDS) { \ 133 - case 4: set->sig[3] = op(set->sig[3]); \ 134 - set->sig[2] = op(set->sig[2]); \ 135 - case 2: set->sig[1] = op(set->sig[1]); \ 136 - case 1: set->sig[0] = op(set->sig[0]); \ 132 + case 4: set->sig[3] = op(set->sig[3]); \ 133 + set->sig[2] = op(set->sig[2]); \ 134 + case 2: set->sig[1] = op(set->sig[1]); \ 135 + case 1: set->sig[0] = op(set->sig[0]); \ 137 136 break; \ 138 - default: \ 139 - _NSIG_WORDS_is_unsupported_size(); \ 137 + default: \ 138 + BUILD_BUG(); \ 140 139 } \ 141 140 } 142 141