diff --git a/libc/src/string/CMakeLists.txt b/libc/src/string/CMakeLists.txt --- a/libc/src/string/CMakeLists.txt +++ b/libc/src/string/CMakeLists.txt @@ -145,6 +145,8 @@ strcoll.cpp HDRS strcoll.h + DEPENDS + .memory_utils.strcmp_implementation ) add_entrypoint_object( diff --git a/libc/src/string/strcoll.cpp b/libc/src/string/strcoll.cpp --- a/libc/src/string/strcoll.cpp +++ b/libc/src/string/strcoll.cpp @@ -9,14 +9,16 @@ #include "src/string/strcoll.h" #include "src/__support/common.h" +#include "src/string/memory_utils/strcmp_implementations.h" namespace __llvm_libc { // TODO: Add support for locales. LLVM_LIBC_FUNCTION(int, strcoll, (const char *left, const char *right)) { - for (; *left && *left == *right; ++left, ++right) - ; - return static_cast(*left) - static_cast(*right); + auto comp = [](char l, char r) -> int { + return static_cast(l) - static_cast(r); + }; + return strcmp_implementation(left, right, comp); } } // namespace __llvm_libc