Path: blob/main/system/lib/llvm-libc/src/string/memchr.cpp
6175 views
//===-- Implementation of memchr ------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "src/string/memchr.h"9#include "src/__support/macros/config.h"10#include "src/__support/macros/null_check.h"11#include "src/string/string_utils.h"1213#include "src/__support/common.h"14#include <stddef.h>1516namespace LIBC_NAMESPACE_DECL {1718// TODO: Look at performance benefits of comparing words.19LLVM_LIBC_FUNCTION(void *, memchr, (const void *src, int c, size_t n)) {20if (n)21LIBC_CRASH_ON_NULLPTR(src);22return internal::find_first_character(23reinterpret_cast<const unsigned char *>(src),24static_cast<unsigned char>(c), n);25}2627} // namespace LIBC_NAMESPACE_DECL282930