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

alpha: Eliminate compiler warning from memset macro

Compiling with GCC 4.8 yields several instances of

crypto/vmac.c: In function ‘vmac_final’:
crypto/vmac.c:616:9: warning: value computed is not used [-Wunused-value]
memset(&mac, 0, sizeof(vmac_t));
^
arch/alpha/include/asm/string.h:31:25: note: in definition of macro ‘memset’
? __builtin_memset((s),0,(n)) \
^
Converting the macro to an inline function eliminates this problem.

However, doing only that causes problems with the GCC 3.x series. The
inline function cannot be named "memset", as otherwise we wind up with
recursion via __builtin_memset. Solve this by adjusting the symbols
such that __memset is the inline, and ___memset is the real function.

Signed-off-by: Richard Henderson <rth@twiddle.net>

authored by

Richard Henderson and committed by
Matt Turner
a47e5bb5 673fdfe3

+33 -15
+18 -6
arch/alpha/include/asm/string.h
··· 22 22 23 23 #define __HAVE_ARCH_MEMSET 24 24 extern void * __constant_c_memset(void *, unsigned long, size_t); 25 + extern void * ___memset(void *, int, size_t); 25 26 extern void * __memset(void *, int, size_t); 26 27 extern void * memset(void *, int, size_t); 27 28 28 - #define memset(s, c, n) \ 29 - (__builtin_constant_p(c) \ 30 - ? (__builtin_constant_p(n) && (c) == 0 \ 31 - ? __builtin_memset((s),0,(n)) \ 32 - : __constant_c_memset((s),0x0101010101010101UL*(unsigned char)(c),(n))) \ 33 - : __memset((s),(c),(n))) 29 + /* For gcc 3.x, we cannot have the inline function named "memset" because 30 + the __builtin_memset will attempt to resolve to the inline as well, 31 + leading to a "sorry" about unimplemented recursive inlining. */ 32 + extern inline void *__memset(void *s, int c, size_t n) 33 + { 34 + if (__builtin_constant_p(c)) { 35 + if (__builtin_constant_p(n)) { 36 + return __builtin_memset(s, c, n); 37 + } else { 38 + unsigned long c8 = (c & 0xff) * 0x0101010101010101UL; 39 + return __constant_c_memset(s, c8, n); 40 + } 41 + } 42 + return ___memset(s, c, n); 43 + } 44 + 45 + #define memset __memset 34 46 35 47 #define __HAVE_ARCH_STRCPY 36 48 extern char * strcpy(char *,const char *);
+1
arch/alpha/kernel/alpha_ksyms.c
··· 40 40 EXPORT_SYMBOL(memmove); 41 41 EXPORT_SYMBOL(__memcpy); 42 42 EXPORT_SYMBOL(__memset); 43 + EXPORT_SYMBOL(___memset); 43 44 EXPORT_SYMBOL(__memsetw); 44 45 EXPORT_SYMBOL(__constant_c_memset); 45 46 EXPORT_SYMBOL(copy_page);
+7 -5
arch/alpha/lib/ev6-memset.S
··· 30 30 .set noat 31 31 .set noreorder 32 32 .text 33 + .globl memset 33 34 .globl __memset 35 + .globl ___memset 34 36 .globl __memsetw 35 37 .globl __constant_c_memset 36 - .globl memset 37 38 38 - .ent __memset 39 + .ent ___memset 39 40 .align 5 40 - __memset: 41 + ___memset: 41 42 .frame $30,0,$26,0 42 43 .prologue 0 43 44 ··· 228 227 nop 229 228 nop 230 229 ret $31,($26),1 # L0 : 231 - .end __memset 230 + .end ___memset 232 231 233 232 /* 234 233 * This is the original body of code, prior to replication and ··· 595 594 596 595 .end __memsetw 597 596 598 - memset = __memset 597 + memset = ___memset 598 + __memset = ___memset
+7 -4
arch/alpha/lib/memset.S
··· 19 19 .text 20 20 .globl memset 21 21 .globl __memset 22 + .globl ___memset 22 23 .globl __memsetw 23 24 .globl __constant_c_memset 24 - .ent __memset 25 + 26 + .ent ___memset 25 27 .align 5 26 - __memset: 28 + ___memset: 27 29 .frame $30,0,$26,0 28 30 .prologue 0 29 31 ··· 105 103 106 104 end: 107 105 ret $31,($26),1 /* E1 */ 108 - .end __memset 106 + .end ___memset 109 107 110 108 .align 5 111 109 .ent __memsetw ··· 123 121 124 122 .end __memsetw 125 123 126 - memset = __memset 124 + memset = ___memset 125 + __memset = ___memset