Blame view

kernel/linux-rt-4.4.41/arch/m68k/include/asm/string.h 1.64 KB
5113f6f70   김현기   kernel add
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
  #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 ("
  "
  		"1:     subq.l  #1,%1
  "
  		"       jcs     2f
  "
  		"       tst.b   (%0)+
  "
  		"       jne     1b
  "
  		"       subq.l  #1,%0
  "
  		"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 ("
  "
  		"	jra	2f
  "
  		"1:	move.b	(%1),(%0)+
  "
  		"	jeq	2f
  "
  		"	addq.l	#1,%1
  "
  		"2:	subq.l	#1,%2
  "
  		"	jcc	1b
  "
  		: "+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 ("
  "
  		"1:	move.b	(%0)+,%2
  "	/* get *cs */
  		"	cmp.b	(%1)+,%2
  "	/* compare a byte */
  		"	jne	2f
  "		/* not equal, break out */
  		"	tst.b	%2
  "		/* at end of cs? */
  		"	jne	1b
  "		/* no, keep going */
  		"	jra	3f
  "		/* strings are equal */
  		"2:	sub.b	-(%1),%2
  "	/* *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_ */