/** * strlen - Find the length of a string * @s: The string to be sized * * returns the length of @s
*/ #ifdef __HAVE_ARCH_STRLEN
size_t strlen(constchar *s)
{ return __strend(s) - s;
}
EXPORT_SYMBOL(strlen); #endif
/** * strnlen - Find the length of a length-limited string * @s: The string to be sized * @n: The maximum number of bytes to search * * returns the minimum of the length of @s and @n
*/ #ifdef __HAVE_ARCH_STRNLEN
size_t strnlen(constchar *s, size_t n)
{ return __strnend(s, n) - s;
}
EXPORT_SYMBOL(strnlen); #endif
/** * strcat - Append one %NUL-terminated string to another * @dest: The string to be appended to * @src: The string to append to it * * returns a pointer to @dest
*/ #ifdef __HAVE_ARCH_STRCAT char *strcat(char *dest, constchar *src)
{ unsignedlong dummy = 0; char *ret = dest;
/** * strlcat - Append a length-limited, %NUL-terminated string to another * @dest: The string to be appended to * @src: The string to append to it * @n: The size of the destination buffer.
*/ #ifdef __HAVE_ARCH_STRLCAT
size_t strlcat(char *dest, constchar *src, size_t n)
{
size_t dsize = __strend(dest) - dest;
size_t len = __strend(src) - src;
size_t res = dsize + len;
if (dsize < n) {
dest += dsize;
n -= dsize; if (len >= n)
len = n - 1;
dest[len] = '\0';
memcpy(dest, src, len);
} return res;
}
EXPORT_SYMBOL(strlcat); #endif
/** * strncat - Append a length-limited, %NUL-terminated string to another * @dest: The string to be appended to * @src: The string to append to it * @n: The maximum numbers of bytes to copy * * returns a pointer to @dest
*/ #ifdef __HAVE_ARCH_STRNCAT char *strncat(char *dest, constchar *src, size_t n)
{
size_t len = __strnend(src, n) - src; char *p = __strend(dest);
/** * strcmp - Compare two strings * @s1: One string * @s2: Another string * * returns 0 if @s1 and @s2 are equal, * < 0 if @s1 is less than @s2 * > 0 if @s1 is greater than @s2
*/ #ifdef __HAVE_ARCH_STRCMP int strcmp(constchar *s1, constchar *s2)
{ int ret = 0;
asmvolatile( " lghi 0,0\n" "0: clst %[s1],%[s2]\n" " jo 0b\n" " je 1f\n" " ic %[ret],0(%[s1])\n" " ic 0,0(%[s2])\n" " sr %[ret],0\n" "1:"
: [ret] "+&d" (ret), [s1] "+&a" (s1), [s2] "+&a" (s2)
:
: "cc", "memory", "0"); return ret;
}
EXPORT_SYMBOL(strcmp); #endif
/** * strstr - Find the first substring in a %NUL terminated string * @s1: The string to be searched * @s2: The string to search for
*/ #ifdef __HAVE_ARCH_STRSTR char *strstr(constchar *s1, constchar *s2)
{ int l1, l2;
l2 = __strend(s2) - s2; if (!l2) return (char *) s1;
l1 = __strend(s1) - s1; while (l1-- >= l2) { int cc;
cc = clcle(s1, l2, s2, l2); if (!cc) return (char *) s1;
s1++;
} return NULL;
}
EXPORT_SYMBOL(strstr); #endif
/** * memchr - Find a character in an area of memory. * @s: The memory area * @c: The byte to search for * @n: The size of the area. * * returns the address of the first occurrence of @c, or %NULL * if @c is not found
*/ #ifdef __HAVE_ARCH_MEMCHR void *memchr(constvoid *s, int c, size_t n)
{ constvoid *ret = s + n;
/** * memcmp - Compare two areas of memory * @s1: One area of memory * @s2: Another area of memory * @n: The size of the area.
*/ #ifdef __HAVE_ARCH_MEMCMP int memcmp(constvoid *s1, constvoid *s2, size_t n)
{ int ret;
ret = clcle(s1, n, s2, n); if (ret)
ret = ret == 1 ? -1 : 1; return ret;
}
EXPORT_SYMBOL(memcmp); #endif
/** * memscan - Find a character in an area of memory. * @s: The memory area * @c: The byte to search for * @n: The size of the area. * * returns the address of the first occurrence of @c, or 1 byte past * the area if @c is not found
*/ #ifdef __HAVE_ARCH_MEMSCAN void *memscan(void *s, int c, size_t n)
{ constvoid *ret = s + n;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.