Coverage Report

Created: 2018-07-03 15:31

/home/travis/build/MoarVM/MoarVM/src/platform/memmem.h
Line
Count
Source
1
/* On Linux we use glibc's memmem which uses the Knuth-Morris-Pratt algorithm.
2
 * We use FreeBSD's libc memmem on Windows and MacOS, which uses
3
 * Crochemore-Perrin two-way string matching.
4
 * Reasoning:
5
 * Windows, does not include any native memmem
6
 * MacOS has a memmem but is slower and originates from FreeBSD dated to 2005
7
 * Solaris doesn't seem to have memmem                                        */
8
9
#if defined(_WIN32) || defined(__APPLE__) || defined(__Darwin__) || defined(__sun)
10
#include "../3rdparty/freebsd/memmem.c"
11
#else
12
/* On systems that use glibc, you must define _GNU_SOURCE before including string.h
13
 * to get access to memmem. */
14
#define _GNU_SOURCE
15
#include <string.h>
16
#endif
17
18
438k
void * MVM_memmem(const void *haystack, size_t haystacklen, const void *needle, size_t needlelen) {
19
438k
    return memmem(haystack, haystacklen, needle, needlelen);
20
438k
}
21
22
/* Extended info:
23
 * In glibc, the Knuth-Morris-Pratt algorithm was added as of git tag glibc-2.8-44-g0caca71ac9 */