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