Skip to content

Commit 36ec861

Browse files
[libc] add wcschr
1 parent ed5869d commit 36ec861

File tree

8 files changed

+77
-0
lines changed

8 files changed

+77
-0
lines changed

libc/config/gpu/entrypoints.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ set(TARGET_LIBC_ENTRYPOINTS
261261
libc.src.time.nanosleep
262262

263263
# wchar.h entrypoints
264+
libc.src.wchar.wcschr
264265
libc.src.wchar.wcslen
265266
libc.src.wchar.wmemchr
266267
libc.src.wchar.wctob

libc/config/linux/aarch64/entrypoints.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ set(TARGET_LIBC_ENTRYPOINTS
349349
libc.src.unistd.write
350350

351351
# wchar.h entrypoints
352+
libc.src.wchar.wcschr
352353
libc.src.wchar.wcslen
353354
libc.src.wchar.wmemchr
354355
libc.src.wchar.wctob

libc/config/linux/riscv/entrypoints.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ set(TARGET_LIBC_ENTRYPOINTS
346346
libc.src.unistd.write
347347

348348
# wchar.h entrypoints
349+
libc.src.wchar.wcschr
349350
libc.src.wchar.wcslen
350351
libc.src.wchar.wmemchr
351352
libc.src.wchar.wctob

libc/config/linux/x86_64/entrypoints.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ set(TARGET_LIBC_ENTRYPOINTS
348348
libc.src.unistd.write
349349

350350
# wchar.h entrypoints
351+
libc.src.wchar.wcschr
351352
libc.src.wchar.wcslen
352353
libc.src.wchar.wmemchr
353354
libc.src.wchar.wctob

libc/hdrgen/yaml/wchar.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,10 @@ functions:
2828
return_type: size_t
2929
arguments:
3030
- type: const wchar_t *
31+
- name: wcschr
32+
standards:
33+
- stdc
34+
return_type: const wchar_t *
35+
arguments:
36+
- type: const wchar_t *
37+
- type: wchar_t

libc/src/wchar/CMakeLists.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,27 @@ add_entrypoint_object(
3434
libc.hdr.types.wchar_t
3535
libc.src.__support.wctype_utils
3636
)
37+
38+
add_entrypoint_object(
39+
wcslen
40+
SRCS
41+
wcslen.cpp
42+
HDRS
43+
wcslen.h
44+
DEPENDS
45+
libc.hdr.types.size_t
46+
libc.hdr.types.wchar_t
47+
libc.src.__support.wctype_utils
48+
)
49+
50+
add_entrypoint_object(
51+
wcschr
52+
SRCS
53+
wcschr.cpp
54+
HDRS
55+
wcschr.h
56+
DEPENDS
57+
.wcslen
58+
.wmemchr
59+
libc.hdr.types.wchar_t
60+
)

libc/src/wchar/wcschr.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//===-- Implementation of wcschr ------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#include "src/wchar/wcschr.h"
10+
#include "src/__support/common.h"
11+
#include "src/__support/macros/config.h"
12+
#include "wcslen.h"
13+
#include "wmemchr.h"
14+
15+
namespace LIBC_NAMESPACE_DECL {
16+
17+
LLVM_LIBC_FUNCTION(const wchar_t *, wcschr, (const wchar_t *s, wchar_t c)) {
18+
return wmemchr(s, c, wcslen(s));
19+
}
20+
21+
} // namespace LIBC_NAMESPACE_DECL

libc/src/wchar/wcschr.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//===-- Implementation header for wmemchr -----------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_LIBC_SRC_WCHAR_WCSCHR_H
10+
#define LLVM_LIBC_SRC_WCHAR_WCSCHR_H
11+
12+
#include "hdr/types/wchar_t.h"
13+
#include "src/__support/macros/config.h"
14+
15+
namespace LIBC_NAMESPACE_DECL {
16+
17+
const wchar_t *wcschr(const wchar_t *s, wchar_t c);
18+
19+
} // namespace LIBC_NAMESPACE_DECL
20+
21+
#endif // LLVM_LIBC_SRC_WCHAR_WCSCHR_H

0 commit comments

Comments
 (0)