Coverage Report

Created: 2017-04-15 07:07

/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
8
#if defined(_WIN32) || defined(__APPLE__) || defined(__Darwin__)
9
#include "../3rdparty/freebsd/memmem.c"
10
#else
11
/* On systems that use glibc, you must define _GNU_SOURCE before including string.h
12
 * to get access to memmem. */
13
#define _GNU_SOURCE
14
#include <string.h>
15
#endif
16
17
362k
void * MVM_memmem(const void *haystack, size_t haystacklen, const void *needle, size_t needlelen) {
18
362k
    return memmem(haystack, haystacklen, needle, needlelen);
19
362k
}
20
21
/* Extended info:
22
 * In glibc, the Knuth-Morris-Pratt algorithm was added as of git tag glibc-2.8-44-g0caca71ac9 */