[clang] Avoid linking libdl unless needed
[llvm-project.git] / libc / src / string / strlen.cpp
blob0b7597ec52b6fabe4adc2ebdcd73c07beb49f67a
1 //===-- Implementation of strlen ------------------------------------------===//
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 //===----------------------------------------------------------------------===//
9 #include "src/string/strlen.h"
11 #include "src/__support/common.h"
13 namespace __llvm_libc {
15 // TODO: investigate the performance of this function.
16 // There might be potential for compiler optimization.
17 size_t LLVM_LIBC_ENTRYPOINT(strlen)(const char *src) {
18 const char *end = src;
19 while (*end != '\0')
20 ++end;
21 return end - src;
24 } // namespace __llvm_libc