2005-09-08 04:27:09 +08:00
|
|
|
#ifndef _ASM_POWERPC_STRING_H
|
|
|
|
#define _ASM_POWERPC_STRING_H
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#ifdef __KERNEL__
|
|
|
|
|
|
|
|
#define __HAVE_ARCH_STRNCPY
|
2008-03-01 00:04:57 +08:00
|
|
|
#define __HAVE_ARCH_STRNCMP
|
2005-04-17 06:20:36 +08:00
|
|
|
#define __HAVE_ARCH_MEMSET
|
|
|
|
#define __HAVE_ARCH_MEMCPY
|
|
|
|
#define __HAVE_ARCH_MEMMOVE
|
|
|
|
#define __HAVE_ARCH_MEMCMP
|
|
|
|
#define __HAVE_ARCH_MEMCHR
|
powerpc/32: add memset16()
Commit 694fc88ce271f ("powerpc/string: Implement optimized
memset variants") added memset16(), memset32() and memset64()
for the 64 bits PPC.
On 32 bits, memset64() is not relevant, and as shown below,
the generic version of memset32() gives a good code, so only
memset16() is candidate for an optimised version.
000009c0 <memset32>:
9c0: 2c 05 00 00 cmpwi r5,0
9c4: 39 23 ff fc addi r9,r3,-4
9c8: 4d 82 00 20 beqlr
9cc: 7c a9 03 a6 mtctr r5
9d0: 94 89 00 04 stwu r4,4(r9)
9d4: 42 00 ff fc bdnz 9d0 <memset32+0x10>
9d8: 4e 80 00 20 blr
The last part of memset() handling the not 4-bytes multiples
operates on bytes, making it unsuitable for handling word without
modification. As it would increase memset() complexity, it is
better to implement memset16() from scratch. In addition it
has the advantage of allowing a more optimised memset16() than what
we would have by using the memset() function.
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2017-08-23 22:54:32 +08:00
|
|
|
#define __HAVE_ARCH_MEMSET16
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
extern char * strcpy(char *,const char *);
|
|
|
|
extern char * strncpy(char *,const char *, __kernel_size_t);
|
|
|
|
extern __kernel_size_t strlen(const char *);
|
|
|
|
extern int strcmp(const char *,const char *);
|
2008-03-01 00:04:57 +08:00
|
|
|
extern int strncmp(const char *, const char *, __kernel_size_t);
|
2005-04-17 06:20:36 +08:00
|
|
|
extern char * strcat(char *, const char *);
|
|
|
|
extern void * memset(void *,int,__kernel_size_t);
|
|
|
|
extern void * memcpy(void *,const void *,__kernel_size_t);
|
|
|
|
extern void * memmove(void *,const void *,__kernel_size_t);
|
|
|
|
extern int memcmp(const void *,const void *,__kernel_size_t);
|
|
|
|
extern void * memchr(const void *,int,__kernel_size_t);
|
|
|
|
|
2017-03-28 03:37:40 +08:00
|
|
|
#ifdef CONFIG_PPC64
|
|
|
|
#define __HAVE_ARCH_MEMSET32
|
|
|
|
#define __HAVE_ARCH_MEMSET64
|
|
|
|
|
|
|
|
extern void *__memset16(uint16_t *, uint16_t v, __kernel_size_t);
|
|
|
|
extern void *__memset32(uint32_t *, uint32_t v, __kernel_size_t);
|
|
|
|
extern void *__memset64(uint64_t *, uint64_t v, __kernel_size_t);
|
|
|
|
|
|
|
|
static inline void *memset16(uint16_t *p, uint16_t v, __kernel_size_t n)
|
|
|
|
{
|
|
|
|
return __memset16(p, v, n * 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void *memset32(uint32_t *p, uint32_t v, __kernel_size_t n)
|
|
|
|
{
|
|
|
|
return __memset32(p, v, n * 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void *memset64(uint64_t *p, uint64_t v, __kernel_size_t n)
|
|
|
|
{
|
|
|
|
return __memset64(p, v, n * 8);
|
|
|
|
}
|
powerpc/32: add memset16()
Commit 694fc88ce271f ("powerpc/string: Implement optimized
memset variants") added memset16(), memset32() and memset64()
for the 64 bits PPC.
On 32 bits, memset64() is not relevant, and as shown below,
the generic version of memset32() gives a good code, so only
memset16() is candidate for an optimised version.
000009c0 <memset32>:
9c0: 2c 05 00 00 cmpwi r5,0
9c4: 39 23 ff fc addi r9,r3,-4
9c8: 4d 82 00 20 beqlr
9cc: 7c a9 03 a6 mtctr r5
9d0: 94 89 00 04 stwu r4,4(r9)
9d4: 42 00 ff fc bdnz 9d0 <memset32+0x10>
9d8: 4e 80 00 20 blr
The last part of memset() handling the not 4-bytes multiples
operates on bytes, making it unsuitable for handling word without
modification. As it would increase memset() complexity, it is
better to implement memset16() from scratch. In addition it
has the advantage of allowing a more optimised memset16() than what
we would have by using the memset() function.
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2017-08-23 22:54:32 +08:00
|
|
|
#else
|
|
|
|
extern void *memset16(uint16_t *, uint16_t, __kernel_size_t);
|
2017-03-28 03:37:40 +08:00
|
|
|
#endif
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif /* __KERNEL__ */
|
|
|
|
|
2005-09-08 04:27:09 +08:00
|
|
|
#endif /* _ASM_POWERPC_STRING_H */
|