~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/s390/include/asm/string.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 /*
  3  *  S390 version
  4  *    Copyright IBM Corp. 1999
  5  *    Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
  6  */
  7 
  8 #ifndef _S390_STRING_H_
  9 #define _S390_STRING_H_
 10 
 11 #ifndef _LINUX_TYPES_H
 12 #include <linux/types.h>
 13 #endif
 14 
 15 #define __HAVE_ARCH_MEMCPY      /* gcc builtin & arch function */
 16 #define __HAVE_ARCH_MEMMOVE     /* gcc builtin & arch function */
 17 #define __HAVE_ARCH_MEMSET      /* gcc builtin & arch function */
 18 
 19 void *memcpy(void *dest, const void *src, size_t n);
 20 void *memset(void *s, int c, size_t n);
 21 void *memmove(void *dest, const void *src, size_t n);
 22 
 23 #if !defined(CONFIG_KASAN) && !defined(CONFIG_KMSAN)
 24 #define __HAVE_ARCH_MEMCHR      /* inline & arch function */
 25 #define __HAVE_ARCH_MEMCMP      /* arch function */
 26 #define __HAVE_ARCH_MEMSCAN     /* inline & arch function */
 27 #define __HAVE_ARCH_STRCAT      /* inline & arch function */
 28 #define __HAVE_ARCH_STRCMP      /* arch function */
 29 #define __HAVE_ARCH_STRCPY      /* inline & arch function */
 30 #define __HAVE_ARCH_STRLCAT     /* arch function */
 31 #define __HAVE_ARCH_STRLEN      /* inline & arch function */
 32 #define __HAVE_ARCH_STRNCAT     /* arch function */
 33 #define __HAVE_ARCH_STRNCPY     /* arch function */
 34 #define __HAVE_ARCH_STRNLEN     /* inline & arch function */
 35 #define __HAVE_ARCH_STRSTR      /* arch function */
 36 #define __HAVE_ARCH_MEMSET16    /* arch function */
 37 #define __HAVE_ARCH_MEMSET32    /* arch function */
 38 #define __HAVE_ARCH_MEMSET64    /* arch function */
 39 
 40 /* Prototypes for non-inlined arch strings functions. */
 41 int memcmp(const void *s1, const void *s2, size_t n);
 42 int strcmp(const char *s1, const char *s2);
 43 size_t strlcat(char *dest, const char *src, size_t n);
 44 char *strncat(char *dest, const char *src, size_t n);
 45 char *strncpy(char *dest, const char *src, size_t n);
 46 char *strstr(const char *s1, const char *s2);
 47 #endif /* !defined(CONFIG_KASAN) && !defined(CONFIG_KMSAN) */
 48 
 49 #undef __HAVE_ARCH_STRCHR
 50 #undef __HAVE_ARCH_STRNCHR
 51 #undef __HAVE_ARCH_STRNCMP
 52 #undef __HAVE_ARCH_STRPBRK
 53 #undef __HAVE_ARCH_STRSEP
 54 #undef __HAVE_ARCH_STRSPN
 55 
 56 #if defined(CONFIG_KASAN) && !defined(__SANITIZE_ADDRESS__)
 57 
 58 #define strlen(s) __strlen(s)
 59 
 60 #define __no_sanitize_prefix_strfunc(x) __##x
 61 
 62 #ifndef __NO_FORTIFY
 63 #define __NO_FORTIFY /* FORTIFY_SOURCE uses __builtin_memcpy, etc. */
 64 #endif
 65 
 66 #else
 67 #define __no_sanitize_prefix_strfunc(x) x
 68 #endif /* defined(CONFIG_KASAN) && !defined(__SANITIZE_ADDRESS__) */
 69 
 70 void *__memcpy(void *dest, const void *src, size_t n);
 71 void *__memset(void *s, int c, size_t n);
 72 void *__memmove(void *dest, const void *src, size_t n);
 73 void *__memset16(uint16_t *s, uint16_t v, size_t count);
 74 void *__memset32(uint32_t *s, uint32_t v, size_t count);
 75 void *__memset64(uint64_t *s, uint64_t v, size_t count);
 76 
 77 #ifdef __HAVE_ARCH_MEMSET16
 78 static inline void *memset16(uint16_t *s, uint16_t v, size_t count)
 79 {
 80         return __memset16(s, v, count * sizeof(v));
 81 }
 82 #endif
 83 
 84 #ifdef __HAVE_ARCH_MEMSET32
 85 static inline void *memset32(uint32_t *s, uint32_t v, size_t count)
 86 {
 87         return __memset32(s, v, count * sizeof(v));
 88 }
 89 #endif
 90 
 91 #ifdef __HAVE_ARCH_MEMSET64
 92 #ifdef IN_BOOT_STRING_C
 93 void *memset64(uint64_t *s, uint64_t v, size_t count);
 94 #else
 95 static inline void *memset64(uint64_t *s, uint64_t v, size_t count)
 96 {
 97         return __memset64(s, v, count * sizeof(v));
 98 }
 99 #endif
