License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 21:07:57 +07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2005-04-17 05:20:36 +07:00
|
|
|
/*
|
|
|
|
* Optimized string functions
|
|
|
|
*
|
|
|
|
* S390 version
|
2012-07-20 16:15:04 +07:00
|
|
|
* Copyright IBM Corp. 2004
|
2005-04-17 05:20:36 +07:00
|
|
|
* Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define IN_ARCH_STRING_C 1
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
2017-02-10 03:20:25 +07:00
|
|
|
#include <linux/string.h>
|
|
|
|
#include <linux/export.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Helper functions to find the end of a string
|
|
|
|
*/
|
|
|
|
static inline char *__strend(const char *s)
|
|
|
|
{
|
|
|
|
register unsigned long r0 asm("0") = 0;
|
|
|
|
|
|
|
|
asm volatile ("0: srst %0,%1\n"
|
|
|
|
" jo 0b"
|
2016-12-13 15:50:30 +07:00
|
|
|
: "+d" (r0), "+a" (s) : : "cc", "memory");
|
2005-04-17 05:20:36 +07:00
|
|
|
return (char *) r0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline char *__strnend(const char *s, size_t n)
|
|
|
|
{
|
|
|
|
register unsigned long r0 asm("0") = 0;
|
|
|
|
const char *p = s + n;
|
|
|
|
|
|
|
|
asm volatile ("0: srst %0,%1\n"
|
|
|
|
" jo 0b"
|
2016-12-13 15:50:30 +07:00
|
|
|
: "+d" (p), "+a" (s) : "d" (r0) : "cc", "memory");
|
2005-04-17 05:20:36 +07:00
|
|
|
return (char *) p;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* strlen - Find the length of a string
|
|
|
|
* @s: The string to be sized
|
|
|
|
*
|
|
|
|
* returns the length of @s
|
|
|
|
*/
|
2018-12-13 21:53:48 +07:00
|
|
|
#ifdef __HAVE_ARCH_STRLEN
|
2005-04-17 05:20:36 +07:00
|
|
|
size_t strlen(const char *s)
|
|
|
|
{
|
|
|
|
return __strend(s) - s;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(strlen);
|
2018-12-13 21:53:48 +07:00
|
|
|
#endif
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2018-12-13 21:53:48 +07:00
|
|
|
#ifdef __HAVE_ARCH_STRNLEN
|
2017-10-05 00:27:09 +07:00
|
|
|
size_t strnlen(const char *s, size_t n)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
return __strnend(s, n) - s;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(strnlen);
|
2018-12-13 21:53:48 +07:00
|
|
|
#endif
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* strcpy - Copy a %NUL terminated string
|
|
|
|
* @dest: Where to copy the string to
|
|
|
|
* @src: Where to copy the string from
|
|
|
|
*
|
|
|
|
* returns a pointer to @dest
|
|
|
|
*/
|
2018-12-13 21:53:48 +07:00
|
|
|
#ifdef __HAVE_ARCH_STRCPY
|
2005-04-17 05:20:36 +07:00
|
|
|
char *strcpy(char *dest, const char *src)
|
|
|
|
{
|
|
|
|
register int r0 asm("0") = 0;
|
|
|
|
char *ret = dest;
|
|
|
|
|
|
|
|
asm volatile ("0: mvst %0,%1\n"
|
|
|
|
" jo 0b"
|
|
|
|
: "+&a" (dest), "+&a" (src) : "d" (r0)
|
|
|
|
: "cc", "memory" );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(strcpy);
|
2018-12-13 21:53:48 +07:00
|
|
|
#endif
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* strlcpy - Copy a %NUL terminated string into a sized buffer
|
|
|
|
* @dest: Where to copy the string to
|
|
|
|
* @src: Where to copy the string from
|
|
|
|
* @size: size of destination buffer
|
|
|
|
*
|
|
|
|
* Compatible with *BSD: the result is always a valid
|
|
|
|
* NUL-terminated string that fits in the buffer (unless,
|
|
|
|
* of course, the buffer size is zero). It does not pad
|
|
|
|
* out the result like strncpy() does.
|
|
|
|
*/
|
2018-12-13 21:53:48 +07:00
|
|
|
#ifdef __HAVE_ARCH_STRLCPY
|
2005-04-17 05:20:36 +07:00
|
|
|
size_t strlcpy(char *dest, const char *src, size_t size)
|
|
|
|
{
|
|
|
|
size_t ret = __strend(src) - src;
|
|
|
|
|
|
|
|
if (size) {
|
|
|
|
size_t len = (ret >= size) ? size-1 : ret;
|
|
|
|
dest[len] = '\0';
|
2012-08-14 18:20:20 +07:00
|
|
|
memcpy(dest, src, len);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(strlcpy);
|
2018-12-13 21:53:48 +07:00
|
|
|
#endif
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* strncpy - Copy a length-limited, %NUL-terminated string
|
|
|
|
* @dest: Where to copy the string to
|
|
|
|
* @src: Where to copy the string from
|
|
|
|
* @n: The maximum number of bytes to copy
|
|
|
|
*
|
|
|
|
* The result is not %NUL-terminated if the source exceeds
|
|
|
|
* @n bytes.
|
|
|
|
*/
|
2018-12-13 21:53:48 +07:00
|
|
|
#ifdef __HAVE_ARCH_STRNCPY
|
2005-04-17 05:20:36 +07:00
|
|
|
char *strncpy(char *dest, const char *src, size_t n)
|
|
|
|
{
|
|
|
|
size_t len = __strnend(src, n) - src;
|
2012-08-14 18:20:20 +07:00
|
|
|
memset(dest + len, 0, n - len);
|
|
|
|
memcpy(dest, src, len);
|
2005-04-17 05:20:36 +07:00
|
|
|
return dest;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(strncpy);
|
2018-12-13 21:53:48 +07:00
|
|
|
#endif
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2018-12-13 21:53:48 +07:00
|
|
|
#ifdef __HAVE_ARCH_STRCAT
|
2005-04-17 05:20:36 +07:00
|
|
|
char *strcat(char *dest, const char *src)
|
|
|
|
{
|
|
|
|
register int r0 asm("0") = 0;
|
|
|
|
unsigned long dummy;
|
|
|
|
char *ret = dest;
|
|
|
|
|
|
|
|
asm volatile ("0: srst %0,%1\n"
|
|
|
|
" jo 0b\n"
|
|
|
|
"1: mvst %0,%2\n"
|
|
|
|
" jo 1b"
|
|
|
|
: "=&a" (dummy), "+a" (dest), "+a" (src)
|
|
|
|
: "d" (r0), "0" (0UL) : "cc", "memory" );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(strcat);
|
2018-12-13 21:53:48 +07:00
|
|
|
#endif
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2018-12-13 21:53:48 +07:00
|
|
|
#ifdef __HAVE_ARCH_STRLCAT
|
2005-04-17 05:20:36 +07:00
|
|
|
size_t strlcat(char *dest, const char *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';
|
2012-08-14 18:20:20 +07:00
|
|
|
memcpy(dest, src, len);
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(strlcat);
|
2018-12-13 21:53:48 +07:00
|
|
|
#endif
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
* Note that in contrast to strncpy, strncat ensures the result is
|
|
|
|
* terminated.
|
|
|
|
*/
|
2018-12-13 21:53:48 +07:00
|
|
|
#ifdef __HAVE_ARCH_STRNCAT
|
2005-04-17 05:20:36 +07:00
|
|
|
char *strncat(char *dest, const char *src, size_t n)
|
|
|
|
{
|
|
|
|
size_t len = __strnend(src, n) - src;
|
|
|
|
char *p = __strend(dest);
|
|
|
|
|
|
|
|
p[len] = '\0';
|
2012-08-14 18:20:20 +07:00
|
|
|
memcpy(p, src, len);
|
2005-04-17 05:20:36 +07:00
|
|
|
return dest;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(strncat);
|
2018-12-13 21:53:48 +07:00
|
|
|
#endif
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* strcmp - Compare two strings
|
2017-10-05 00:27:09 +07:00
|
|
|
* @s1: One string
|
|
|
|
* @s2: Another string
|
2005-04-17 05:20:36 +07:00
|
|
|
*
|
2017-10-05 00:27:09 +07:00
|
|
|
* returns 0 if @s1 and @s2 are equal,
|
|
|
|
* < 0 if @s1 is less than @s2
|
|
|
|
* > 0 if @s1 is greater than @s2
|
2005-04-17 05:20:36 +07:00
|
|
|
*/
|
2018-12-13 21:53:48 +07:00
|
|
|
#ifdef __HAVE_ARCH_STRCMP
|
2017-10-05 00:27:09 +07:00
|
|
|
int strcmp(const char *s1, const char *s2)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
register int r0 asm("0") = 0;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
asm volatile ("0: clst %2,%3\n"
|
|
|
|
" jo 0b\n"
|
|
|
|
" je 1f\n"
|
|
|
|
" ic %0,0(%2)\n"
|
|
|
|
" ic %1,0(%3)\n"
|
|
|
|
" sr %0,%1\n"
|
|
|
|
"1:"
|
2017-10-05 00:27:09 +07:00
|
|
|
: "+d" (ret), "+d" (r0), "+a" (s1), "+a" (s2)
|
2016-12-13 15:50:30 +07:00
|
|
|
: : "cc", "memory");
|
2005-04-17 05:20:36 +07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(strcmp);
|
2018-12-13 21:53:48 +07:00
|
|
|
#endif
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* strrchr - Find the last occurrence of a character in a string
|
|
|
|
* @s: The string to be searched
|
|
|
|
* @c: The character to search for
|
|
|
|
*/
|
2018-12-13 21:53:48 +07:00
|
|
|
#ifdef __HAVE_ARCH_STRRCHR
|
2017-10-05 00:27:09 +07:00
|
|
|
char *strrchr(const char *s, int c)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
size_t len = __strend(s) - s;
|
|
|
|
|
|
|
|
if (len)
|
|
|
|
do {
|
|
|
|
if (s[len] == (char) c)
|
|
|
|
return (char *) s + len;
|
|
|
|
} while (--len > 0);
|
2006-07-12 21:41:55 +07:00
|
|
|
return NULL;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(strrchr);
|
2018-12-13 21:53:48 +07:00
|
|
|
#endif
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2016-06-20 18:07:42 +07:00
|
|
|
static inline int clcle(const char *s1, unsigned long l1,
|
2016-08-04 15:24:30 +07:00
|
|
|
const char *s2, unsigned long l2)
|
2016-06-20 18:07:42 +07:00
|
|
|
{
|
|
|
|
register unsigned long r2 asm("2") = (unsigned long) s1;
|
2016-08-04 15:24:30 +07:00
|
|
|
register unsigned long r3 asm("3") = (unsigned long) l1;
|
2016-06-20 18:07:42 +07:00
|
|
|
register unsigned long r4 asm("4") = (unsigned long) s2;
|
|
|
|
register unsigned long r5 asm("5") = (unsigned long) l2;
|
|
|
|
int cc;
|
|
|
|
|
|
|
|
asm volatile ("0: clcle %1,%3,0\n"
|
|
|
|
" jo 0b\n"
|
|
|
|
" ipm %0\n"
|
|
|
|
" srl %0,28"
|
|
|
|
: "=&d" (cc), "+a" (r2), "+a" (r3),
|
2016-12-13 15:50:30 +07:00
|
|
|
"+a" (r4), "+a" (r5) : : "cc", "memory");
|
2016-06-20 18:07:42 +07:00
|
|
|
return cc;
|
|
|
|
}
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/**
|
|
|
|
* strstr - Find the first substring in a %NUL terminated string
|
|
|
|
* @s1: The string to be searched
|
|
|
|
* @s2: The string to search for
|
|
|
|
*/
|
2018-12-13 21:53:48 +07:00
|
|
|
#ifdef __HAVE_ARCH_STRSTR
|
2017-10-05 00:27:09 +07:00
|
|
|
char *strstr(const char *s1, const char *s2)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
int l1, l2;
|
|
|
|
|
|
|
|
l2 = __strend(s2) - s2;
|
|
|
|
if (!l2)
|
|
|
|
return (char *) s1;
|
|
|
|
l1 = __strend(s1) - s1;
|
|
|
|
while (l1-- >= l2) {
|
2016-08-04 15:24:30 +07:00
|
|
|
int cc;
|
2016-06-20 18:07:42 +07:00
|
|
|
|
2016-08-04 15:24:30 +07:00
|
|
|
cc = clcle(s1, l2, s2, l2);
|
2005-04-17 05:20:36 +07:00
|
|
|
if (!cc)
|
|
|
|
return (char *) s1;
|
|
|
|
s1++;
|
|
|
|
}
|
2006-07-12 21:41:55 +07:00
|
|
|
return NULL;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(strstr);
|
2018-12-13 21:53:48 +07:00
|
|
|
#endif
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2018-12-13 21:53:48 +07:00
|
|
|
#ifdef __HAVE_ARCH_MEMCHR
|
2005-04-17 05:20:36 +07:00
|
|
|
void *memchr(const void *s, int c, size_t n)
|
|
|
|
{
|
|
|
|
register int r0 asm("0") = (char) c;
|
|
|
|
const void *ret = s + n;
|
|
|
|
|
|
|
|
asm volatile ("0: srst %0,%1\n"
|
|
|
|
" jo 0b\n"
|
|
|
|
" jl 1f\n"
|
|
|
|
" la %0,0\n"
|
|
|
|
"1:"
|
2016-12-13 15:50:30 +07:00
|
|
|
: "+a" (ret), "+&a" (s) : "d" (r0) : "cc", "memory");
|
2005-04-17 05:20:36 +07:00
|
|
|
return (void *) ret;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(memchr);
|
2018-12-13 21:53:48 +07:00
|
|
|
#endif
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* memcmp - Compare two areas of memory
|
2017-10-05 00:27:09 +07:00
|
|
|
* @s1: One area of memory
|
|
|
|
* @s2: Another area of memory
|
2005-04-17 05:20:36 +07:00
|
|
|
* @count: The size of the area.
|
|
|
|
*/
|
2018-12-13 21:53:48 +07:00
|
|
|
#ifdef __HAVE_ARCH_MEMCMP
|
2017-10-05 00:27:09 +07:00
|
|
|
int memcmp(const void *s1, const void *s2, size_t n)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2016-08-04 15:24:30 +07:00
|
|
|
int ret;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2017-10-05 00:27:09 +07:00
|
|
|
ret = clcle(s1, n, s2, n);
|
2005-04-17 05:20:36 +07:00
|
|
|
if (ret)
|
2016-08-04 15:24:30 +07:00
|
|
|
ret = ret == 1 ? -1 : 1;
|
2005-04-17 05:20:36 +07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(memcmp);
|
2018-12-13 21:53:48 +07:00
|
|
|
#endif
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2018-12-13 21:53:48 +07:00
|
|
|
#ifdef __HAVE_ARCH_MEMSCAN
|
2005-04-17 05:20:36 +07:00
|
|
|
void *memscan(void *s, int c, size_t n)
|
|
|
|
{
|
|
|
|
register int r0 asm("0") = (char) c;
|
|
|
|
const void *ret = s + n;
|
|
|
|
|
|
|
|
asm volatile ("0: srst %0,%1\n"
|
|
|
|
" jo 0b\n"
|
2016-12-13 15:50:30 +07:00
|
|
|
: "+a" (ret), "+&a" (s) : "d" (r0) : "cc", "memory");
|
2005-04-17 05:20:36 +07:00
|
|
|
return (void *) ret;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(memscan);
|
2018-12-13 21:53:48 +07:00
|
|
|
#endif
|