opnsense-src/lib/libc/string
Ed Maste 88521634e9 libc: Use musl's O(n) memmem and strstr
It is O(n) in the length of the haystack (big) string, and has special
cases for short needle (little) strings, of one to four bytes, to avoid
excessive overhead.

There are a small set of nearly trivial cases where the startup overhead
of the musl implementation makes it slightly slower -- for example, a 31
byte needle that matches the beginning of the haystack.  It's faster for
non-trivial cases, and significantly so for inputs that trigger worst-
case behaviour of the previous implementation.  As an example, in my
tests a 16K needle that matches the end of a 64K haystack is nearly
2000x faster with this implementation.

Reviewed by:	bapt (earlier), ed (earlier)
Obtained from:	musl (snapshot at commit c718f9fc)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D2601
2017-03-18 00:51:39 +00:00
..
bcmp.3 Add timingsafe_bcmp and timingsafe_memcmp. 2016-08-14 23:38:50 +00:00
bcmp.c Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
bcopy.3 Fix spelling. 2015-08-24 01:53:18 +00:00
bcopy.c Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
bstring.3 Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
bzero.3 Update bzero(3) manpage to following the Posix Standard. 2015-08-24 01:51:10 +00:00
bzero.c Fix the style of the SCM ID's. 2002-03-22 21:53:29 +00:00
ffs.3 Document bitset(9) 2015-10-17 19:55:58 +00:00
ffs.c Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
ffsl.c Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
ffsll.c Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
fls.c Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
flsl.c Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
flsll.c Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
index.3 Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
Makefile.inc Replace dot-dot relative pathing with SRCTOP-relative paths where possible 2017-01-20 03:23:24 +00:00
memccpy.3 Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
memccpy.c Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
memchr.3 Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
memchr.c Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
memcmp.3 Add timingsafe_bcmp and timingsafe_memcmp. 2016-08-14 23:38:50 +00:00
memcmp.c Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
memcpy.3 Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
memcpy.c Fix the style of the SCM ID's. 2002-03-22 21:53:29 +00:00
memmem.3 libc: Use musl's O(n) memmem and strstr 2017-03-18 00:51:39 +00:00
memmem.c libc: Use musl's O(n) memmem and strstr 2017-03-18 00:51:39 +00:00
memmove.3 Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
memmove.c Fix the style of the SCM ID's. 2002-03-22 21:53:29 +00:00
memrchr.c Add memrchr(3). 2008-04-10 00:12:44 +00:00
memset.3 Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
memset.c Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
stpcpy.c Add restrict qualifiers. 2009-02-28 06:05:37 +00:00
stpncpy.c - Add getdelim(), getline(), stpncpy(), strnlen(), wcsnlen(), 2009-02-28 06:00:58 +00:00
strcasecmp.3 Fix strcasecmp_l() and strncasecmp_l() POSIX 2008 compliance. 2014-05-30 01:09:07 +00:00
strcasecmp.c Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
strcasestr.c Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
strcat.3 libc man pages: Remove reference to non-existent FreeBSD Security 2014-03-07 15:35:54 +00:00
strcat.c Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
strchr.3 strchr(3): Mdoc fixes. 2015-06-04 21:54:46 +00:00
strchr.c Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
strchrnul.c Add declaration to eliminate -Wmissing-prototypes warning. 2015-09-20 03:51:15 +00:00
strcmp.3 Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
strcmp.c Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
strcoll.3 Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
strcoll.c Fix typo 2015-08-09 00:19:14 +00:00
strcpy.3 libc man pages: Remove reference to non-existent FreeBSD Security 2014-03-07 15:35:54 +00:00
strcpy.c Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
strcspn.c Replace the current strspn() and strcspn() with significantly faster 2005-04-02 18:52:44 +00:00
strdup.3 Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
strdup.c Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
strerror.3 use .Mt to mark up email addresses consistently (part4) 2014-06-23 08:25:03 +00:00
strerror.c libc: Always use our own copy of sys_errlist and sys_nerr (.so only). 2013-08-31 22:32:42 +00:00
string.3 Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
strlcat.c Make strlcpy/strlcat slightly easier to read. 2015-04-06 03:21:22 +00:00
strlcpy.3 Make it clear that the "size" argument is for the dst string. 2016-02-26 22:14:19 +00:00
strlcpy.c Make strlcpy/strlcat slightly easier to read. 2015-04-06 03:21:22 +00:00
strlen.3 Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
strlen.c Correct bugs fixed but not merged from my own tree. 2010-03-13 00:15:06 +00:00
strmode.3 Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
strmode.c Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
strncat.c Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
strncmp.c Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
strncpy.c Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
strndup.c Replace strndup with OpenBSD's implementation. 2015-08-26 23:28:10 +00:00
strnlen.c - Add getdelim(), getline(), stpncpy(), strnlen(), wcsnlen(), 2009-02-28 06:00:58 +00:00
strnstr.c Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
strpbrk.3 Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
strpbrk.c Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
strrchr.c Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
strsep.3 Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
strsep.c Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
strsignal.c Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
strspn.3 Various mdoc fixes and a few EOL whitespace removals. 2014-12-21 12:36:36 +00:00
strspn.c Replace the current strspn() and strcspn() with significantly faster 2005-04-02 18:52:44 +00:00
strstr.3 Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
strstr.c libc: Use musl's O(n) memmem and strstr 2017-03-18 00:51:39 +00:00
strtok.3 Add a standards compliance note for strtok_r as suggested by cpercival. 2016-01-22 20:36:03 +00:00
strtok.c Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
strxfrm.3 Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
strxfrm.c Fix typo 2015-08-09 00:19:14 +00:00
swab.3 Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
swab.c Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
Symbol.map Add timingsafe_bcmp and timingsafe_memcmp. 2016-08-14 23:38:50 +00:00
timingsafe_bcmp.3 Add timingsafe_bcmp and timingsafe_memcmp. 2016-08-14 23:38:50 +00:00
timingsafe_bcmp.c Add timingsafe_bcmp and timingsafe_memcmp. 2016-08-14 23:38:50 +00:00
timingsafe_memcmp.c Add timingsafe_bcmp and timingsafe_memcmp. 2016-08-14 23:38:50 +00:00
wcpcpy.c Add wcpcpy(3) and wcpncpy(3). 2009-03-04 06:01:27 +00:00
wcpncpy.c Add wcpcpy(3) and wcpncpy(3). 2009-03-04 06:01:27 +00:00
wcscasecmp.c - Add getdelim(), getline(), stpncpy(), strnlen(), wcsnlen(), 2009-02-28 06:00:58 +00:00
wcscat.c - ANSIfy function definitions 2009-02-03 17:58:20 +00:00
wcschr.c Reimplement, handling the case where c == L'\0' correctly and fixing 2002-10-23 10:47:47 +00:00
wcscmp.c Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
wcscoll.3 Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
wcscoll.c libc: spelling fixes. 2016-04-30 01:24:24 +00:00
wcscpy.c - ANSIfy function definitions 2009-02-03 17:58:20 +00:00
wcscspn.c - ANSIfy function definitions 2009-02-03 17:58:20 +00:00
wcsdup.c Add an implementation of the semi-standard wcsdup() function, as found 2005-08-13 05:54:33 +00:00
wcslcat.c Avoid reading pass the end of the source buffer when it is not NUL 2016-01-13 21:50:08 +00:00
wcslcpy.c - ANSIfy function definitions 2009-02-03 17:58:20 +00:00
wcslen.c - ANSIfy function definitions 2009-02-03 17:58:20 +00:00
wcsncasecmp.c - Add getdelim(), getline(), stpncpy(), strnlen(), wcsnlen(), 2009-02-28 06:00:58 +00:00
wcsncat.c Avoid reading pass the end of the source buffer when it is not NUL 2016-01-13 21:49:01 +00:00
wcsncmp.c Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
wcsncpy.c Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
wcsnlen.c - Add getdelim(), getline(), stpncpy(), strnlen(), wcsnlen(), 2009-02-28 06:00:58 +00:00
wcspbrk.c - ANSIfy function definitions 2009-02-03 17:58:20 +00:00
wcsrchr.c Reimplement more efficiently, using a single forward scan (like strrchr(3)) 2002-10-23 10:52:04 +00:00
wcsspn.c - ANSIfy function definitions 2009-02-03 17:58:20 +00:00
wcsstr.c Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
wcstok.3 Remove stray comma at the end of the See Also list. 2002-10-15 09:49:54 +00:00
wcstok.c Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
wcswidth.3 mdoc(7) police: tiny nits. 2002-12-09 14:04:05 +00:00
wcswidth.c Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
wcsxfrm.3 Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
wcsxfrm.c The collate functions within libc have been using version 1 and 1.2 of the 2015-08-07 23:41:26 +00:00
wmemchr.3 Renumber clauses to reduce diffs to other versions 2013-05-28 20:57:40 +00:00
wmemchr.c - ANSIfy function definitions 2009-02-03 17:58:20 +00:00
wmemcmp.c - ANSIfy function definitions 2009-02-03 17:58:20 +00:00
wmemcpy.c - ANSIfy function definitions 2009-02-03 17:58:20 +00:00
wmemmove.c - ANSIfy function definitions 2009-02-03 17:58:20 +00:00
wmemset.c Fix the functions to match prototypes. The K&R definitions differ 2009-02-03 20:25:36 +00:00