2 * include/asm-s390/string.h
5 * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
9 #ifndef _S390_STRING_H_
10 #define _S390_STRING_H_
12 #ifndef _LINUX_TYPES_H
13 #include <linux/types.h>
16 #define __HAVE_ARCH_MEMCHR /* inline & arch function */
17 #define __HAVE_ARCH_MEMCMP /* arch function */
18 #define __HAVE_ARCH_MEMCPY /* gcc builtin & arch function */
19 #define __HAVE_ARCH_MEMSCAN /* inline & arch function */
20 #define __HAVE_ARCH_MEMSET /* gcc builtin & arch function */
21 #define __HAVE_ARCH_STRCAT /* inline & arch function */
22 #define __HAVE_ARCH_STRCMP /* arch function */
23 #define __HAVE_ARCH_STRCPY /* inline & arch function */
24 #define __HAVE_ARCH_STRLCAT /* arch function */
25 #define __HAVE_ARCH_STRLCPY /* arch function */
26 #define __HAVE_ARCH_STRLEN /* inline & arch function */
27 #define __HAVE_ARCH_STRNCAT /* arch function */
28 #define __HAVE_ARCH_STRNCPY /* arch function */
29 #define __HAVE_ARCH_STRNLEN /* inline & arch function */
30 #define __HAVE_ARCH_STRRCHR /* arch function */
31 #define __HAVE_ARCH_STRSTR /* arch function */
33 /* Prototypes for non-inlined arch strings functions. */
34 extern int memcmp(const void *, const void *, size_t);
35 extern void *memcpy(void *, const void *, size_t);
36 extern void *memset(void *, int, size_t);
37 extern int strcmp(const char *,const char *);
38 extern size_t strlcat(char *, const char *, size_t);
39 extern size_t strlcpy(char *, const char *, size_t);
40 extern char *strncat(char *, const char *, size_t);
41 extern char *strncpy(char *, const char *, size_t);
42 extern char *strrchr(const char *, int);
43 extern char *strstr(const char *, const char *);
45 #undef __HAVE_ARCH_MEMMOVE
46 #undef __HAVE_ARCH_STRCHR
47 #undef __HAVE_ARCH_STRNCHR
48 #undef __HAVE_ARCH_STRNCMP
49 #undef __HAVE_ARCH_STRNICMP
50 #undef __HAVE_ARCH_STRPBRK
51 #undef __HAVE_ARCH_STRSEP
52 #undef __HAVE_ARCH_STRSPN
54 #if !defined(IN_ARCH_STRING_C)
56 static inline void *memchr(const void * s, int c, size_t n)
58 register int r0 asm("0") = (char) c;
59 const void *ret = s + n;
67 : "+a" (ret), "+&a" (s) : "d" (r0) : "cc");
71 static inline void *memscan(void *s, int c, size_t n)
73 register int r0 asm("0") = (char) c;
74 const void *ret = s + n;
79 : "+a" (ret), "+&a" (s) : "d" (r0) : "cc");
83 static inline char *strcat(char *dst, const char *src)
85 register int r0 asm("0") = 0;
94 : "=&a" (dummy), "+a" (dst), "+a" (src)
95 : "d" (r0), "0" (0) : "cc", "memory" );
99 static inline char *strcpy(char *dst, const char *src)
102 register int r0 asm("0") = 0;
108 : "+&a" (dst), "+&a" (src) : "d" (r0)
112 return __builtin_strcpy(dst, src);
116 static inline size_t strlen(const char *s)
119 register unsigned long r0 asm("0") = 0;
125 : "+d" (r0), "+a" (tmp) : : "cc");
126 return r0 - (unsigned long) s;
128 return __builtin_strlen(s);
132 static inline size_t strnlen(const char * s, size_t n)
134 register int r0 asm("0") = 0;
136 const char *end = s + n;
141 : "+a" (end), "+a" (tmp) : "d" (r0) : "cc");
144 #else /* IN_ARCH_STRING_C */
145 void *memchr(const void * s, int c, size_t n);
146 void *memscan(void *s, int c, size_t n);
147 char *strcat(char *dst, const char *src);
148 char *strcpy(char *dst, const char *src);
149 size_t strlen(const char *s);
150 size_t strnlen(const char * s, size_t n);
151 #endif /* !IN_ARCH_STRING_C */
153 #endif /* __S390_STRING_H_ */