summaryrefslogtreecommitdiff
path: root/libc/src/string/memmem.cpp
blob: eed1d38a6ac68241be40465640126fbe55f8db80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//===-- Implementation of memmem ------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "src/string/memmem.h"
#include "src/__support/common.h"
#include "src/string/memory_utils/memmem_implementations.h"

namespace __llvm_libc {

LLVM_LIBC_FUNCTION(void *, memmem,
                   (const void *haystack, size_t haystack_len,
                    const void *needle, size_t needle_len)) {
  constexpr auto comp = [](unsigned char l, unsigned char r) -> int {
    return l - r;
  };
  return memmem_implementation(haystack, haystack_len, needle, needle_len,
                               comp);
}

} // namespace __llvm_libc