[libc] Implement iswprint entrypoint (#185251)

Implemented the iswprint entrypoint and tests for issue #185136
This commit is contained in:
neonetizen 2026-03-19 12:36:56 -07:00 committed by GitHub
parent 8e1e371561
commit adbb122717
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 99 additions and 1 deletions

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -68,3 +68,9 @@ functions:
return_type: int
arguments:
- type: wint_t
- name: iswprint
standards:
- stdc
return_type: int
arguments:
- type: wint_t

View File

@ -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
)

View 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

View 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

View File

@ -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
)

View 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);
}
}
}