[libc-commits] [libc] [libc] add wmemchr, wcslen, wcschr, wcsrchr, wcspbrk, wcsstr (PR #121183)

Joseph Huber via libc-commits libc-commits at lists.llvm.org
Thu Jan 23 09:00:45 PST 2025


================
@@ -0,0 +1,22 @@
+//===-- Implementation of wcslen ------------------------------------------===//
+//
+// 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/wcslen.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(size_t, wcslen, (const wchar_t *s)) {
+  size_t length = 0;
+  while (s[length++])
+    ;
----------------
jhuber6 wrote:

Hm, we could possibly just template the implementation instead of using `void *`, that way the pointer arithmetic work work I'd think.

https://github.com/llvm/llvm-project/pull/121183


More information about the libc-commits mailing list