File tree Expand file tree Collapse file tree 8 files changed +72
-0
lines changed Expand file tree Collapse file tree 8 files changed +72
-0
lines changed Original file line number Diff line number Diff line change @@ -261,6 +261,7 @@ set(TARGET_LIBC_ENTRYPOINTS
261
261
libc.src.time.nanosleep
262
262
263
263
# wchar.h entrypoints
264
+ libc.src.wchar.wmemchr
264
265
libc.src.wchar.wctob
265
266
266
267
# locale.h entrypoints
Original file line number Diff line number Diff line change @@ -349,6 +349,7 @@ set(TARGET_LIBC_ENTRYPOINTS
349
349
libc.src.unistd.write
350
350
351
351
# wchar.h entrypoints
352
+ libc.src.wchar.wmemchr
352
353
libc.src.wchar.wctob
353
354
)
354
355
Original file line number Diff line number Diff line change @@ -346,6 +346,7 @@ set(TARGET_LIBC_ENTRYPOINTS
346
346
libc.src.unistd.write
347
347
348
348
# wchar.h entrypoints
349
+ libc.src.wchar.wmemchr
349
350
libc.src.wchar.wctob
350
351
)
351
352
Original file line number Diff line number Diff line change @@ -348,6 +348,7 @@ set(TARGET_LIBC_ENTRYPOINTS
348
348
libc.src.unistd.write
349
349
350
350
# wchar.h entrypoints
351
+ libc.src.wchar.wmemchr
351
352
libc.src.wchar.wctob
352
353
libc.src.wchar.btowc
353
354
)
Original file line number Diff line number Diff line change @@ -14,3 +14,11 @@ functions:
14
14
return_type : int
15
15
arguments :
16
16
- type : wint_t
17
+ - name : wmemchr
18
+ standards :
19
+ - stdc
20
+ return_type : const wchar_t *
21
+ arguments :
22
+ - type : const wchar_t *
23
+ - type : wchar_t
24
+ - type : size_t
Original file line number Diff line number Diff line change @@ -22,3 +22,15 @@ add_entrypoint_object(
22
22
libc.hdr.wchar_macros
23
23
libc.src.__support.wctype_utils
24
24
)
25
+
26
+ add_entrypoint_object (
27
+ wmemchr
28
+ SRCS
29
+ wmemchr.cpp
30
+ HDRS
31
+ wmemchr.h
32
+ DEPENDS
33
+ libc.hdr.types.size_t
34
+ libc.hdr.types.wchar_t
35
+ libc.src.__support.wctype_utils
36
+ )
Original file line number Diff line number Diff line change
1
+ // ===-- Implementation of wmemchr -----------------------------------------===//
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/wmemchr.h"
10
+ #include " src/__support/common.h"
11
+ #include " src/__support/macros/config.h"
12
+
13
+ namespace LIBC_NAMESPACE_DECL {
14
+
15
+ LLVM_LIBC_FUNCTION (const wchar_t *, wmemchr,
16
+ (const wchar_t *s, wchar_t c, size_t n)) {
17
+ for (size_t i = 0 ; i < n; i++) {
18
+ if (s[i] == c) {
19
+ return &s[i];
20
+ }
21
+ }
22
+
23
+ return nullptr ;
24
+ }
25
+
26
+ } // namespace LIBC_NAMESPACE_DECL
Original file line number Diff line number Diff line change
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_WMEMCHR_H
10
+ #define LLVM_LIBC_SRC_WCHAR_WMEMCHR_H
11
+
12
+ #include " hdr/types/size_t.h"
13
+ #include " hdr/types/wchar_t.h"
14
+ #include " src/__support/macros/config.h"
15
+
16
+ namespace LIBC_NAMESPACE_DECL {
17
+
18
+ const wchar_t *wmemchr (const wchar_t *s, wchar_t c, size_t n);
19
+
20
+ } // namespace LIBC_NAMESPACE_DECL
21
+
22
+ #endif // LLVM_LIBC_SRC_WCHAR_WMEMCHR_H
You can’t perform that action at this time.
0 commit comments