[libc-commits] [libc] [libc]: implement 'iswpunct' entrypoint (PR #186968)
via libc-commits
libc-commits at lists.llvm.org
Tue Mar 17 08:25:02 PDT 2026
https://github.com/Kubikusik updated https://github.com/llvm/llvm-project/pull/186968
>From 619d957eefb1f79f5b515b374c7ed105a8bce5d1 Mon Sep 17 00:00:00 2001
From: kubikusik <jakubmical at student.agh.edu.pl>
Date: Tue, 17 Mar 2026 07:54:44 +0100
Subject: [PATCH 1/2] Add iswpunct entrypoints and related tests
Adds entrypoints to various architectures, as well as tests for correct behaviour of the iswpunct in iswpunct_test.cpp
---
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 | 11 ++++
libc/src/wctype/iswpunct.cpp | 19 +++++++
libc/src/wctype/iswpunct.h | 21 +++++++
libc/test/src/wctype/CMakeLists.txt | 10 ++++
libc/test/src/wctype/iswpunct_test.cpp | 63 +++++++++++++++++++++
14 files changed, 138 insertions(+)
create mode 100644 libc/src/wctype/iswpunct.cpp
create mode 100644 libc/src/wctype/iswpunct.h
create mode 100644 libc/test/src/wctype/iswpunct_test.cpp
diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt
index 7acaca15d39ae..83717616e3135 100644
--- a/libc/config/baremetal/arm/entrypoints.txt
+++ b/libc/config/baremetal/arm/entrypoints.txt
@@ -311,6 +311,7 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.wctype.iswspace
libc.src.wctype.iswblank
libc.src.wctype.iswxdigit
+ libc.src.wctype.iswpunct
# internal entrypoints
libc.startup.baremetal.init
libc.startup.baremetal.fini
diff --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt
index fc6201b44149f..3c922062d2f8b 100644
--- a/libc/config/baremetal/riscv/entrypoints.txt
+++ b/libc/config/baremetal/riscv/entrypoints.txt
@@ -308,6 +308,7 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.wctype.iswspace
libc.src.wctype.iswblank
libc.src.wctype.iswxdigit
+ libc.src.wctype.iswpunct
# internal entrypoints
libc.startup.baremetal.init
diff --git a/libc/config/darwin/aarch64/entrypoints.txt b/libc/config/darwin/aarch64/entrypoints.txt
index 2d26763e29d03..11f142266d9a9 100644
--- a/libc/config/darwin/aarch64/entrypoints.txt
+++ b/libc/config/darwin/aarch64/entrypoints.txt
@@ -111,6 +111,7 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.wctype.iswspace
libc.src.wctype.iswblank
libc.src.wctype.iswxdigit
+ libc.src.wctype.iswpunct
)
if(LLVM_LIBC_FULL_BUILD)
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index 380c91e1ac396..92cf42a296264 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -382,6 +382,7 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.wctype.iswspace
libc.src.wctype.iswblank
libc.src.wctype.iswxdigit
+ libc.src.wctype.iswpunct
# 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 8611082f87003..737d6fcc6016a 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -203,6 +203,7 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.wctype.iswspace
libc.src.wctype.iswblank
libc.src.wctype.iswxdigit
+ libc.src.wctype.iswpunct
)
if(LLVM_LIBC_FULL_BUILD)
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index ddb24c3eea178..312329895e081 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -386,6 +386,7 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.wctype.iswspace
libc.src.wctype.iswblank
libc.src.wctype.iswxdigit
+ libc.src.wctype.iswpunct
# 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 9102de9bf0417..1039c28eb5c6f 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -431,6 +431,7 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.wctype.iswspace
libc.src.wctype.iswblank
libc.src.wctype.iswxdigit
+ libc.src.wctype.iswpunct
# sys/uio.h entrypoints
libc.src.sys.uio.writev
diff --git a/libc/config/windows/entrypoints.txt b/libc/config/windows/entrypoints.txt
index 02b56ab01081b..089cd1c8ede89 100644
--- a/libc/config/windows/entrypoints.txt
+++ b/libc/config/windows/entrypoints.txt
@@ -117,6 +117,7 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.wctype.iswspace
libc.src.wctype.iswblank
libc.src.wctype.iswxdigit
+ libc.src.wctype.iswpunct
)
set(TARGET_LIBM_ENTRYPOINTS
diff --git a/libc/include/wctype.yaml b/libc/include/wctype.yaml
index ca47cae27b640..170eac48e734a 100644
--- a/libc/include/wctype.yaml
+++ b/libc/include/wctype.yaml
@@ -62,3 +62,9 @@ functions:
return_type: int
arguments:
- type: wint_t
+ - name: iswpunct
+ standards:
+ - stdc
+ return_type: int
+ arguments:
+ - type: wint_t
diff --git a/libc/src/wctype/CMakeLists.txt b/libc/src/wctype/CMakeLists.txt
index 73ec0eb9c857f..1e1a7ded46cf3 100644
--- a/libc/src/wctype/CMakeLists.txt
+++ b/libc/src/wctype/CMakeLists.txt
@@ -107,3 +107,14 @@ add_entrypoint_object(
libc.hdr.types.wint_t
libc.src.__support.wctype_utils
)
+
+add_entrypoint_object(
+ iswpunct
+ SRCS
+ iswpunct.cpp
+ HDRS
+ iswpunct.h
+ DEPENDS
+ libc.hdr.types.wint_t
+ libc.src.__support.wctype_utils
+)
diff --git a/libc/src/wctype/iswpunct.cpp b/libc/src/wctype/iswpunct.cpp
new file mode 100644
index 0000000000000..50ffd29b0a3c0
--- /dev/null
+++ b/libc/src/wctype/iswpunct.cpp
@@ -0,0 +1,19 @@
+//===-- Implementation of iswspace ----------------------------------------===//
+//
+// 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/iswpunct.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, iswpunct, (wint_t c)) {
+ return internal::ispunct(static_cast<wchar_t>(c));
+}
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/wctype/iswpunct.h b/libc/src/wctype/iswpunct.h
new file mode 100644
index 0000000000000..ba2c797c85a00
--- /dev/null
+++ b/libc/src/wctype/iswpunct.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for iswspace ----------------------*- 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_ISWPUNCT_H
+#define LLVM_LIBC_SRC_WCTYPE_ISWPUNCT_H
+
+#include "hdr/types/wint_t.h"
+#include "src/__support/common.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+int iswpunct(wint_t c);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_WCTYPE_ISWPUNCT_H
diff --git a/libc/test/src/wctype/CMakeLists.txt b/libc/test/src/wctype/CMakeLists.txt
index 65189a0d16d5a..132d74daaac70 100644
--- a/libc/test/src/wctype/CMakeLists.txt
+++ b/libc/test/src/wctype/CMakeLists.txt
@@ -101,3 +101,13 @@ add_libc_test(
DEPENDS
libc.src.wctype.iswupper
)
+
+add_libc_test(
+ iswpunct_test
+ SUITE
+ libc_wctype_unittests
+ SRCS
+ iswpunct_test.cpp
+ DEPENDS
+ libc.src.wctype.iswpunct
+)
diff --git a/libc/test/src/wctype/iswpunct_test.cpp b/libc/test/src/wctype/iswpunct_test.cpp
new file mode 100644
index 0000000000000..c8eeafd4482f0
--- /dev/null
+++ b/libc/test/src/wctype/iswpunct_test.cpp
@@ -0,0 +1,63 @@
+//===-- Unittests for iswspace --------------------------------------------===//
+//
+// 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/iswpunct.h"
+
+#include "test/UnitTest/Test.h"
+
+TEST(LlvmLibciswpunct, SimpleTest) {
+ EXPECT_NE(LIBC_NAMESPACE::iswpunct('!'), 0);
+ EXPECT_NE(LIBC_NAMESPACE::iswpunct('\"'), 0);
+ EXPECT_NE(LIBC_NAMESPACE::iswpunct('#'), 0);
+ EXPECT_NE(LIBC_NAMESPACE::iswpunct('$'), 0);
+ EXPECT_NE(LIBC_NAMESPACE::iswpunct('%'), 0);
+ EXPECT_NE(LIBC_NAMESPACE::iswpunct('&'), 0);
+ EXPECT_NE(LIBC_NAMESPACE::iswpunct('\''), 0);
+ EXPECT_NE(LIBC_NAMESPACE::iswpunct('('), 0);
+ EXPECT_NE(LIBC_NAMESPACE::iswpunct(')'), 0);
+ EXPECT_NE(LIBC_NAMESPACE::iswpunct('*'), 0);
+ EXPECT_NE(LIBC_NAMESPACE::iswpunct('+'), 0);
+ EXPECT_NE(LIBC_NAMESPACE::iswpunct(','), 0);
+ EXPECT_NE(LIBC_NAMESPACE::iswpunct('-'), 0);
+ EXPECT_NE(LIBC_NAMESPACE::iswpunct('.'), 0);
+ EXPECT_NE(LIBC_NAMESPACE::iswpunct('/'), 0);
+ EXPECT_NE(LIBC_NAMESPACE::iswpunct(':'), 0);
+ EXPECT_NE(LIBC_NAMESPACE::iswpunct(';'), 0);
+ EXPECT_NE(LIBC_NAMESPACE::iswpunct('<'), 0);
+ EXPECT_NE(LIBC_NAMESPACE::iswpunct('='), 0);
+ EXPECT_NE(LIBC_NAMESPACE::iswpunct('>'), 0);
+ EXPECT_NE(LIBC_NAMESPACE::iswpunct('?'), 0);
+ EXPECT_NE(LIBC_NAMESPACE::iswpunct('@'), 0);
+ EXPECT_NE(LIBC_NAMESPACE::iswpunct('['), 0);
+ EXPECT_NE(LIBC_NAMESPACE::iswpunct('\\'), 0);
+ EXPECT_NE(LIBC_NAMESPACE::iswpunct(']'), 0);
+ EXPECT_NE(LIBC_NAMESPACE::iswpunct('^'), 0);
+ EXPECT_NE(LIBC_NAMESPACE::iswpunct('_'), 0);
+ EXPECT_NE(LIBC_NAMESPACE::iswpunct('`'), 0);
+ EXPECT_NE(LIBC_NAMESPACE::iswpunct('{'), 0);
+ EXPECT_NE(LIBC_NAMESPACE::iswpunct('|'), 0);
+ EXPECT_NE(LIBC_NAMESPACE::iswpunct('}'), 0);
+ EXPECT_NE(LIBC_NAMESPACE::iswpunct('~'), 0);
+
+ EXPECT_EQ(LIBC_NAMESPACE::iswpunct('\n'), 0);
+ EXPECT_EQ(LIBC_NAMESPACE::iswpunct('\v'), 0);
+ EXPECT_EQ(LIBC_NAMESPACE::iswpunct('\f'), 0);
+ EXPECT_EQ(LIBC_NAMESPACE::iswpunct('\r'), 0);
+ EXPECT_EQ(LIBC_NAMESPACE::iswpunct('\0'), 0);
+ EXPECT_EQ(LIBC_NAMESPACE::iswpunct('\t'), 0);
+ EXPECT_EQ(LIBC_NAMESPACE::iswpunct(' '), 0);
+ EXPECT_EQ(LIBC_NAMESPACE::iswpunct('0'), 0);
+ EXPECT_EQ(LIBC_NAMESPACE::iswpunct('5'), 0);
+ EXPECT_EQ(LIBC_NAMESPACE::iswpunct('9'), 0);
+ EXPECT_EQ(LIBC_NAMESPACE::iswpunct('A'), 0);
+ EXPECT_EQ(LIBC_NAMESPACE::iswpunct('M'), 0);
+ EXPECT_EQ(LIBC_NAMESPACE::iswpunct('Z'), 0);
+ EXPECT_EQ(LIBC_NAMESPACE::iswpunct('a'), 0);
+ EXPECT_EQ(LIBC_NAMESPACE::iswpunct('m'), 0);
+ EXPECT_EQ(LIBC_NAMESPACE::iswpunct('z'), 0);
+}
>From 8471bf3f2c6f1a725d88715b9d92db5ab345002a Mon Sep 17 00:00:00 2001
From: kubikusik <jakubmical at student.agh.edu.pl>
Date: Tue, 17 Mar 2026 16:23:46 +0100
Subject: [PATCH 2/2] fix: fixed typos and added the missing common dependency
---
libc/src/wctype/CMakeLists.txt | 1 +
libc/src/wctype/iswpunct.cpp | 2 +-
libc/src/wctype/iswpunct.h | 2 +-
3 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/libc/src/wctype/CMakeLists.txt b/libc/src/wctype/CMakeLists.txt
index 1e1a7ded46cf3..ac23cc43be0ad 100644
--- a/libc/src/wctype/CMakeLists.txt
+++ b/libc/src/wctype/CMakeLists.txt
@@ -115,6 +115,7 @@ add_entrypoint_object(
HDRS
iswpunct.h
DEPENDS
+ libc.src.__support.common
libc.hdr.types.wint_t
libc.src.__support.wctype_utils
)
diff --git a/libc/src/wctype/iswpunct.cpp b/libc/src/wctype/iswpunct.cpp
index 50ffd29b0a3c0..d02bbbb2ed00a 100644
--- a/libc/src/wctype/iswpunct.cpp
+++ b/libc/src/wctype/iswpunct.cpp
@@ -1,4 +1,4 @@
-//===-- Implementation of iswspace ----------------------------------------===//
+//===-- Implementation of iswpunct ----------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/libc/src/wctype/iswpunct.h b/libc/src/wctype/iswpunct.h
index ba2c797c85a00..28fd7c37ab9c0 100644
--- a/libc/src/wctype/iswpunct.h
+++ b/libc/src/wctype/iswpunct.h
@@ -1,4 +1,4 @@
-//===-- Implementation header for iswspace ----------------------*- C++ -*-===//
+//===-- Implementation header for iswpunct ----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
More information about the libc-commits
mailing list