MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / include / asm-s390 / string.h
blob017872d61daaefd80da9333fdd57f6a23c899e40
1 /*
2 * include/asm-s390/string.h
4 * S390 version
5 * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
6 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
7 */
9 #ifndef _S390_STRING_H_
10 #define _S390_STRING_H_
12 #ifdef __KERNEL__
14 #ifndef _LINUX_TYPES_H
15 #include <linux/types.h>
16 #endif
18 #define __HAVE_ARCH_BCOPY /* arch function */
19 #define __HAVE_ARCH_MEMCHR /* inline & arch function */
20 #define __HAVE_ARCH_MEMCMP /* arch function */
21 #define __HAVE_ARCH_MEMCPY /* gcc builtin & arch function */
22 #define __HAVE_ARCH_MEMSCAN /* inline & arch function */
23 #define __HAVE_ARCH_MEMSET /* gcc builtin & arch function */
24 #define __HAVE_ARCH_STRCAT /* inline & arch function */
25 #define __HAVE_ARCH_STRCMP /* arch function */
26 #define __HAVE_ARCH_STRCPY /* inline & arch function */
27 #define __HAVE_ARCH_STRLCAT /* arch function */
28 #define __HAVE_ARCH_STRLCPY /* arch function */
29 #define __HAVE_ARCH_STRLEN /* inline & arch function */
30 #define __HAVE_ARCH_STRNCAT /* arch function */
31 #define __HAVE_ARCH_STRNCPY /* arch function */
32 #define __HAVE_ARCH_STRNLEN /* inline & arch function */
33 #define __HAVE_ARCH_STRRCHR /* arch function */
34 #define __HAVE_ARCH_STRSTR /* arch function */
36 /* Prototypes for non-inlined arch strings functions. */
37 extern int memcmp(const void *, const void *, size_t);
38 extern void *memcpy(void *, const void *, size_t);
39 extern void *memset(void *, int, size_t);
40 extern int strcmp(const char *,const char *);
41 extern size_t strlcat(char *, const char *, size_t);
42 extern size_t strlcpy(char *, const char *, size_t);
43 extern char *strncat(char *, const char *, size_t);
44 extern char *strncpy(char *, const char *, size_t);
45 extern char *strrchr(const char *, int);
46 extern char *strstr(const char *, const char *);
48 #undef __HAVE_ARCH_MEMMOVE
49 #undef __HAVE_ARCH_STRCHR
50 #undef __HAVE_ARCH_STRNCHR
51 #undef __HAVE_ARCH_STRNCMP
52 #undef __HAVE_ARCH_STRNICMP
53 #undef __HAVE_ARCH_STRPBRK
54 #undef __HAVE_ARCH_STRSEP
55 #undef __HAVE_ARCH_STRSPN
57 #if !defined(IN_ARCH_STRING_C)
59 static inline void *memchr(const void * s, int c, size_t n)
61 register int r0 asm("0") = (char) c;
62 const void *ret = s + n;
64 asm volatile ("0: srst %0,%1\n"
65 " jo 0b\n"
66 " jl 1f\n"
67 " la %0,0\n"
68 "1:"
69 : "+a" (ret), "+&a" (s) : "d" (r0) : "cc" );
70 return (void *) ret;
73 static inline void *memscan(void *s, int c, size_t n)
75 register int r0 asm("0") = (char) c;
76 const void *ret = s + n;
78 asm volatile ("0: srst %0,%1\n"
79 " jo 0b\n"
80 : "+a" (ret), "+&a" (s) : "d" (r0) : "cc" );
81 return (void *) ret;
84 static inline char *strcat(char *dst, const char *src)
86 register int r0 asm("0") = 0;
87 unsigned long dummy;
88 char *ret = dst;
90 asm volatile ("0: srst %0,%1\n"
91 " jo 0b\n"
92 "1: mvst %0,%2\n"
93 " jo 1b"
94 : "=&a" (dummy), "+a" (dst), "+a" (src)
95 : "d" (r0), "0" (0) : "cc", "memory" );
96 return ret;
99 static inline char *strcpy(char *dst, const char *src)
101 register int r0 asm("0") = 0;
102 char *ret = dst;
104 asm volatile ("0: mvst %0,%1\n"
105 " jo 0b"
106 : "+&a" (dst), "+&a" (src) : "d" (r0)
107 : "cc", "memory" );
108 return ret;
111 static inline size_t strlen(const char *s)
113 register unsigned long r0 asm("0") = 0;
114 const char *tmp = s;
116 asm volatile ("0: srst %0,%1\n"
117 " jo 0b"
118 : "+d" (r0), "+a" (tmp) : : "cc" );
119 return r0 - (unsigned long) s;
122 static inline size_t strnlen(const char * s, size_t n)
124 register int r0 asm("0") = 0;
125 const char *tmp = s;
126 const char *end = s + n;
128 asm volatile ("0: srst %0,%1\n"
129 " jo 0b"
130 : "+a" (end), "+a" (tmp) : "d" (r0) : "cc" );
131 return end - s;
134 #endif /* !IN_ARCH_STRING_C */
136 #endif /* __KERNEL__ */
138 #endif /* __S390_STRING_H_ */