From dcec8a13bf565e47942a1751a9cec21bec5648fe Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Thu, 7 May 1998 02:55:41 +0000 Subject: o Merge with Linux 2.1.99. o Fix ancient bug in the ELF loader making ldd crash. o Fix ancient bug in the keyboard code for SGI, SNI and Jazz. --- include/asm-alpha/string.h | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) (limited to 'include/asm-alpha/string.h') diff --git a/include/asm-alpha/string.h b/include/asm-alpha/string.h index 6ef1f4120..4b83c8291 100644 --- a/include/asm-alpha/string.h +++ b/include/asm-alpha/string.h @@ -3,29 +3,40 @@ #ifdef __KERNEL__ -extern void * __constant_c_memset(void *, unsigned long, long); -extern void * __memset(void *, char, size_t); - /* - * Ugh. Gcc uses "bcopy()" internally for structure assignments. + * GCC of any recent vintage doesn't do stupid things with bcopy. Of + * EGCS-devel vintage, it knows all about expanding memcpy inline. + * For things other than EGCS-devel but still recent, GCC will expand + * __builtin_memcpy as a simple call to memcpy. + * + * Similarly for a memset with data = 0. */ -#define __HAVE_ARCH_BCOPY -/* - * Define "memcpy()" to something else, otherwise gcc will - * corrupt that too into a "bcopy". Also, some day we might - * want to do a separate inlined constant-size memcpy (for 8 - * and 16 byte user<->kernel structure copying). - */ #define __HAVE_ARCH_MEMCPY +/* For backward compatibility with modules. Unused otherwise. */ extern void * __memcpy(void *, const void *, size_t); -#define memcpy __memcpy + +#if __GNUC__ > 2 || __GNUC_MINOR__ >= 8 +#define memcpy __builtin_memcpy +#endif #define __HAVE_ARCH_MEMSET -#define memset(s, c, count) \ -(__builtin_constant_p(c) ? \ - __constant_c_memset((s),(0x0101010101010101UL*(unsigned char)c),(count)) : \ - __memset((s),(c),(count))) +extern void * __constant_c_memset(void *, unsigned long, long); +extern void * __memset(void *, char, size_t); + +#if __GNUC__ > 2 || __GNUC_MINOR__ >= 8 +#define memset(s, c, n) \ +(__builtin_constant_p(c) \ + ? (__builtin_constant_p(n) && (c) == 0 \ + ? __builtin_memset((s),0,(n)) \ + : __constant_c_memset((s),0x0101010101010101UL*(unsigned char)(c),(n))) \ + : __memset((s),(c),(n))) +#else +#define memset(s, c, n) \ +(__builtin_constant_p(c) \ + ? __constant_c_memset((s),0x0101010101010101UL*(unsigned char)(c),(n)) \ + : __memset((s),(c),(n))) +#endif #define __HAVE_ARCH_STRCPY #define __HAVE_ARCH_STRNCPY -- cgit v1.2.3