1 //===-- str{,case}str implementation ----------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef LLVM_LIBC_SRC_STRING_MEMORY_UTILS_INLINE_STRSTR_H 10 #define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_INLINE_STRSTR_H 11 12 #include "src/__support/macros/config.h" 13 #include "src/string/memory_utils/inline_memmem.h" 14 #include "src/string/string_utils.h" 15 #include <stddef.h> 16 17 namespace LIBC_NAMESPACE_DECL { 18 19 template <typename Comp> 20 LIBC_INLINE constexpr char *inline_strstr(const char *haystack, 21 const char *needle, Comp &&comp) { 22 void *result = inline_memmem( 23 static_cast<const void *>(haystack), internal::string_length(haystack), 24 static_cast<const void *>(needle), internal::string_length(needle), comp); 25 return static_cast<char *>(result); 26 } 27 28 } // namespace LIBC_NAMESPACE_DECL 29 30 #endif // LLVM_LIBC_SRC_STRING_MEMORY_UTILS_INLINE_STRSTR_H 31