kernel_optimize_test/arch/m68k/include/asm/string.h
Geert Uytterhoeven d346a5db02 m68k: Remove inline strcpy() and strcat() implementations
Gcc may replace calls to standard string functions by open code and/or
calls to other standard string functions. If the replacement function is
not available out-of-line, link errors will happen.

To avoid this, the out-of-line versions were provided by
arch/m68k/lib/string.c, but they were usually not linked in anymore as
typically none of its symbols are referenced by built-in code.
However, if any module would need them, they would not be available.

Hence remove the inline strcpy() and strcat() implementations, remove
arch/m68k/lib/string.c, and let the generic string library code handle it.

Impact on a typical kernel build seems minimal or nonexistent:

-      .text : 0x00001000 - 0x002aac74   (2728 KiB)
-      .data : 0x002ada48 - 0x00392148   ( 914 KiB)
+      .text : 0x00001000 - 0x002aacf4   (2728 KiB)
+      .data : 0x002adac8 - 0x00392148   ( 914 KiB)

See also commit e00c73ee05 ("m68k: Remove
inline strlen() implementation").

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
2013-06-24 19:44:18 +02:00

74 lines
1.6 KiB
C

#ifndef _M68K_STRING_H_
#define _M68K_STRING_H_
#include <linux/types.h>
#include <linux/compiler.h>
#define __HAVE_ARCH_STRNLEN
static inline size_t strnlen(const char *s, size_t count)
{
const char *sc = s;
asm volatile ("\n"
"1: subq.l #1,%1\n"
" jcs 2f\n"
" tst.b (%0)+\n"
" jne 1b\n"
" subq.l #1,%0\n"
"2:"
: "+a" (sc), "+d" (count));
return sc - s;
}
#define __HAVE_ARCH_STRNCPY
static inline char *strncpy(char *dest, const char *src, size_t n)
{
char *xdest = dest;
asm volatile ("\n"
" jra 2f\n"
"1: move.b (%1),(%0)+\n"
" jeq 2f\n"
" addq.l #1,%1\n"
"2: subq.l #1,%2\n"
" jcc 1b\n"
: "+a" (dest), "+a" (src), "+d" (n)
: : "memory");
return xdest;
}
#ifndef CONFIG_COLDFIRE
#define __HAVE_ARCH_STRCMP
static inline int strcmp(const char *cs, const char *ct)
{
char res;
asm ("\n"
"1: move.b (%0)+,%2\n" /* get *cs */
" cmp.b (%1)+,%2\n" /* compare a byte */
" jne 2f\n" /* not equal, break out */
" tst.b %2\n" /* at end of cs? */
" jne 1b\n" /* no, keep going */
" jra 3f\n" /* strings are equal */
"2: sub.b -(%1),%2\n" /* *cs - *ct */
"3:"
: "+a" (cs), "+a" (ct), "=d" (res));
return res;
}
#endif /* CONFIG_COLDFIRE */
#define __HAVE_ARCH_MEMMOVE
extern void *memmove(void *, const void *, __kernel_size_t);
#define memcmp(d, s, n) __builtin_memcmp(d, s, n)
#define __HAVE_ARCH_MEMSET
extern void *memset(void *, int, __kernel_size_t);
#define memset(d, c, n) __builtin_memset(d, c, n)
#define __HAVE_ARCH_MEMCPY
extern void *memcpy(void *, const void *, __kernel_size_t);
#define memcpy(d, s, n) __builtin_memcpy(d, s, n)
#endif /* _M68K_STRING_H_ */