hc
2023-12-06 08f87f769b595151be1afeff53e144f543faa614
kernel/arch/s390/lib/string.c
....@@ -43,11 +43,13 @@
4343 *
4444 * returns the length of @s
4545 */
46
+#ifdef __HAVE_ARCH_STRLEN
4647 size_t strlen(const char *s)
4748 {
4849 return __strend(s) - s;
4950 }
5051 EXPORT_SYMBOL(strlen);
52
+#endif
5153
5254 /**
5355 * strnlen - Find the length of a length-limited string
....@@ -56,11 +58,13 @@
5658 *
5759 * returns the minimum of the length of @s and @n
5860 */
61
+#ifdef __HAVE_ARCH_STRNLEN
5962 size_t strnlen(const char *s, size_t n)
6063 {
6164 return __strnend(s, n) - s;
6265 }
6366 EXPORT_SYMBOL(strnlen);
67
+#endif
6468
6569 /**
6670 * strcpy - Copy a %NUL terminated string
....@@ -69,6 +73,7 @@
6973 *
7074 * returns a pointer to @dest
7175 */
76
+#ifdef __HAVE_ARCH_STRCPY
7277 char *strcpy(char *dest, const char *src)
7378 {
7479 register int r0 asm("0") = 0;
....@@ -81,6 +86,7 @@
8186 return ret;
8287 }
8388 EXPORT_SYMBOL(strcpy);
89
+#endif
8490
8591 /**
8692 * strlcpy - Copy a %NUL terminated string into a sized buffer
....@@ -93,6 +99,7 @@
9399 * of course, the buffer size is zero). It does not pad
94100 * out the result like strncpy() does.
95101 */
102
+#ifdef __HAVE_ARCH_STRLCPY
96103 size_t strlcpy(char *dest, const char *src, size_t size)
97104 {
98105 size_t ret = __strend(src) - src;
....@@ -105,6 +112,7 @@
105112 return ret;
106113 }
107114 EXPORT_SYMBOL(strlcpy);
115
+#endif
108116
109117 /**
110118 * strncpy - Copy a length-limited, %NUL-terminated string
....@@ -115,6 +123,7 @@
115123 * The result is not %NUL-terminated if the source exceeds
116124 * @n bytes.
117125 */
126
+#ifdef __HAVE_ARCH_STRNCPY
118127 char *strncpy(char *dest, const char *src, size_t n)
119128 {
120129 size_t len = __strnend(src, n) - src;
....@@ -123,6 +132,7 @@
123132 return dest;
124133 }
125134 EXPORT_SYMBOL(strncpy);
135
+#endif
126136
127137 /**
128138 * strcat - Append one %NUL-terminated string to another
....@@ -131,6 +141,7 @@
131141 *
132142 * returns a pointer to @dest
133143 */
144
+#ifdef __HAVE_ARCH_STRCAT
134145 char *strcat(char *dest, const char *src)
135146 {
136147 register int r0 asm("0") = 0;
....@@ -146,6 +157,7 @@
146157 return ret;
147158 }
148159 EXPORT_SYMBOL(strcat);
160
+#endif
149161
150162 /**
151163 * strlcat - Append a length-limited, %NUL-terminated string to another
....@@ -153,6 +165,7 @@
153165 * @src: The string to append to it
154166 * @n: The size of the destination buffer.
155167 */
168
+#ifdef __HAVE_ARCH_STRLCAT
156169 size_t strlcat(char *dest, const char *src, size_t n)
157170 {
158171 size_t dsize = __strend(dest) - dest;
....@@ -170,6 +183,7 @@
170183 return res;
171184 }
172185 EXPORT_SYMBOL(strlcat);
186
+#endif
173187
174188 /**
175189 * strncat - Append a length-limited, %NUL-terminated string to another
....@@ -182,6 +196,7 @@
182196 * Note that in contrast to strncpy, strncat ensures the result is
183197 * terminated.
184198 */
199
+#ifdef __HAVE_ARCH_STRNCAT
185200 char *strncat(char *dest, const char *src, size_t n)
186201 {
187202 size_t len = __strnend(src, n) - src;
....@@ -192,6 +207,7 @@
192207 return dest;
193208 }
194209 EXPORT_SYMBOL(strncat);
210
+#endif
195211
196212 /**
197213 * strcmp - Compare two strings
....@@ -202,6 +218,7 @@
202218 * < 0 if @s1 is less than @s2
203219 * > 0 if @s1 is greater than @s2
204220 */
221
+#ifdef __HAVE_ARCH_STRCMP
205222 int strcmp(const char *s1, const char *s2)
206223 {
207224 register int r0 asm("0") = 0;
....@@ -219,12 +236,14 @@
219236 return ret;
220237 }
221238 EXPORT_SYMBOL(strcmp);
239
+#endif
222240
223241 /**
224242 * strrchr - Find the last occurrence of a character in a string
225243 * @s: The string to be searched
226244 * @c: The character to search for
227245 */
246
+#ifdef __HAVE_ARCH_STRRCHR
228247 char *strrchr(const char *s, int c)
229248 {
230249 ssize_t len = __strend(s) - s;
....@@ -236,6 +255,7 @@
236255 return NULL;
237256 }
238257 EXPORT_SYMBOL(strrchr);
258
+#endif
239259
240260 static inline int clcle(const char *s1, unsigned long l1,
241261 const char *s2, unsigned long l2)
....@@ -260,6 +280,7 @@
260280 * @s1: The string to be searched
261281 * @s2: The string to search for
262282 */
283
+#ifdef __HAVE_ARCH_STRSTR
263284 char *strstr(const char *s1, const char *s2)
264285 {
265286 int l1, l2;
....@@ -279,6 +300,7 @@
279300 return NULL;
280301 }
281302 EXPORT_SYMBOL(strstr);
303
+#endif
282304
283305 /**
284306 * memchr - Find a character in an area of memory.
....@@ -289,6 +311,7 @@
289311 * returns the address of the first occurrence of @c, or %NULL
290312 * if @c is not found
291313 */
314
+#ifdef __HAVE_ARCH_MEMCHR
292315 void *memchr(const void *s, int c, size_t n)
293316 {
294317 register int r0 asm("0") = (char) c;
....@@ -303,13 +326,15 @@
303326 return (void *) ret;
304327 }
305328 EXPORT_SYMBOL(memchr);
329
+#endif
306330
307331 /**
308332 * memcmp - Compare two areas of memory
309333 * @s1: One area of memory
310334 * @s2: Another area of memory
311
- * @count: The size of the area.
335
+ * @n: The size of the area.
312336 */
337
+#ifdef __HAVE_ARCH_MEMCMP
313338 int memcmp(const void *s1, const void *s2, size_t n)
314339 {
315340 int ret;
....@@ -320,6 +345,7 @@
320345 return ret;
321346 }
322347 EXPORT_SYMBOL(memcmp);
348
+#endif
323349
324350 /**
325351 * memscan - Find a character in an area of memory.
....@@ -330,6 +356,7 @@
330356 * returns the address of the first occurrence of @c, or 1 byte past
331357 * the area if @c is not found
332358 */
359
+#ifdef __HAVE_ARCH_MEMSCAN
333360 void *memscan(void *s, int c, size_t n)
334361 {
335362 register int r0 asm("0") = (char) c;
....@@ -341,3 +368,4 @@
341368 return (void *) ret;
342369 }
343370 EXPORT_SYMBOL(memscan);
371
+#endif