100 #endif
101 
102 #if !defined(IN_ARCH_STRING_C) && (!defined(CONFIG_FORTIFY_SOURCE) || defined(__NO_FORTIFY))
103 
104 #ifdef __HAVE_ARCH_MEMCHR
105 static inline void *memchr(const void * s, int c, size_t n)
106 {
107         const void *ret = s + n;
108 
109         asm volatile(
110                 "       lgr     0,%[c]\n"
111                 "0:     srst    %[ret],%[s]\n"
112                 "       jo      0b\n"
113                 "       jl      1f\n"
114                 "       la      %[ret],0\n"
115                 "1:"
116                 : [ret] "+&a" (ret), [s] "+&a" (s)
117                 : [c] "d" (c)
118                 : "cc", "memory", "");
119         return (void *) ret;
120 }
121 #endif
122 
123 #ifdef __HAVE_ARCH_MEMSCAN
124 static inline void *memscan(void *s, int c, size_t n)
125 {
126         const void *ret = s + n;
127 
128         asm volatile(
129                 "       lgr     0,%[c]\n"
130                 "0:     srst    %[ret],%[s]\n"
131                 "       jo      0b\n"
132                 : [ret] "+&a" (ret), [s] "+&a" (s)
133                 : [c] "d" (c)
134                 : "cc", "memory", "");
135         return (void *) ret;
136 }
137 #endif
138 
139 #ifdef __HAVE_ARCH_STRCAT
140 static inline char *strcat(char *dst, const char *src)
141 {
142         unsigned long dummy = 0;
143         char *ret = dst;
144 
145         asm volatile(
146                 "       lghi    0,0\n"
147                 "0:     srst    %[dummy],%[dst]\n"
148                 "       jo      0b\n"
149                 "1:     mvst    %[dummy],%[src]\n"
150                 "       jo      1b"
151                 : [dummy] "+&a" (dummy), [dst] "+&a" (dst), [src] "+&a" (src)
152                 :
153                 : "cc", "memory", "");
154         return ret;
155 }
156 #endif
157 
158 #ifdef __HAVE_ARCH_STRCPY
159 static inline char *strcpy(char *dst, const char *src)
160 {
161         char *ret = dst;
162 
163         asm volatile(
164                 "       lghi    0,0\n"
165                 "0:     mvst    %[dst],%[src]\n"
166                 "       jo      0b"
167                 : [dst] "+&a" (dst), [src] "+&a" (src)
168                 :
169                 : "cc", "memory", "");
170         return ret;
171 }
172 #endif
173 
174 #if defined(__HAVE_ARCH_STRLEN) || (defined(CONFIG_KASAN) && !defined(__SANITIZE_ADDRESS__))
175 static inline size_t __no_sanitize_prefix_strfunc(strlen)(const char *s)
176 {
177         unsigned long end = 0;
178         const char *tmp = s;
179 
180         asm volatile(
181                 "       lghi    0,0\n"
182                 "0:     srst    %[end],%[tmp]\n"
183                 "       jo      0b"
184                 : [end] "+&a" (end), [tmp] "+&a" (tmp)
185                 :
186                 : "cc", "memory", "");
187         return end - (unsigned long)s;
188 }
189 #endif
190 
191 #ifdef __HAVE_ARCH_STRNLEN
192 static inline size_t strnlen(const char * s, size_t n)
193 {
194         const char *tmp = s;
195         const char *end = s + n;
196 
197         asm volatile(
198                 "       lghi    0,0\n"
199                 "0:     srst    %[end],%[tmp]\n"
200                 "       jo      0b"
201                 : [end] "+&a" (end), [tmp] "+&a" (tmp)
202                 :
203                 : "cc", "memory", "");
204         return end - s;
205 }
206 #endif
207 #else /* IN_ARCH_STRING_C */
208 void *memchr(const void * s, int c, size_t n);
209 void *memscan(void *s, int c, size_t n);
210 char *strcat(char *dst, const char *src);
211 char *strcpy(char *dst, const char *src);
212 size_t strlen(const char *s);
213 size_t strnlen(const char * s, size_t n);
214 #endif /* !IN_ARCH_STRING_C */
215 
216 #endif /* __S390_STRING_H_ */
217 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php