Skip to content

Commit 5757dce

Browse files
author
Sriya Pratipati
committed
started mbstowcs implementation
1 parent b64d7ba commit 5757dce

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

libc/src/wchar/mbstowcs.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//===-- Implementation of mbstowcs ----------------------------------------===//
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/mbstowcs.h"
10+
11+
#include "hdr/types/size_t.h"
12+
#include "hdr/types/wchar_t.h"
13+
#include "src/__support/common.h"
14+
#include "src/__support/libc_errno.h"
15+
#include "src/__support/macros/config.h"
16+
#include "src/__support/wchar/mbstate.h"
17+
#include "src/__support/wchar/string_converter.h"
18+
19+
namespace LIBC_NAMESPACE_DECL {
20+
21+
LLVM_LIBC_FUNCTION(int, mbstowcs,
22+
(wchar_t *__restrict pwcs, const char *__restrict s,
23+
size_t n)) {
24+
static internal::mbstate internal_mbstate;
25+
internal::StringConverter<char8_t> str_conv(
26+
reinterpret_cast<const char8_t *>(pwcs), &internal_mbstate, n);
27+
}
28+
29+
} // namespace LIBC_NAMESPACE_DECL

libc/src/wchar/mbstowcs.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//===-- Implementation header for mbstowcs --------------------------------===//
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_MBSTOWCS_H
10+
#define LLVM_LIBC_SRC_WCHAR_MBSTOWCS_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+
int mbstowcs(wchar_t *__restrict pwcs, const char *__restrict s, size_t n);
19+
20+
} // namespace LIBC_NAMESPACE_DECL
21+
22+
#endif // LLVM_LIBC_SRC_WCHAR_MBSTOWCS_H

0 commit comments

Comments
 (0)