Commit a47e5bb5 authored by Richard Henderson's avatar Richard Henderson Committed by Matt Turner

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: default avatarRichard Henderson <rth@twiddle.net>
parent 673fdfe3
...@@ -22,15 +22,27 @@ extern void * __memcpy(void *, const void *, size_t); ...@@ -22,15 +22,27 @@ extern void * __memcpy(void *, const void *, size_t);
#define __HAVE_ARCH_MEMSET #define __HAVE_ARCH_MEMSET
extern void * __constant_c_memset(void *, unsigned long, size_t); extern void * __constant_c_memset(void *, unsigned long, size_t);
extern void * ___memset(void *, int, size_t);
extern void * __memset(void *, int, size_t); extern void * __memset(void *, int, size_t);
extern void * memset(void *, int, size_t); extern void * memset(void *, int, size_t);
#define memset(s, c, n) \ /* For gcc 3.x, we cannot have the inline function named "memset" because
(__builtin_constant_p(c) \ the __builtin_memset will attempt to resolve to the inline as well,
? (__builtin_constant_p(n) && (c) == 0 \ leading to a "sorry" about unimplemented recursive inlining. */
? __builtin_memset((s),0,(n)) \ extern inline void *__memset(void *s, int c, size_t n)
: __constant_c_memset((s),0x0101010101010101UL*(unsigned char)(c),(n))) \ {
: __memset((s),(c),(n))) if (__builtin_constant_p(c)) {
if (__builtin_constant_p(n)) {
return __builtin_memset(s, c, n);
} else {
unsigned long c8 = (c & 0xff) * 0x0101010101010101UL;
return __constant_c_memset(s, c8, n);
}
}
return ___memset(s, c, n);
}
#define memset __memset
#define __HAVE_ARCH_STRCPY #define __HAVE_ARCH_STRCPY
extern char * strcpy(char *,const char *); extern char * strcpy(char *,const char *);
......
...@@ -40,6 +40,7 @@ EXPORT_SYMBOL(strrchr); ...@@ -40,6 +40,7 @@ EXPORT_SYMBOL(strrchr);
EXPORT_SYMBOL(memmove); EXPORT_SYMBOL(memmove);
EXPORT_SYMBOL(__memcpy); EXPORT_SYMBOL(__memcpy);
EXPORT_SYMBOL(__memset); EXPORT_SYMBOL(__memset);
EXPORT_SYMBOL(___memset);
EXPORT_SYMBOL(__memsetw); EXPORT_SYMBOL(__memsetw);
EXPORT_SYMBOL(__constant_c_memset); EXPORT_SYMBOL(__constant_c_memset);
EXPORT_SYMBOL(copy_page); EXPORT_SYMBOL(copy_page);
......
...@@ -30,14 +30,15 @@ ...@@ -30,14 +30,15 @@
.set noat .set noat
.set noreorder .set noreorder
.text .text
.globl memset
.globl __memset .globl __memset
.globl ___memset
.globl __memsetw .globl __memsetw
.globl __constant_c_memset .globl __constant_c_memset
.globl memset
.ent __memset .ent ___memset
.align 5 .align 5
__memset: ___memset:
.frame $30,0,$26,0 .frame $30,0,$26,0
.prologue 0 .prologue 0
...@@ -227,7 +228,7 @@ end_b: ...@@ -227,7 +228,7 @@ end_b:
nop nop
nop nop
ret $31,($26),1 # L0 : ret $31,($26),1 # L0 :
.end __memset .end ___memset
/* /*
* This is the original body of code, prior to replication and * This is the original body of code, prior to replication and
...@@ -594,4 +595,5 @@ end_w: ...@@ -594,4 +595,5 @@ end_w:
.end __memsetw .end __memsetw
memset = __memset memset = ___memset
__memset = ___memset
...@@ -19,11 +19,13 @@ ...@@ -19,11 +19,13 @@
.text .text
.globl memset .globl memset
.globl __memset .globl __memset
.globl ___memset
.globl __memsetw .globl __memsetw
.globl __constant_c_memset .globl __constant_c_memset
.ent __memset
.ent ___memset
.align 5 .align 5
__memset: ___memset:
.frame $30,0,$26,0 .frame $30,0,$26,0
.prologue 0 .prologue 0
...@@ -103,7 +105,7 @@ within_one_quad: ...@@ -103,7 +105,7 @@ within_one_quad:
end: end:
ret $31,($26),1 /* E1 */ ret $31,($26),1 /* E1 */
.end __memset .end ___memset
.align 5 .align 5
.ent __memsetw .ent __memsetw
...@@ -121,4 +123,5 @@ __memsetw: ...@@ -121,4 +123,5 @@ __memsetw:
.end __memsetw .end __memsetw
memset = __memset memset = ___memset
__memset = ___memset
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment