Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef __ALPHA_STRING_H__
0003 #define __ALPHA_STRING_H__
0004 
0005 #ifdef __KERNEL__
0006 
0007 /*
0008  * GCC of any recent vintage doesn't do stupid things with bcopy.
0009  * EGCS 1.1 knows all about expanding memcpy inline, others don't.
0010  *
0011  * Similarly for a memset with data = 0.
0012  */
0013 
0014 #define __HAVE_ARCH_MEMCPY
0015 extern void * memcpy(void *, const void *, size_t);
0016 #define __HAVE_ARCH_MEMMOVE
0017 extern void * memmove(void *, const void *, size_t);
0018 
0019 /* For backward compatibility with modules.  Unused otherwise.  */
0020 extern void * __memcpy(void *, const void *, size_t);
0021 
0022 #define memcpy __builtin_memcpy
0023 
0024 #define __HAVE_ARCH_MEMSET
0025 extern void * __constant_c_memset(void *, unsigned long, size_t);
0026 extern void * ___memset(void *, int, size_t);
0027 extern void * __memset(void *, int, size_t);
0028 extern void * memset(void *, int, size_t);
0029 
0030 /* For gcc 3.x, we cannot have the inline function named "memset" because
0031    the __builtin_memset will attempt to resolve to the inline as well,
0032    leading to a "sorry" about unimplemented recursive inlining.  */
0033 extern inline void *__memset(void *s, int c, size_t n)
0034 {
0035     if (__builtin_constant_p(c)) {
0036         if (__builtin_constant_p(n)) {
0037             return __builtin_memset(s, c, n);
0038         } else {
0039             unsigned long c8 = (c & 0xff) * 0x0101010101010101UL;
0040             return __constant_c_memset(s, c8, n);
0041         }
0042     }
0043     return ___memset(s, c, n);
0044 }
0045 
0046 #define memset __memset
0047 
0048 #define __HAVE_ARCH_STRCPY
0049 extern char * strcpy(char *,const char *);
0050 #define __HAVE_ARCH_STRNCPY
0051 extern char * strncpy(char *, const char *, size_t);
0052 #define __HAVE_ARCH_STRCAT
0053 extern char * strcat(char *, const char *);
0054 #define __HAVE_ARCH_STRNCAT
0055 extern char * strncat(char *, const char *, size_t);
0056 #define __HAVE_ARCH_STRCHR
0057 extern char * strchr(const char *,int);
0058 #define __HAVE_ARCH_STRRCHR
0059 extern char * strrchr(const char *,int);
0060 #define __HAVE_ARCH_STRLEN
0061 extern size_t strlen(const char *);
0062 #define __HAVE_ARCH_MEMCHR
0063 extern void * memchr(const void *, int, size_t);
0064 
0065 /* The following routine is like memset except that it writes 16-bit
0066    aligned values.  The DEST and COUNT parameters must be even for 
0067    correct operation.  */
0068 
0069 #define __HAVE_ARCH_MEMSET16
0070 extern void * __memset16(void *dest, unsigned short, size_t count);
0071 static inline void *memset16(uint16_t *p, uint16_t v, size_t n)
0072 {
0073     if (__builtin_constant_p(v))
0074         return __constant_c_memset(p, 0x0001000100010001UL * v, n * 2);
0075     return __memset16(p, v, n * 2);
0076 }
0077 
0078 #endif /* __KERNEL__ */
0079 
0080 #endif /* __ALPHA_STRING_H__ */