1 Index: scripts/kallsyms.c
2 ===================================================================
3 --- scripts/kallsyms.c (revision 3266)
4 +++ scripts/kallsyms.c (working copy)
14 @@ -56,6 +54,37 @@ int token_profit[0x10000];
15 unsigned char best_table[256][2];
16 unsigned char best_table_len[256];
18 +/* memmem(), while useful, is not in POSIX, so create a local version
19 + * so we can compile on non-GNU systems (Darwin, *BSD, etc...)
21 +void *memmem(const void *haystack, size_t haystack_len,
22 + const void *needle, size_t needle_len)
25 + const char *const last_possible =
26 + (const char *)haystack + haystack_len - needle_len;
28 + /* The first occurrence of the empty string is deemed to occur at
29 + * the beginning of the string.
31 + if (needle_len == 0)
32 + return (void *)haystack;
34 + /* Sanity check, otherwise the loop might search through the whole
37 + if (haystack_len < needle_len)
40 + for (begin = (const char *)haystack; begin <= last_possible; ++begin)
41 + if (begin[0] == ((const char *)needle)[0] &&
42 + !memcmp((const void *)&begin[1],
43 + (const void *)((const char *)needle + 1),
45 + return (void *)begin;
50 static void usage(void)