Linux Audio

Check our new training course

Loading...
v3.5.6
  1/*
  2 *  include/asm-s390/string.h
  3 *
  4 *  S390 version
  5 *    Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
  6 *    Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
  7 */
  8
  9#ifndef _S390_STRING_H_
 10#define _S390_STRING_H_
 11
 12#ifndef _LINUX_TYPES_H
 13#include <linux/types.h>
 14#endif
 15
 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 */
 32
 33/* Prototypes for non-inlined arch strings functions. */
 34extern int memcmp(const void *, const void *, size_t);
 35extern void *memcpy(void *, const void *, size_t);
 36extern void *memset(void *, int, size_t);
 37extern int strcmp(const char *,const char *);
 38extern size_t strlcat(char *, const char *, size_t);
 39extern size_t strlcpy(char *, const char *, size_t);
 40extern char *strncat(char *, const char *, size_t);
 41extern char *strncpy(char *, const char *, size_t);
 42extern char *strrchr(const char *, int);
 43extern char *strstr(const char *, const char *);
 44
 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
 53
 54#if !defined(IN_ARCH_STRING_C)
 55
 56static inline void *memchr(const void * s, int c, size_t n)
 57{
 58	register int r0 asm("0") = (char) c;
 59	const void *ret = s + n;
 60
 61	asm volatile(
 62		"0:	srst	%0,%1\n"
 63		"	jo	0b\n"
 64		"	jl	1f\n"
 65		"	la	%0,0\n"
 66		"1:"
 67		: "+a" (ret), "+&a" (s) : "d" (r0) : "cc");
 68	return (void *) ret;
 69}
 70
 71static inline void *memscan(void *s, int c, size_t n)
 72{
 73	register int r0 asm("0") = (char) c;
 74	const void *ret = s + n;
 75
 76	asm volatile(
 77		"0:	srst	%0,%1\n"
 78		"	jo	0b\n"
 79		: "+a" (ret), "+&a" (s) : "d" (r0) : "cc");
 80	return (void *) ret;
 81}
 82
 83static inline char *strcat(char *dst, const char *src)
 84{
 85	register int r0 asm("0") = 0;
 86	unsigned long dummy;
 87	char *ret = dst;
 88
 89	asm volatile(
 90		"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;
 97}
 98
 99static inline char *strcpy(char *dst, const char *src)
100{
101#if __GNUC__ < 4
102	register int r0 asm("0") = 0;
103	char *ret = dst;
104
105	asm volatile(
106		"0:	mvst	%0,%1\n"
107		"	jo	0b"
108		: "+&a" (dst), "+&a" (src) : "d" (r0)
109		: "cc", "memory");
110	return ret;
111#else
112	return __builtin_strcpy(dst, src);
113#endif
114}
115
116static inline size_t strlen(const char *s)
117{
118#if __GNUC__ < 4
119	register unsigned long r0 asm("0") = 0;
120	const char *tmp = s;
121
122	asm volatile(
123		"0:	srst	%0,%1\n"
124		"	jo	0b"
125		: "+d" (r0), "+a" (tmp) :  : "cc");
126	return r0 - (unsigned long) s;
127#else
128	return __builtin_strlen(s);
129#endif
130}
131
132static inline size_t strnlen(const char * s, size_t n)
133{
134	register int r0 asm("0") = 0;
135	const char *tmp = s;
136	const char *end = s + n;
137
138	asm volatile(
139		"0:	srst	%0,%1\n"
140		"	jo	0b"
141		: "+a" (end), "+a" (tmp) : "d" (r0)  : "cc");
142	return end - s;
143}
144#else /* IN_ARCH_STRING_C */
145void *memchr(const void * s, int c, size_t n);
146void *memscan(void *s, int c, size_t n);
147char *strcat(char *dst, const char *src);
148char *strcpy(char *dst, const char *src);
149size_t strlen(const char *s);
150size_t strnlen(const char * s, size_t n);
151#endif /* !IN_ARCH_STRING_C */
152
153#endif /* __S390_STRING_H_ */
v3.15
  1/*
 
 
  2 *  S390 version
  3 *    Copyright IBM Corp. 1999
  4 *    Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
  5 */
  6
  7#ifndef _S390_STRING_H_
  8#define _S390_STRING_H_
  9
 10#ifndef _LINUX_TYPES_H
 11#include <linux/types.h>
 12#endif
 13
 14#define __HAVE_ARCH_MEMCHR	/* inline & arch function */
 15#define __HAVE_ARCH_MEMCMP	/* arch function */
 16#define __HAVE_ARCH_MEMCPY	/* gcc builtin & arch function */
 17#define __HAVE_ARCH_MEMSCAN	/* inline & arch function */
 18#define __HAVE_ARCH_MEMSET	/* gcc builtin & arch function */
 19#define __HAVE_ARCH_STRCAT	/* inline & arch function */
 20#define __HAVE_ARCH_STRCMP	/* arch function */
 21#define __HAVE_ARCH_STRCPY	/* inline & arch function */
 22#define __HAVE_ARCH_STRLCAT	/* arch function */
 23#define __HAVE_ARCH_STRLCPY	/* arch function */
 24#define __HAVE_ARCH_STRLEN	/* inline & arch function */
 25#define __HAVE_ARCH_STRNCAT	/* arch function */
 26#define __HAVE_ARCH_STRNCPY	/* arch function */
 27#define __HAVE_ARCH_STRNLEN	/* inline & arch function */
 28#define __HAVE_ARCH_STRRCHR	/* arch function */
 29#define __HAVE_ARCH_STRSTR	/* arch function */
 30
 31/* Prototypes for non-inlined arch strings functions. */
 32extern int memcmp(const void *, const void *, size_t);
 33extern void *memcpy(void *, const void *, size_t);
 34extern void *memset(void *, int, size_t);
 35extern int strcmp(const char *,const char *);
 36extern size_t strlcat(char *, const char *, size_t);
 37extern size_t strlcpy(char *, const char *, size_t);
 38extern char *strncat(char *, const char *, size_t);
 39extern char *strncpy(char *, const char *, size_t);
 40extern char *strrchr(const char *, int);
 41extern char *strstr(const char *, const char *);
 42
 43#undef __HAVE_ARCH_MEMMOVE
 44#undef __HAVE_ARCH_STRCHR
 45#undef __HAVE_ARCH_STRNCHR
 46#undef __HAVE_ARCH_STRNCMP
 47#undef __HAVE_ARCH_STRNICMP
 48#undef __HAVE_ARCH_STRPBRK
 49#undef __HAVE_ARCH_STRSEP
 50#undef __HAVE_ARCH_STRSPN
 51
 52#if !defined(IN_ARCH_STRING_C)
 53
 54static inline void *memchr(const void * s, int c, size_t n)
 55{
 56	register int r0 asm("0") = (char) c;
 57	const void *ret = s + n;
 58
 59	asm volatile(
 60		"0:	srst	%0,%1\n"
 61		"	jo	0b\n"
 62		"	jl	1f\n"
 63		"	la	%0,0\n"
 64		"1:"
 65		: "+a" (ret), "+&a" (s) : "d" (r0) : "cc");
 66	return (void *) ret;
 67}
 68
 69static inline void *memscan(void *s, int c, size_t n)
 70{
 71	register int r0 asm("0") = (char) c;
 72	const void *ret = s + n;
 73
 74	asm volatile(
 75		"0:	srst	%0,%1\n"
 76		"	jo	0b\n"
 77		: "+a" (ret), "+&a" (s) : "d" (r0) : "cc");
 78	return (void *) ret;
 79}
 80
 81static inline char *strcat(char *dst, const char *src)
 82{
 83	register int r0 asm("0") = 0;
 84	unsigned long dummy;
 85	char *ret = dst;
 86
 87	asm volatile(
 88		"0:	srst	%0,%1\n"
 89		"	jo	0b\n"
 90		"1:	mvst	%0,%2\n"
 91		"	jo	1b"
 92		: "=&a" (dummy), "+a" (dst), "+a" (src)
 93		: "d" (r0), "0" (0) : "cc", "memory" );
 94	return ret;
 95}
 96
 97static inline char *strcpy(char *dst, const char *src)
 98{
 
 99	register int r0 asm("0") = 0;
100	char *ret = dst;
101
102	asm volatile(
103		"0:	mvst	%0,%1\n"
104		"	jo	0b"
105		: "+&a" (dst), "+&a" (src) : "d" (r0)
106		: "cc", "memory");
107	return ret;
 
 
 
108}
109
110static inline size_t strlen(const char *s)
111{
 
112	register unsigned long r0 asm("0") = 0;
113	const char *tmp = s;
114
115	asm volatile(
116		"0:	srst	%0,%1\n"
117		"	jo	0b"
118		: "+d" (r0), "+a" (tmp) :  : "cc");
119	return r0 - (unsigned long) s;
 
 
 
120}
121
122static inline size_t strnlen(const char * s, size_t n)
123{
124	register int r0 asm("0") = 0;
125	const char *tmp = s;
126	const char *end = s + n;
127
128	asm volatile(
129		"0:	srst	%0,%1\n"
130		"	jo	0b"
131		: "+a" (end), "+a" (tmp) : "d" (r0)  : "cc");
132	return end - s;
133}
134#else /* IN_ARCH_STRING_C */
135void *memchr(const void * s, int c, size_t n);
136void *memscan(void *s, int c, size_t n);
137char *strcat(char *dst, const char *src);
138char *strcpy(char *dst, const char *src);
139size_t strlen(const char *s);
140size_t strnlen(const char * s, size_t n);
141#endif /* !IN_ARCH_STRING_C */
142
143#endif /* __S390_STRING_H_ */