[libc-commits] [libc] [libc] Implement iswprint entrypoint (PR #185251)
via libc-commits
libc-commits at lists.llvm.org
Sat Mar 7 21:36:12 PST 2026
https://github.com/neonetizen created https://github.com/llvm/llvm-project/pull/185251
<img width="645" height="126" alt="image" src="https://github.com/user-attachments/assets/d0d5b2dd-d4ab-4ece-902b-bc5a0143b886" />
Added the iswprint entrypoint and tests for issue #185136
>From f47c99a7ef5b90dc6d14bb2162376eb1e8710ce2 Mon Sep 17 00:00:00 2001
From: neonetizen <justin.pelak7 at gmail.com>
Date: Sat, 7 Mar 2026 21:31:18 -0800
Subject: [PATCH] [libc] Implement iswprint entrypoint
---
libc/config/baremetal/arm/entrypoints.txt | 1 +
libc/config/baremetal/riscv/entrypoints.txt | 1 +
libc/config/darwin/aarch64/entrypoints.txt | 1 +
libc/config/linux/aarch64/entrypoints.txt | 1 +
libc/config/linux/arm/entrypoints.txt | 1 +
libc/config/linux/riscv/entrypoints.txt | 1 +
libc/config/linux/x86_64/entrypoints.txt | 1 +
libc/config/windows/entrypoints.txt | 1 +
libc/include/wctype.yaml | 6 ++++++
libc/src/wctype/CMakeLists.txt | 10 ++++++++++
libc/src/wctype/iswprint.cpp | 21 ++++++++++++++++++++
libc/src/wctype/iswprint.h | 21 ++++++++++++++++++++
libc/test/src/wctype/CMakeLists.txt | 10 ++++++++++
libc/test/src/wctype/iswprint_test.cpp | 22 +++++++++++++++++++++
14 files changed, 98 insertions(+)
create mode 100644 libc/src/wctype/iswprint.cpp
create mode 100644 libc/src/wctype/iswprint.h
create mode 100644 libc/test/src/wctype/iswprint_test.cpp
diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt
index 7bc92e84b7fa4..08e12b26df8f5 100644
--- a/libc/config/baremetal/arm/entrypoints.txt
+++ b/libc/config/baremetal/arm/entrypoints.txt
@@ -299,6 +299,7 @@ set(TARGET_LIBC_ENTRYPOINTS
# wctype.h entrypoints
libc.src.wctype.iswalpha
+ libc.src.wctype.iswprint
# internal entrypoints
libc.startup.baremetal.init
diff --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt
index 29be47dfbfd53..601f98abe704c 100644
--- a/libc/config/baremetal/riscv/entrypoints.txt
+++ b/libc/config/baremetal/riscv/entrypoints.txt
@@ -296,6 +296,7 @@ set(TARGET_LIBC_ENTRYPOINTS
# wctype.h entrypoints
libc.src.wctype.iswalpha
+ libc.src.wctype.iswprint
# internal entrypoints
libc.startup.baremetal.init
diff --git a/libc/config/darwin/aarch64/entrypoints.txt b/libc/config/darwin/aarch64/entrypoints.txt
index b4a1ee70764cb..c8536b8459aed 100644
--- a/libc/config/darwin/aarch64/entrypoints.txt
+++ b/libc/config/darwin/aarch64/entrypoints.txt
@@ -102,6 +102,7 @@ set(TARGET_LIBC_ENTRYPOINTS
# wctype.h entrypoints
libc.src.wctype.iswalpha
+ libc.src.wctype.iswprint
)
if(LLVM_LIBC_FULL_BUILD)
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index 960958b7cf90a..a56d6a5af39a5 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -369,6 +369,7 @@ set(TARGET_LIBC_ENTRYPOINTS
# wctype.h entrypoints
libc.src.wctype.iswalpha
+ libc.src.wctype.iswprint
# sys/uio.h entrypoints
libc.src.sys.uio.writev
diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt
index e76bf81670ce5..786e3ebee3f00 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -194,6 +194,7 @@ set(TARGET_LIBC_ENTRYPOINTS
# wctype.h entrypoints
libc.src.wctype.iswalpha
+ libc.src.wctype.iswprint
)
if(LLVM_LIBC_FULL_BUILD)
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index a69d1a1b0a642..1c1af4a24559d 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -373,6 +373,7 @@ set(TARGET_LIBC_ENTRYPOINTS
# wctype.h entrypoints
libc.src.wctype.iswalpha
+ libc.src.wctype.iswprint
# sys/uio.h entrypoints
libc.src.sys.uio.writev
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 4103ee0331a23..e5d0d1884cb1d 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -418,6 +418,7 @@ set(TARGET_LIBC_ENTRYPOINTS
# wctype.h entrypoints
libc.src.wctype.iswalpha
+ libc.src.wctype.iswprint
# sys/uio.h entrypoints
libc.src.sys.uio.writev
diff --git a/libc/config/windows/entrypoints.txt b/libc/config/windows/entrypoints.txt
index f777fc6c94bc2..9cea47cb8da45 100644
--- a/libc/config/windows/entrypoints.txt
+++ b/libc/config/windows/entrypoints.txt
@@ -108,6 +108,7 @@ set(TARGET_LIBC_ENTRYPOINTS
# wctype.h entrypoints
libc.src.wctype.iswalpha
+ libc.src.wctype.iswprint
)
set(TARGET_LIBM_ENTRYPOINTS
diff --git a/libc/include/wctype.yaml b/libc/include/wctype.yaml
index fb4f96f7d17e4..59b879e20dd2b 100644
--- a/libc/include/wctype.yaml
+++ b/libc/include/wctype.yaml
@@ -8,3 +8,9 @@ functions:
return_type: int
arguments:
- type: wint_t
+ - name: iswprint
+ standards:
+ - stdc
+ return_type: int
+ arguments:
+ - type: wint_t
\ No newline at end of file
diff --git a/libc/src/wctype/CMakeLists.txt b/libc/src/wctype/CMakeLists.txt
index 3ac5eaef8ed8b..8255bce2d3804 100644
--- a/libc/src/wctype/CMakeLists.txt
+++ b/libc/src/wctype/CMakeLists.txt
@@ -7,3 +7,13 @@ add_entrypoint_object(
DEPENDS
libc.src.__support.wctype_utils
)
+
+add_entrypoint_object(
+ iswprint
+ SRCS
+ iswprint.cpp
+ HDRS
+ iswprint.h
+ DEPENDS
+ libc.src.__support.wctype_utils
+)
\ No newline at end of file
diff --git a/libc/src/wctype/iswprint.cpp b/libc/src/wctype/iswprint.cpp
new file mode 100644
index 0000000000000..b291a52054e1f
--- /dev/null
+++ b/libc/src/wctype/iswprint.cpp
@@ -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
diff --git a/libc/src/wctype/iswprint.h b/libc/src/wctype/iswprint.h
new file mode 100644
index 0000000000000..e848bcca2acc4
--- /dev/null
+++ b/libc/src/wctype/iswprint.h
@@ -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
diff --git a/libc/test/src/wctype/CMakeLists.txt b/libc/test/src/wctype/CMakeLists.txt
index 5459cdb4a9b71..1473d7ab8cc18 100644
--- a/libc/test/src/wctype/CMakeLists.txt
+++ b/libc/test/src/wctype/CMakeLists.txt
@@ -9,3 +9,13 @@ add_libc_test(
DEPENDS
libc.src.wctype.iswalpha
)
+
+add_libc_test(
+ iswprint_test
+ SUITE
+ libc_wctype_unittests
+ SRCS
+ iswprint_test.cpp
+ DEPENDS
+ libc.src.wctype.iswprint
+)
diff --git a/libc/test/src/wctype/iswprint_test.cpp b/libc/test/src/wctype/iswprint_test.cpp
new file mode 100644
index 0000000000000..c83932b4b9785
--- /dev/null
+++ b/libc/test/src/wctype/iswprint_test.cpp
@@ -0,0 +1,22 @@
+//===-- 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/__support/CPP/span.h"
+#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);
+ }
+ }
+}
More information about the libc-commits
mailing list