-/* Copyright (C) 1991-2012 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
#ifndef _LIBC
# define __builtin_expect(expr, val) (expr)
+# define __memmem memmem
#endif
#define RETURN_TYPE void *
#define AVAILABLE(h, h_l, j, n_l) ((j) <= (h_l) - (n_l))
+#define FASTSEARCH(S,C,N) (void*) memchr ((void *)(S), (C), (N))
#include "str-two-way.h"
#undef memmem
if NEEDLE_LEN is 0, otherwise NULL if NEEDLE is not found in
HAYSTACK. */
void *
-memmem (const void *haystack_start, size_t haystack_len,
- const void *needle_start, size_t needle_len)
+__memmem (const void *haystack_start, size_t haystack_len,
+ const void *needle_start, size_t needle_len)
{
/* Abstract memory is considered to be an array of 'unsigned char' values,
not an array of 'char' values. See ISO C 99 section 6.2.6.1. */
/* Sanity check, otherwise the loop might search through the whole
memory. */
- if (__builtin_expect (haystack_len < needle_len, 0))
+ if (__glibc_unlikely (haystack_len < needle_len))
return NULL;
/* Use optimizations in memchr when possible, to reduce the search
else
return two_way_long_needle (haystack, haystack_len, needle, needle_len);
}
-libc_hidden_def (memmem)
+libc_hidden_def (__memmem)
+weak_alias (__memmem, memmem)
+libc_hidden_weak (memmem)
#undef LONG_NEEDLE_THRESHOLD