xref: /llvm-project/libc/src/string/strncmp.cpp (revision 5ff3ff33ff930e4ec49da7910612d8a41eb068cb)
1c6d03b58SMichael Jones //===-- Implementation of strncmp -----------------------------------------===//
2c6d03b58SMichael Jones //
3c6d03b58SMichael Jones // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4c6d03b58SMichael Jones // See https://llvm.org/LICENSE.txt for license information.
5c6d03b58SMichael Jones // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6c6d03b58SMichael Jones //
7c6d03b58SMichael Jones //===----------------------------------------------------------------------===//
8c6d03b58SMichael Jones 
9c6d03b58SMichael Jones #include "src/string/strncmp.h"
10c6d03b58SMichael Jones 
11c6d03b58SMichael Jones #include "src/__support/common.h"
12*5ff3ff33SPetr Hosek #include "src/__support/macros/config.h"
131f578347SGuillaume Chatelet #include "src/string/memory_utils/inline_strcmp.h"
14f296dce7SAlex Brachet 
15c6d03b58SMichael Jones #include <stddef.h>
16c6d03b58SMichael Jones 
17*5ff3ff33SPetr Hosek namespace LIBC_NAMESPACE_DECL {
18c6d03b58SMichael Jones 
19c6d03b58SMichael Jones LLVM_LIBC_FUNCTION(int, strncmp,
20c6d03b58SMichael Jones                    (const char *left, const char *right, size_t n)) {
21f296dce7SAlex Brachet   auto comp = [](char l, char r) -> int { return l - r; };
221f578347SGuillaume Chatelet   return inline_strncmp(left, right, n, comp);
23c6d03b58SMichael Jones }
24c6d03b58SMichael Jones 
25*5ff3ff33SPetr Hosek } // namespace LIBC_NAMESPACE_DECL
26