Alpha already had an optimised fill-memory-with-16-bit-quantity assembler routine called memsetw(). It has a slightly different calling convention from memset16() in that it takes a byte count, not a count of words. That's the same convention used by ARM's __memset routines, so rename Alpha's routine to match and add a memset16() wrapper around it. Then convert Alpha's scr_memsetw() to call memset16() instead of memsetw(). Link: http://lkml.kernel.org/r/20170720184539.31609-6-willy@infradead.org Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com> Cc: Richard Henderson <rth@twiddle.net> Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru> Cc: Matt Turner <mattst88@gmail.com> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com> Cc: "Martin K. Petersen" <martin.petersen@oracle.com> Cc: David Miller <davem@davemloft.net> Cc: Ingo Molnar <mingo@elte.hu> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Minchan Kim <minchan@kernel.org> Cc: Ralf Baechle <ralf@linux-mips.org> Cc: Russell King <rmk+kernel@armlinux.org.uk> Cc: Sam Ravnborg <sam@ravnborg.org> Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Cc: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
80 lines
2.4 KiB
C
80 lines
2.4 KiB
C
#ifndef __ALPHA_STRING_H__
|
|
#define __ALPHA_STRING_H__
|
|
|
|
#ifdef __KERNEL__
|
|
|
|
/*
|
|
* GCC of any recent vintage doesn't do stupid things with bcopy.
|
|
* EGCS 1.1 knows all about expanding memcpy inline, others don't.
|
|
*
|
|
* Similarly for a memset with data = 0.
|
|
*/
|
|
|
|
#define __HAVE_ARCH_MEMCPY
|
|
extern void * memcpy(void *, const void *, size_t);
|
|
#define __HAVE_ARCH_MEMMOVE
|
|
extern void * memmove(void *, const void *, size_t);
|
|
|
|
/* For backward compatibility with modules. Unused otherwise. */
|
|
extern void * __memcpy(void *, const void *, size_t);
|
|
|
|
#define memcpy __builtin_memcpy
|
|
|
|
#define __HAVE_ARCH_MEMSET
|
|
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);
|
|
|
|
/* For gcc 3.x, we cannot have the inline function named "memset" because
|
|
the __builtin_memset will attempt to resolve to the inline as well,
|
|
leading to a "sorry" about unimplemented recursive inlining. */
|
|
extern inline void *__memset(void *s, int c, size_t 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
|
|
extern char * strcpy(char *,const char *);
|
|
#define __HAVE_ARCH_STRNCPY
|
|
extern char * strncpy(char *, const char *, size_t);
|
|
#define __HAVE_ARCH_STRCAT
|
|
extern char * strcat(char *, const char *);
|
|
#define __HAVE_ARCH_STRNCAT
|
|
extern char * strncat(char *, const char *, size_t);
|
|
#define __HAVE_ARCH_STRCHR
|
|
extern char * strchr(const char *,int);
|
|
#define __HAVE_ARCH_STRRCHR
|
|
extern char * strrchr(const char *,int);
|
|
#define __HAVE_ARCH_STRLEN
|
|
extern size_t strlen(const char *);
|
|
#define __HAVE_ARCH_MEMCHR
|
|
extern void * memchr(const void *, int, size_t);
|
|
|
|
/* The following routine is like memset except that it writes 16-bit
|
|
aligned values. The DEST and COUNT parameters must be even for
|
|
correct operation. */
|
|
|
|
#define __HAVE_ARCH_MEMSET16
|
|
extern void * __memset16(void *dest, unsigned short, size_t count);
|
|
static inline void *memset16(uint16_t *p, uint16_t v, size_t n)
|
|
{
|
|
if (__builtin_constant_p(v))
|
|
return __constant_c_memset(p, 0x0001000100010001UL * v, n * 2);
|
|
return __memset16(p, v, n * 2);
|
|
}
|
|
|
|
#endif /* __KERNEL__ */
|
|
|
|
#endif /* __ALPHA_STRING_H__ */
|