aboutsummaryrefslogtreecommitdiffstats
path: root/lib/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/string.c')
-rw-r--r--lib/string.c48
1 files changed, 29 insertions, 19 deletions
diff --git a/lib/string.c b/lib/string.c
index 992bf30af759..10063300b830 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -27,14 +27,14 @@
27#include <linux/bug.h> 27#include <linux/bug.h>
28#include <linux/errno.h> 28#include <linux/errno.h>
29 29
30#ifndef __HAVE_ARCH_STRNICMP 30#ifndef __HAVE_ARCH_STRNCASECMP
31/** 31/**
32 * strnicmp - Case insensitive, length-limited string comparison 32 * strncasecmp - Case insensitive, length-limited string comparison
33 * @s1: One string 33 * @s1: One string
34 * @s2: The other string 34 * @s2: The other string
35 * @len: the maximum number of characters to compare 35 * @len: the maximum number of characters to compare
36 */ 36 */
37int strnicmp(const char *s1, const char *s2, size_t len) 37int strncasecmp(const char *s1, const char *s2, size_t len)
38{ 38{
39 /* Yes, Virginia, it had better be unsigned */ 39 /* Yes, Virginia, it had better be unsigned */
40 unsigned char c1, c2; 40 unsigned char c1, c2;
@@ -56,6 +56,14 @@ int strnicmp(const char *s1, const char *s2, size_t len)
56 } while (--len); 56 } while (--len);
57 return (int)c1 - (int)c2; 57 return (int)c1 - (int)c2;
58} 58}
59EXPORT_SYMBOL(strncasecmp);
60#endif
61#ifndef __HAVE_ARCH_STRNICMP
62#undef strnicmp
63int strnicmp(const char *s1, const char *s2, size_t len)
64{
65 return strncasecmp(s1, s2, len);
66}
59EXPORT_SYMBOL(strnicmp); 67EXPORT_SYMBOL(strnicmp);
60#endif 68#endif
61 69
@@ -73,20 +81,6 @@ int strcasecmp(const char *s1, const char *s2)
73EXPORT_SYMBOL(strcasecmp); 81EXPORT_SYMBOL(strcasecmp);
74#endif 82#endif
75 83
76#ifndef __HAVE_ARCH_STRNCASECMP
77int strncasecmp(const char *s1, const char *s2, size_t n)
78{
79 int c1, c2;
80
81 do {
82 c1 = tolower(*s1++);
83 c2 = tolower(*s2++);
84 } while ((--n > 0) && c1 == c2 && c1 != 0);
85 return c1 - c2;
86}
87EXPORT_SYMBOL(strncasecmp);
88#endif
89
90#ifndef __HAVE_ARCH_STRCPY 84#ifndef __HAVE_ARCH_STRCPY
91/** 85/**
92 * strcpy - Copy a %NUL terminated string 86 * strcpy - Copy a %NUL terminated string
@@ -604,6 +598,22 @@ void *memset(void *s, int c, size_t count)
604EXPORT_SYMBOL(memset); 598EXPORT_SYMBOL(memset);
605#endif 599#endif
606 600
601/**
602 * memzero_explicit - Fill a region of memory (e.g. sensitive
603 * keying data) with 0s.
604 * @s: Pointer to the start of the area.
605 * @count: The size of the area.
606 *
607 * memzero_explicit() doesn't need an arch-specific version as
608 * it just invokes the one of memset() implicitly.
609 */
610void memzero_explicit(void *s, size_t count)
611{
612 memset(s, 0, count);
613 OPTIMIZER_HIDE_VAR(s);
614}
615EXPORT_SYMBOL(memzero_explicit);
616
607#ifndef __HAVE_ARCH_MEMCPY 617#ifndef __HAVE_ARCH_MEMCPY
608/** 618/**
609 * memcpy - Copy one area of memory to another 619 * memcpy - Copy one area of memory to another
@@ -807,9 +817,9 @@ void *memchr_inv(const void *start, int c, size_t bytes)
807 return check_bytes8(start, value, bytes); 817 return check_bytes8(start, value, bytes);
808 818
809 value64 = value; 819 value64 = value;
810#if defined(ARCH_HAS_FAST_MULTIPLIER) && BITS_PER_LONG == 64 820#if defined(CONFIG_ARCH_HAS_FAST_MULTIPLIER) && BITS_PER_LONG == 64
811 value64 *= 0x0101010101010101; 821 value64 *= 0x0101010101010101;
812#elif defined(ARCH_HAS_FAST_MULTIPLIER) 822#elif defined(CONFIG_ARCH_HAS_FAST_MULTIPLIER)
813 value64 *= 0x01010101; 823 value64 *= 0x01010101;
814 value64 |= value64 << 32; 824 value64 |= value64 << 32;
815#else 825#else