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 //===----------------------------------------------------------------------===// 8 9 #include "src/string/strlen.h" 10 11 #include "src/__support/common.h" 12 13 namespace __llvm_libc { 14 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; 22 } 23 24 } // namespace __llvm_libc 25