1 //===-- Implementation of strchr ------------------------------------------===//
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 #include "src/string/strchr.h"
10 
11 #include "src/__support/common.h"
12 
13 namespace __llvm_libc {
14 
15 // TODO: Look at performance benefits of comparing words.
16 LLVM_LIBC_FUNCTION(char *, strchr, (const char *src, int c)) {
17   const char ch = static_cast<char>(c);
18   for (; *src && *src != ch; ++src)
19     ;
20   return *src == ch ? const_cast<char *>(src) : nullptr;
21 }
22 
23 } // namespace __llvm_libc
24