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

Joseph Huber via libc-commits libc-commits at lists.llvm.org
Mon Jan 6 13:17:56 PST 2025


================
@@ -0,0 +1,37 @@
+//===-- Implementation of wcspbrk -----------------------------------------===//
+//
+// 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/wcspbrk.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+#include "wcslen.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(const wchar_t *, wcspbrk,
+                   (const wchar_t *wcs, const wchar_t *accept)) {
+  size_t n_accept = wcslen(accept);
+
+  for (size_t i = 0; i < wcslen(wcs); i++) {
----------------
jhuber6 wrote:

Yes, the LLVM libc's written in such a way that entrypoints should be independent from eachother. The correct way to do this is to move the function into an internal utility header and then make both call that instead.

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


More information about the libc-commits mailing list