[libc] Implement iswprint entrypoint (#185251)
Implemented the iswprint entrypoint and tests for issue #185136
This commit is contained in:
parent
8e1e371561
commit
adbb122717
@ -312,6 +312,7 @@ set(TARGET_LIBC_ENTRYPOINTS
|
||||
libc.src.wctype.iswblank
|
||||
libc.src.wctype.iswxdigit
|
||||
libc.src.wctype.iswpunct
|
||||
libc.src.wctype.iswprint
|
||||
# internal entrypoints
|
||||
libc.startup.baremetal.init
|
||||
libc.startup.baremetal.fini
|
||||
|
||||
@ -309,6 +309,7 @@ set(TARGET_LIBC_ENTRYPOINTS
|
||||
libc.src.wctype.iswblank
|
||||
libc.src.wctype.iswxdigit
|
||||
libc.src.wctype.iswpunct
|
||||
libc.src.wctype.iswprint
|
||||
|
||||
# internal entrypoints
|
||||
libc.startup.baremetal.init
|
||||
|
||||
@ -112,6 +112,7 @@ set(TARGET_LIBC_ENTRYPOINTS
|
||||
libc.src.wctype.iswblank
|
||||
libc.src.wctype.iswxdigit
|
||||
libc.src.wctype.iswpunct
|
||||
libc.src.wctype.iswprint
|
||||
)
|
||||
|
||||
if(LLVM_LIBC_FULL_BUILD)
|
||||
|
||||
@ -383,6 +383,7 @@ set(TARGET_LIBC_ENTRYPOINTS
|
||||
libc.src.wctype.iswblank
|
||||
libc.src.wctype.iswxdigit
|
||||
libc.src.wctype.iswpunct
|
||||
libc.src.wctype.iswprint
|
||||
|
||||
# sys/uio.h entrypoints
|
||||
libc.src.sys.uio.writev
|
||||
|
||||
@ -204,6 +204,7 @@ set(TARGET_LIBC_ENTRYPOINTS
|
||||
libc.src.wctype.iswblank
|
||||
libc.src.wctype.iswxdigit
|
||||
libc.src.wctype.iswpunct
|
||||
libc.src.wctype.iswprint
|
||||
)
|
||||
|
||||
if(LLVM_LIBC_FULL_BUILD)
|
||||
|
||||
@ -387,6 +387,7 @@ set(TARGET_LIBC_ENTRYPOINTS
|
||||
libc.src.wctype.iswblank
|
||||
libc.src.wctype.iswxdigit
|
||||
libc.src.wctype.iswpunct
|
||||
libc.src.wctype.iswprint
|
||||
|
||||
# sys/uio.h entrypoints
|
||||
libc.src.sys.uio.writev
|
||||
|
||||
@ -437,6 +437,7 @@ set(TARGET_LIBC_ENTRYPOINTS
|
||||
libc.src.wctype.iswblank
|
||||
libc.src.wctype.iswxdigit
|
||||
libc.src.wctype.iswpunct
|
||||
libc.src.wctype.iswprint
|
||||
|
||||
# sys/uio.h entrypoints
|
||||
libc.src.sys.uio.writev
|
||||
|
||||
@ -118,6 +118,7 @@ set(TARGET_LIBC_ENTRYPOINTS
|
||||
libc.src.wctype.iswblank
|
||||
libc.src.wctype.iswxdigit
|
||||
libc.src.wctype.iswpunct
|
||||
libc.src.wctype.iswprint
|
||||
)
|
||||
|
||||
set(TARGET_LIBM_ENTRYPOINTS
|
||||
|
||||
@ -68,3 +68,9 @@ functions:
|
||||
return_type: int
|
||||
arguments:
|
||||
- type: wint_t
|
||||
- name: iswprint
|
||||
standards:
|
||||
- stdc
|
||||
return_type: int
|
||||
arguments:
|
||||
- type: wint_t
|
||||
|
||||
@ -5,7 +5,7 @@ add_entrypoint_object(
|
||||
HDRS
|
||||
iswalpha.h
|
||||
DEPENDS
|
||||
libc.src.__support.wctype_utils
|
||||
libc.src.__support.wctype_utils
|
||||
)
|
||||
|
||||
add_entrypoint_object(
|
||||
@ -119,3 +119,14 @@ add_entrypoint_object(
|
||||
libc.src.__support.wctype_utils
|
||||
libc.hdr.types.wint_t
|
||||
)
|
||||
|
||||
add_entrypoint_object(
|
||||
iswprint
|
||||
SRCS
|
||||
iswprint.cpp
|
||||
HDRS
|
||||
iswprint.h
|
||||
DEPENDS
|
||||
libc.src.__support.wctype_utils
|
||||
libc.hdr.types.wint_t
|
||||
)
|
||||
|
||||
21
libc/src/wctype/iswprint.cpp
Normal file
21
libc/src/wctype/iswprint.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
//===-- Implementation of iswprint ----------------------------------------===//
|
||||
//
|
||||
// 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/wctype/iswprint.h"
|
||||
#include "src/__support/common.h"
|
||||
#include "src/__support/wctype_utils.h"
|
||||
|
||||
#include "hdr/types/wint_t.h"
|
||||
|
||||
namespace LIBC_NAMESPACE_DECL {
|
||||
|
||||
LLVM_LIBC_FUNCTION(int, iswprint, (wint_t c)) {
|
||||
return internal::isprint(static_cast<wchar_t>(c));
|
||||
}
|
||||
|
||||
} // namespace LIBC_NAMESPACE_DECL
|
||||
21
libc/src/wctype/iswprint.h
Normal file
21
libc/src/wctype/iswprint.h
Normal file
@ -0,0 +1,21 @@
|
||||
//===-- Implementation header for iswprint ----------------------*- C++ -*-===//
|
||||
//
|
||||
// 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
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_LIBC_SRC_WCTYPE_ISWPRINT_H
|
||||
#define LLVM_LIBC_SRC_WCTYPE_ISWPRINT_H
|
||||
|
||||
#include "hdr/types/wint_t.h"
|
||||
#include "src/__support/common.h"
|
||||
|
||||
namespace LIBC_NAMESPACE_DECL {
|
||||
|
||||
int iswprint(wint_t c);
|
||||
|
||||
} // namespace LIBC_NAMESPACE_DECL
|
||||
|
||||
#endif // LLVM_LIBC_SRC_WCTYPE_ISWPRINT_H
|
||||
@ -111,3 +111,13 @@ add_libc_test(
|
||||
DEPENDS
|
||||
libc.src.wctype.iswpunct
|
||||
)
|
||||
|
||||
add_libc_test(
|
||||
iswprint_test
|
||||
SUITE
|
||||
libc_wctype_unittests
|
||||
SRCS
|
||||
iswprint_test.cpp
|
||||
DEPENDS
|
||||
libc.src.wctype.iswprint
|
||||
)
|
||||
|
||||
21
libc/test/src/wctype/iswprint_test.cpp
Normal file
21
libc/test/src/wctype/iswprint_test.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
//===-- Unittests for iswprint --------------------------------------------===//
|
||||
//
|
||||
// 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/wctype/iswprint.h"
|
||||
|
||||
#include "test/UnitTest/Test.h"
|
||||
|
||||
TEST(LlvmLibciswprint, SimpleTest) {
|
||||
for (int ch = -255; ch < 255; ++ch) {
|
||||
if (' ' <= ch && ch <= '~') {
|
||||
EXPECT_NE(LIBC_NAMESPACE::iswprint(ch), 0);
|
||||
} else {
|
||||
EXPECT_EQ(LIBC_NAMESPACE::iswprint(ch), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user