blob: 9eb9933d845fb8dc82f321e1a049641a4cd4c125 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __ALPHA_STRING_H__
2#define __ALPHA_STRING_H__
3
4#ifdef __KERNEL__
5
6/*
7 * GCC of any recent vintage doesn't do stupid things with bcopy.
8 * EGCS 1.1 knows all about expanding memcpy inline, others don't.
9 *
10 * Similarly for a memset with data = 0.
11 */
12
13#define __HAVE_ARCH_MEMCPY
14extern void * memcpy(void *, const void *, size_t);
15#define __HAVE_ARCH_MEMMOVE
16extern void * memmove(void *, const void *, size_t);
17
18/* For backward compatibility with modules. Unused otherwise. */
19extern void * __memcpy(void *, const void *, size_t);
20
21#define memcpy __builtin_memcpy
22
23#define __HAVE_ARCH_MEMSET
24extern void * __constant_c_memset(void *, unsigned long, size_t);
Richard Hendersona47e5bb2013-07-11 09:47:45 -070025extern void * ___memset(void *, int, size_t);
Linus Torvalds1da177e2005-04-16 15:20:36 -070026extern void * __memset(void *, int, size_t);
27extern void * memset(void *, int, size_t);
28
Richard Hendersona47e5bb2013-07-11 09:47:45 -070029/* For gcc 3.x, we cannot have the inline function named "memset" because
30 the __builtin_memset will attempt to resolve to the inline as well,
31 leading to a "sorry" about unimplemented recursive inlining. */
32extern inline void *__memset(void *s, int c, size_t n)
33{
34 if (__builtin_constant_p(c)) {
35 if (__builtin_constant_p(n)) {
36 return __builtin_memset(s, c, n);
37 } else {
38 unsigned long c8 = (c & 0xff) * 0x0101010101010101UL;
39 return __constant_c_memset(s, c8, n);
40 }
41 }
42 return ___memset(s, c, n);
43}
44
45#define memset __memset
Linus Torvalds1da177e2005-04-16 15:20:36 -070046
47#define __HAVE_ARCH_STRCPY
48extern char * strcpy(char *,const char *);
49#define __HAVE_ARCH_STRNCPY
50extern char * strncpy(char *, const char *, size_t);
51#define __HAVE_ARCH_STRCAT
52extern char * strcat(char *, const char *);
53#define __HAVE_ARCH_STRNCAT
54extern char * strncat(char *, const char *, size_t);
55#define __HAVE_ARCH_STRCHR
56extern char * strchr(const char *,int);
57#define __HAVE_ARCH_STRRCHR
58extern char * strrchr(const char *,int);
59#define __HAVE_ARCH_STRLEN
60extern size_t strlen(const char *);
61#define __HAVE_ARCH_MEMCHR
62extern void * memchr(const void *, int, size_t);
63
64/* The following routine is like memset except that it writes 16-bit
65 aligned values. The DEST and COUNT parameters must be even for
66 correct operation. */
67
Matthew Wilcox92ce4c32017-09-08 16:14:04 -070068#define __HAVE_ARCH_MEMSET16
69extern void * __memset16(void *dest, unsigned short, size_t count);
70static inline void *memset16(uint16_t *p, uint16_t v, size_t n)
71{
72 if (__builtin_constant_p(v))
73 return __constant_c_memset(p, 0x0001000100010001UL * v, n * 2);
74 return __memset16(p, v, n * 2);
75}
Linus Torvalds1da177e2005-04-16 15:20:36 -070076
Linus Torvalds1da177e2005-04-16 15:20:36 -070077#endif /* __KERNEL__ */
78
79#endif /* __ALPHA_STRING_H__ */