[libc-commits] [libc] [libc] wmemcmp implementation (PR #141880)
Michael Jones via libc-commits
libc-commits at lists.llvm.org
Wed May 28 16:47:23 PDT 2025
================
@@ -0,0 +1,28 @@
+//===-- Implementation of wmemcmp ------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/wchar/wmemcmp.h"
+
+#include "hdr/types/size_t.h"
+#include "hdr/types/wchar_t.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(int, wmemcmp,
+ (const wchar_t *s1, const wchar_t *s2, size_t n)) {
+ for (size_t i = 0; i < n; ++s1, ++s2, ++i) {
+ if (*s1 != *s2)
+ return (int)(*s1 - *s2);
+ }
----------------
michaelrj-google wrote:
instead of incrementing the pointers I'd recommend using `s1[i]` and `s2[i]`
https://github.com/llvm/llvm-project/pull/141880
More information about the libc-commits
mailing list